fix: fast links list
This commit is contained in:
parent
aa3dbe6761
commit
4181d6d9ca
@ -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,
|
||||
|
||||
@ -53,7 +53,8 @@ const COLUMNS: GridColDef<Row, string>[] = [
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
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 ?
|
||||
|
||||
<Typography
|
||||
sx={{
|
||||
margin: "10px 0 0",
|
||||
textAlign: "center",
|
||||
color: theme.palette.secondary.main,
|
||||
}}
|
||||
>
|
||||
Нет привилегии
|
||||
{privilege === undefined ? (
|
||||
<Typography
|
||||
sx={{
|
||||
margin: "10px 0 0",
|
||||
textAlign: "center",
|
||||
color: theme.palette.secondary.main,
|
||||
}}
|
||||
>
|
||||
Нет привилегии
|
||||
</Typography>
|
||||
) : (
|
||||
<Box
|
||||
sx={{
|
||||
color: "#e6e8ec",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
margin: "20px 0",
|
||||
}}
|
||||
>
|
||||
<Typography>название привилегии: {privilege.name}</Typography>
|
||||
<Typography>
|
||||
{promocode?.activationCount} активаций из{" "}
|
||||
{promocode?.activationLimit}
|
||||
</Typography>
|
||||
:
|
||||
<Box
|
||||
sx={{
|
||||
color: "#e6e8ec",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
margin: "20px 0",
|
||||
}}
|
||||
>
|
||||
<Typography>название привилегии: {privilege.name}</Typography>
|
||||
<Typography>{promocode?.activationCount} активаций из {promocode?.activationLimit}</Typography>
|
||||
<Typography>приветствие: "{promocode?.greetings}"</Typography>
|
||||
{promocode?.bonus?.discount?.factor !== undefined && <Typography>скидка: {100 - (promocode?.bonus?.discount?.factor * 100)}%</Typography>}
|
||||
{<Typography>количество привилегии: {promocode?.bonus?.privilege?.amount}</Typography>}
|
||||
{promocode?.dueTo !== undefined && promocode.dueTo > 0 && <Typography>действует до: {new Date(promocode.dueTo).toLocaleString()}</Typography>}
|
||||
</Box>
|
||||
}
|
||||
<Typography>приветствие: "{promocode?.greetings}"</Typography>
|
||||
{promocode?.bonus?.discount?.factor !== undefined && (
|
||||
<Typography>
|
||||
скидка: {100 - promocode?.bonus?.discount?.factor * 100}%
|
||||
</Typography>
|
||||
)}
|
||||
{
|
||||
<Typography>
|
||||
количество привилегии: {promocode?.bonus?.privilege?.amount}
|
||||
</Typography>
|
||||
}
|
||||
{promocode?.dueTo !== undefined && promocode.dueTo > 0 && (
|
||||
<Typography>
|
||||
действует до: {new Date(promocode.dueTo).toLocaleString()}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user