From 03534c200f1f10fe13a2c3a5ae7d08dc40f161a1 Mon Sep 17 00:00:00 2001 From: nflnkr Date: Tue, 20 Jun 2023 21:21:44 +0300 Subject: [PATCH] add deprecation marks --- src/kitUI/Cart/Cart.tsx | 1 + src/kitUI/Cart/calc.ts | 2 +- src/model/tariff.ts | 101 +++++++++++------- .../dashboard/Content/Tariffs/EditModal.tsx | 2 + .../dashboard/Content/Tariffs/tariffsDG.tsx | 2 + 5 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/kitUI/Cart/Cart.tsx b/src/kitUI/Cart/Cart.tsx index 07aa2bc..e7b56b1 100644 --- a/src/kitUI/Cart/Cart.tsx +++ b/src/kitUI/Cart/Cart.tsx @@ -24,6 +24,7 @@ import { calcCartData, createCartItem, findDiscountFactor, formatDiscountFactor import { useTariffStore } from "@root/stores/tariffs"; import { AnyDiscount, CartItemTotal } from "@root/model/cart"; import { findPrivilegeById } from "@root/stores/privileges"; +import { Privilege } from "@root/model/tariff"; interface Props { selectedTariffs: GridSelectionModel; diff --git a/src/kitUI/Cart/calc.ts b/src/kitUI/Cart/calc.ts index b14edcc..19852cf 100644 --- a/src/kitUI/Cart/calc.ts +++ b/src/kitUI/Cart/calc.ts @@ -10,9 +10,9 @@ import { ServiceDiscount, UserDiscount, } from "@root/model/cart"; -import { Tariff_BACKEND } from "@root/model/tariff"; import { User } from "../../model/user"; import { findPrivilegeById } from "@root/stores/privileges"; +import { SERVICE_LIST, ServiceType, Tariff } from "@root/model/tariff"; export function calcCartData({ user, diff --git a/src/model/tariff.ts b/src/model/tariff.ts index b77640d..ce082f9 100644 --- a/src/model/tariff.ts +++ b/src/model/tariff.ts @@ -1,16 +1,16 @@ export const SERVICE_LIST = [ - { - serviceKey: "templategen", - displayName: "Шаблонизатор документов", - }, - { - serviceKey: "squiz", - displayName: "Опросник", - }, - { - serviceKey: "dwarfener", - displayName: "Аналитика сокращателя", - }, + { + serviceKey: "templategen", + displayName: "Шаблонизатор документов", + }, + { + serviceKey: "squiz", + displayName: "Опросник", + }, + { + serviceKey: "dwarfener", + displayName: "Аналитика сокращателя", + }, ] as const; export type ServiceType = (typeof SERVICE_LIST)[number]["serviceKey"]; @@ -18,33 +18,56 @@ export type ServiceType = (typeof SERVICE_LIST)[number]["serviceKey"]; export type PrivilegeType = "unlim" | "gencount" | "activequiz" | "abcount" | "extended"; export interface Privilege_BACKEND { - name: string; - privilegeId: string; - serviceKey: string; - amount: number; - description: string; - price: number; - type: string; - value: string; - updatedAt: string; - _id: string; + name: string; + privilegeId: string; + serviceKey: string; + amount: number; + description: string; + price: number; + type: string; + value: string; + updatedAt: string; + _id: string; } export type Tariff_BACKEND = { - _id: string, - name: string, - price: number, - isCustom: boolean, - isFront: boolean, - privilegies: Privilege_BACKEND[], - isDeleted: boolean, - createdAt: string, - updatedAt: string -} + _id: string, + name: string, + price: number, + isCustom: boolean, + isFront: boolean, + privilegies: Privilege_BACKEND[], + isDeleted: boolean, + createdAt: string, + updatedAt: string; +}; export type Tariff_FRONTEND = { - id: string, - name: string, - amount:number, - isFront: boolean, - privilegeId: string, - customPricePerUnit: number -} \ No newline at end of file + id: string, + name: string, + amount: number, + privilegeId: string, + customPricePerUnit?: number; +}; + +/** @deprecated */ +export interface Privilege { + serviceKey: ServiceType; + name: PrivilegeType; + privilegeId: string; + description: string; + /** Единица измерения привелегии: время в днях/кол-во */ + type: "day" | "count"; + /** Стоимость одной единицы привелегии */ + price: number; +} + +/** @deprecated */ +export interface Tariff { + id: string; + name: string; + privilegeId: string; + /** Количество единиц привелегии */ + amount: number; + /** Кастомная цена, если есть, то используется вместо privilege.price */ + customPricePerUnit?: number; + isFront?: boolean; +} diff --git a/src/pages/dashboard/Content/Tariffs/EditModal.tsx b/src/pages/dashboard/Content/Tariffs/EditModal.tsx index 7b6575d..b59ce9c 100644 --- a/src/pages/dashboard/Content/Tariffs/EditModal.tsx +++ b/src/pages/dashboard/Content/Tariffs/EditModal.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck import React, { useEffect, useState } from "react"; import Box from "@mui/material/Box"; import Button from "@mui/material/Button"; @@ -48,6 +49,7 @@ interface Props { getTariffs: () => void } +/** @deprecated */ export default function EditModal({tariff, getTariffs}:Props) { const [open, setOpen] = useState(false); diff --git a/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx b/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx index 1e36fe7..d8772c1 100644 --- a/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx +++ b/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck import React from "react"; import { useEffect, useState } from "react"; import { GridColDef, GridSelectionModel, GridToolbar } from "@mui/x-data-grid"; @@ -24,6 +25,7 @@ interface Props { getTariffs: () => void; } +/** @deprecated */ export default function TariffsDG({ selectedTariffs, handleSelectionChange, getTariffs }: Props) { const { token } = authStore();