Привилегии
This commit is contained in:
parent
aeb6a879eb
commit
4904775397
@ -1,6 +1,5 @@
|
||||
import { ServiceType, Privilege, Tariff } from "./tariff";
|
||||
|
||||
|
||||
interface DiscountBase {
|
||||
_id: string;
|
||||
name: string;
|
||||
|
44
src/model/discount.ts
Normal file
44
src/model/discount.ts
Normal file
@ -0,0 +1,44 @@
|
||||
export type Discount = {
|
||||
ID: string;
|
||||
Name: string;
|
||||
Layer: number;
|
||||
Description: string;
|
||||
Condition: {
|
||||
Period?: {
|
||||
From: string;
|
||||
To: string;
|
||||
};
|
||||
User?: string;
|
||||
UserType?: string;
|
||||
Coupon?: string;
|
||||
PurchasesAmount?: number;
|
||||
CartPurchasesAmount?: number;
|
||||
Product?: string;
|
||||
Term?: string;
|
||||
Usage?: string;
|
||||
PriceFrom?: number;
|
||||
Group?: string;
|
||||
};
|
||||
Target: {
|
||||
Products?: {
|
||||
ID: string;
|
||||
Factor: number;
|
||||
Overhelm: boolean;
|
||||
}[];
|
||||
Factor?: number;
|
||||
TargetScope?: string;
|
||||
TargetGroup?: string;
|
||||
Overhelm?: boolean;
|
||||
};
|
||||
Audit: {
|
||||
UpdatedAt: string;
|
||||
CreatedAt: string;
|
||||
DeletedAt: string;
|
||||
Deleted: boolean;
|
||||
};
|
||||
Deprecated: boolean;
|
||||
};
|
||||
|
||||
export type DiscountData = {
|
||||
Discounts: Discount[];
|
||||
};
|
@ -1,3 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { Box, Button, styled, useTheme } from "@mui/material";
|
||||
import { DataGrid, GridColDef, GridRowsProp, GridToolbar } from "@mui/x-data-grid";
|
||||
import { findDiscountFactor, formatDiscountFactor } from "@root/kitUI/Cart/calc";
|
||||
@ -8,8 +10,8 @@ import {
|
||||
useDiscountStore,
|
||||
} from "@root/stores/discounts";
|
||||
import axios from "axios";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import type { DiscountData } from "@root/model/discount";
|
||||
|
||||
const BoxButton = styled("div")(({ theme }) => ({
|
||||
[theme.breakpoints.down(400)]: {
|
||||
@ -64,17 +66,21 @@ const columns: GridColDef[] = [
|
||||
|
||||
export default function DiscountDataGrid() {
|
||||
const theme = useTheme();
|
||||
const discounts = useDiscountStore((state) => state.discounts);
|
||||
const exampleDiscounts = useDiscountStore((state) => state.discounts);
|
||||
const selectedDiscountIds = useDiscountStore((state) => state.selectedDiscountIds);
|
||||
|
||||
const [discount, setDiscount] = useState();
|
||||
const [discount, setDiscount] = useState<DiscountData>();
|
||||
|
||||
const mergeDiscount = [...(discount?.Discounts ?? []), ...exampleDiscounts];
|
||||
|
||||
console.log(mergeDiscount);
|
||||
|
||||
useEffect(() => {
|
||||
const axiosDiscount = async () => {
|
||||
try {
|
||||
const { data } = await axios({
|
||||
method: "get",
|
||||
url: "https://penahub.gitlab.yandexcloud.net/price/discount/all",
|
||||
url: "https://admin.pena.digital/price/discounts",
|
||||
});
|
||||
setDiscount(data);
|
||||
console.log(data);
|
||||
@ -86,7 +92,7 @@ export default function DiscountDataGrid() {
|
||||
axiosDiscount();
|
||||
}, []);
|
||||
|
||||
const discountsGridData: GridRowsProp = discounts.map((discount) => {
|
||||
const discountsGridData: GridRowsProp = exampleDiscounts.map((discount) => {
|
||||
const value =
|
||||
(discount.condition as any).purchasesAmount ??
|
||||
(discount.condition as any).cartPurchasesAmount ??
|
||||
|
Loading…
Reference in New Issue
Block a user