Merge branch 'dev' into staging

This commit is contained in:
Nastya 2024-04-13 02:44:41 +03:00
commit f7eda79bec
3 changed files with 48 additions and 9 deletions

@ -30,6 +30,8 @@ export type GetPromocodeListBody = {
export type Promocode = CreatePromocodeBody & {
id: string;
dueTo: number;
activationLimit: number;
outdated: boolean;
offLimit: boolean;
delete: boolean;

@ -312,16 +312,13 @@ export const CreatePromocodeForm = ({ createPromocode }: Props) => {
name="privilegeId"
as={Select}
label="Привилегия"
onChange={({ target }: SelectChangeProps) => {
const currentPrivilege = privileges.find(
(item) => item.privilegeId === target.value
);
setFieldValue("serviceKey", currentPrivilege?.serviceKey);
setFieldValue("privilegeId", currentPrivilege?.privilegeId);
const currentPrivilege = privileges.find(
(item) => item.privilegeId === target.value
);
setFieldValue("serviceKey", currentPrivilege?.serviceKey);
setFieldValue("privilegeId", currentPrivilege?.privilegeId);
}}
sx={{
width: "100%",

@ -12,6 +12,7 @@ import {
import { DataGrid, GridLoadingOverlay, GridToolbar } from "@mui/x-data-grid";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { usePrivilegeStore } from "@root/stores/privilegesStore";
import { fadeIn } from "@root/utils/style/keyframes";
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
@ -98,6 +99,14 @@ export const StatisticsModal = ({
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down(550));
const [rows, setRows] = useState<Row[]>([]);
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 createFastlink = async () => {
await createFastLink(id);
@ -142,7 +151,9 @@ export const StatisticsModal = ({
setStartDate(new Date());
setEndDate(new Date());
}}
sx={{ "& > .MuiBox-root": { outline: "none" } }}
sx={{
"& > .MuiBox-root": { outline: "none", padding: "32px 32px 16px" },
}}
>
<Box
sx={{
@ -282,6 +293,35 @@ export const StatisticsModal = ({
rowsPerPageOptions={[10, 25, 50, 100]}
autoHeight
/>
{
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>
<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>
);