Merge branch 'dev' into 'staging'
Dev See merge request frontend/admin!78
This commit is contained in:
commit
888fefae2b
@ -4,14 +4,20 @@ import { Promocode } from "@root/model/promocodes";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { BarChart, Delete } from "@mui/icons-material";
|
||||
import {promocodeApi} from "@root/api/promocode/requests";
|
||||
import { promocodeApi } from "@root/api/promocode/requests";
|
||||
|
||||
export function usePromocodeGridColDef(
|
||||
setStatistics: (id: string) => void,
|
||||
deletePromocode: (id: string) => void
|
||||
) {
|
||||
const validity = (value:string|number) => {if(value===0){return "неоганичен"}else {return new Date(value).toLocaleString()}}
|
||||
return useMemo<GridColDef<Promocode, string | number, string >[]>(
|
||||
const validity = (value: string | number) => {
|
||||
if (value === 0) {
|
||||
return "неоганичен";
|
||||
} else {
|
||||
return new Date(value).toLocaleString();
|
||||
}
|
||||
};
|
||||
return useMemo<GridColDef<Promocode, string | number, string>[]>(
|
||||
() => [
|
||||
{
|
||||
field: "id",
|
||||
@ -50,6 +56,14 @@ export function usePromocodeGridColDef(
|
||||
valueGetter: ({ row }) => row.dueTo * 1000,
|
||||
valueFormatter: ({ value }) => `${validity(value)}`,
|
||||
},
|
||||
{
|
||||
field: "description",
|
||||
headerName: "Описание",
|
||||
minWidth: 200,
|
||||
flex: 1,
|
||||
sortable: false,
|
||||
valueGetter: ({ row }) => row.description,
|
||||
},
|
||||
{
|
||||
field: "settings",
|
||||
headerName: "",
|
||||
@ -57,10 +71,12 @@ export function usePromocodeGridColDef(
|
||||
sortable: false,
|
||||
renderCell: (params) => {
|
||||
return (
|
||||
<IconButton onClick={() => {
|
||||
setStatistics(params.row.id,)
|
||||
promocodeApi.getPromocodeStatistics(params.row.id, 0, 0)
|
||||
}}>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
setStatistics(params.row.id);
|
||||
promocodeApi.getPromocodeStatistics(params.row.id, 0, 0);
|
||||
}}
|
||||
>
|
||||
<BarChart />
|
||||
</IconButton>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user