feat: prettier

This commit is contained in:
2024-09-27 04:47:04 +03:00
parent c5f839d9ef
commit de4fe450ab
253 changed files with 11322 additions and 10004 deletions

View File

@@ -1,9 +1,14 @@
import {useEffect, useState} from "react";
import {ClientSchema, MarketplaceSchema, MarketplaceService, TaskService} from "../../../client";
import {notifications} from "../../../shared/lib/notifications.ts";
import {RootState, useAppDispatch} from "../../../redux/store.ts";
import {addTask} from "../../../features/tasksSlice.tsx";
import {useSelector} from "react-redux";
import { useEffect, useState } from "react";
import {
ClientSchema,
MarketplaceSchema,
MarketplaceService,
TaskService,
} from "../../../client";
import { notifications } from "../../../shared/lib/notifications.ts";
import { RootState, useAppDispatch } from "../../../redux/store.ts";
import { addTask } from "../../../features/tasksSlice.tsx";
import { useSelector } from "react-redux";
const useMarketplacesPageState = () => {
const dispatch = useAppDispatch();
@@ -14,12 +19,12 @@ const useMarketplacesPageState = () => {
if (!client) return;
MarketplaceService.getClientMarketplaces({
requestBody: {
clientId: client.id
}
}).then((response) => {
clientId: client.id,
},
}).then(response => {
setItems(response.marketplaces);
})
}
});
};
const onCreate = (marketplace: MarketplaceSchema) => {
MarketplaceService.createMarketplace({
@@ -27,77 +32,78 @@ const useMarketplacesPageState = () => {
marketplace: {
...marketplace,
clientId: marketplace.client.id,
baseMarketplaceKey: marketplace.baseMarketplace.key
}
}
}).then(async ({ok, message}) => {
notifications.guess(ok, {message});
baseMarketplaceKey: marketplace.baseMarketplace.key,
},
},
}).then(async ({ ok, message }) => {
notifications.guess(ok, { message });
if (!ok) return;
await fetchMarketplaces();
})
}
});
};
const onDelete = (marketplace: MarketplaceSchema) => {
MarketplaceService.deleteMarketplace({
requestBody: {
marketplaceId: marketplace.id
}
}).then(async ({ok, message}) => {
notifications.guess(ok, {message});
marketplaceId: marketplace.id,
},
}).then(async ({ ok, message }) => {
notifications.guess(ok, { message });
if (!ok) return;
await fetchMarketplaces();
})
}
});
};
const onChange = (marketplace: MarketplaceSchema) => {
MarketplaceService.updateMarketplace({
requestBody: {
marketplace: marketplace
}
}).then(async ({ok, message}) => {
notifications.guess(ok, {message});
marketplace: marketplace,
},
}).then(async ({ ok, message }) => {
notifications.guess(ok, { message });
if (!ok) return;
await fetchMarketplaces();
})
}
});
};
const onSynchronize = (marketplace: MarketplaceSchema) => {
const task = tasks.find(task => task.info.marketplaceId === marketplace.id);
const task = tasks.find(
task => task.info.marketplaceId === marketplace.id
);
if (task) {
notifications.error({
title: 'Ошибка',
message: `Синхронизация маркетплейса ${marketplace.name} уже запущена`
title: "Ошибка",
message: `Синхронизация маркетплейса ${marketplace.name} уже запущена`,
});
return;
}
TaskService.createSynchronizeMarketplaceTask({
requestBody: {
marketplaceId:
marketplace.id
}
}).then(({taskId}) => {
dispatch(addTask({
id: taskId,
config: {
onErrorData: {
title: 'Ошибка',
message: `Ошибка синхронизации маркетплейса: ${marketplace.name}`
marketplaceId: marketplace.id,
},
}).then(({ taskId }) => {
dispatch(
addTask({
id: taskId,
config: {
onErrorData: {
title: "Ошибка",
message: `Ошибка синхронизации маркетплейса: ${marketplace.name}`,
},
onLoadingData: {
title: "Синхронизация",
message: `Синхронизация маркетплейса: ${marketplace.name}`,
},
onSuccessData: {
title: "Успех",
message: `Маркетплейс ${marketplace.name} успешно синхронизирован`,
},
},
onLoadingData: {
title: 'Синхронизация',
message: `Синхронизация маркетплейса: ${marketplace.name}`
info: {
marketplaceId: marketplace.id,
},
onSuccessData: {
title: 'Успех',
message: `Маркетплейс ${marketplace.name} успешно синхронизирован`
}
},
info: {
marketplaceId: marketplace.id
}
}));
})
}
})
);
});
};
useEffect(() => {
fetchMarketplaces();
}, [client]);
@@ -108,7 +114,7 @@ const useMarketplacesPageState = () => {
onDelete,
onChange,
onCreate,
onSynchronize
}
}
export default useMarketplacesPageState;
onSynchronize,
};
};
export default useMarketplacesPageState;