diff --git a/src/api/promocode/swr.ts b/src/api/promocode/swr.ts index 05b9424..bb21130 100644 --- a/src/api/promocode/swr.ts +++ b/src/api/promocode/swr.ts @@ -111,16 +111,19 @@ export function usePromocodes( } ); - const createFastLink = useCallback(async function (id: string) { - try { - await promocodeApi.createFastlink(id); - mutate(["promocodes", page, pageSize]); - } catch (error) { - console.log("Error creating fast link", error); - if (error instanceof Error) - enqueueSnackbar(error.message, { variant: "error" }); - } - }, [page, pageSize]); + const createFastLink = useCallback( + async function (id: string) { + try { + await promocodeApi.createFastlink(id); + mutate(["promocodes", page, pageSize]); + } catch (error) { + console.log("Error creating fast link", error); + if (error instanceof Error) + enqueueSnackbar(error.message, { variant: "error" }); + } + }, + [page, pageSize] + ); return { ...swrResponse, diff --git a/src/pages/dashboard/Content/PromocodeManagement/StatisticsModal.tsx b/src/pages/dashboard/Content/PromocodeManagement/StatisticsModal.tsx index 9dec31f..69e8c7c 100644 --- a/src/pages/dashboard/Content/PromocodeManagement/StatisticsModal.tsx +++ b/src/pages/dashboard/Content/PromocodeManagement/StatisticsModal.tsx @@ -53,7 +53,8 @@ const COLUMNS: GridColDef[] = [ navigator.clipboard.writeText( - `https://${isTest ? "s" : ""}hub.pena.digital/?fl=${params.row.link + `https://${isTest ? "s" : ""}hub.pena.digital/?fl=${ + params.row.link }` ) } @@ -107,18 +108,15 @@ export const StatisticsModal = ({ const { privileges } = usePrivilegeStore(); const currentPrivilegeId = promocodes.find((promocode) => promocode.id === id) ?.bonus.privilege.privilegeID; - const privilege = - privileges.find((item) => item.privilegeId === currentPrivilegeId); - const promocode = - promocodes.find((item) => item.id === id); - console.log(promocode) + const privilege = privileges.find( + (item) => item.privilegeId === currentPrivilegeId + ); + const promocode = promocodes.find((item) => item.id === id); const createFastlink = async () => { await createFastLink(id); - - getParseData(); }; - const getParseData = async () => { + const getParseData = () => { const rows = promocodes .find((promocode) => promocode.id === id) ?.fastLinks?.map((link, index) => ({ @@ -138,7 +136,7 @@ export const StatisticsModal = ({ if (!id) { setRows([]); } - }, [id]); + }, [id, promocodes]); // const formatTo = to === null ? 0 : moment(to).unix() // const formatFrom = from === null ? 0 : moment(from).unix() @@ -298,35 +296,48 @@ export const StatisticsModal = ({ rowsPerPageOptions={[10, 25, 50, 100]} autoHeight /> - { - privilege === undefined ? - - - Нет привилегии + {privilege === undefined ? ( + + Нет привилегии + + ) : ( + + название привилегии: {privilege.name} + + {promocode?.activationCount} активаций из{" "} + {promocode?.activationLimit} - : - - название привилегии: {privilege.name} - {promocode?.activationCount} активаций из {promocode?.activationLimit} - приветствие: "{promocode?.greetings}" - {promocode?.bonus?.discount?.factor !== undefined && скидка: {100 - (promocode?.bonus?.discount?.factor * 100)}%} - {количество привилегии: {promocode?.bonus?.privilege?.amount}} - {promocode?.dueTo !== undefined && promocode.dueTo > 0 && действует до: {new Date(promocode.dueTo).toLocaleString()}} - - } + приветствие: "{promocode?.greetings}" + {promocode?.bonus?.discount?.factor !== undefined && ( + + скидка: {100 - promocode?.bonus?.discount?.factor * 100}% + + )} + { + + количество привилегии: {promocode?.bonus?.privilege?.amount} + + } + {promocode?.dueTo !== undefined && promocode.dueTo > 0 && ( + + действует до: {new Date(promocode.dueTo).toLocaleString()} + + )} + + )} );