diff --git a/package.json b/package.json index ade6abd..52b3c11 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "@date-io/dayjs": "^2.15.0", "@emotion/react": "^11.10.4", "@emotion/styled": "^11.10.4", - "@frontend/kitui": "^1.0.54", + "@frontend/kitui": "^1.0.59", "@material-ui/pickers": "^3.3.10", "@mui/icons-material": "^5.10.3", "@mui/material": "^5.10.5", diff --git a/src/api/tariffs.ts b/src/api/tariffs.ts index 4a3b308..d0cc3fc 100644 --- a/src/api/tariffs.ts +++ b/src/api/tariffs.ts @@ -9,6 +9,7 @@ import type { EditTariffRequestBody } from "@root/model/tariff"; type CreateTariffBackendRequest = { name: string; description: string; + order: number; price: number; isCustom: boolean; privileges: Omit[]; @@ -53,6 +54,8 @@ export const putTariff = async (tariff: Tariff): Promise<[null, string?]> => { name: tariff.name, price: tariff.price ?? 0, isCustom: false, + order: tariff.order || 1, + description: tariff.description, privileges: tariff.privileges, }, }); diff --git a/src/model/tariff.ts b/src/model/tariff.ts index 0d6376d..d03fd32 100644 --- a/src/model/tariff.ts +++ b/src/model/tariff.ts @@ -20,7 +20,9 @@ export type ServiceType = (typeof SERVICE_LIST)[number]["serviceKey"]; export type PrivilegeType = "unlim" | "gencount" | "activequiz" | "abcount" | "extended"; export type EditTariffRequestBody = { + description: string; name: string; + order: number; price: number; isCustom: boolean; privileges: Omit[]; diff --git a/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx b/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx index d2985fb..1ba890b 100644 --- a/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx +++ b/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx @@ -27,6 +27,7 @@ interface Values { amountField: string, customPriceField: string, privilegeIdField: string, + orderField: number, privilege: PrivilegeWithAmount | null } @@ -58,6 +59,7 @@ export default function CreateTariff() { amountField: "", customPriceField: "", privilegeIdField: "", + orderField: 0, privilege: null }; @@ -69,6 +71,7 @@ export default function CreateTariff() { const [_, createdTariffError] = await createTariff({ name: values.nameField, price: Number(values.customPriceField) * 100, + order: values.orderField, isCustom: false, description: values.descriptionField, privileges: [ @@ -309,6 +312,29 @@ export default function CreateTariff() { } }} /> + { + props.setFieldValue("orderField", e.target.value) + }} + value={props.values.orderField} + onBlur={props.handleBlur} + label="порядковый номер" + InputProps={{ + style: { + backgroundColor: theme.palette.content.main, + color: theme.palette.secondary.main, + } + }} + type={'number'} + InputLabelProps={{ + style: { + color: theme.palette.secondary.main + } + }} + /> )} diff --git a/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx b/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx index b3aa535..a5018e4 100644 --- a/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx +++ b/src/pages/dashboard/Content/Tariffs/tariffsDG.tsx @@ -14,7 +14,7 @@ import { currencyFormatter } from "@root/utils/currencyFormatter"; const columns: GridColDef[] = [ - { field: "_id", headerName: "ID", width: 100, valueGetter: ({ row }) => row._id }, + { field: "_id", headerName: "ID", width: 100, valueGetter: ({ row }) => row.order || 1 }, { field: "edit", headerName: "Изменение", diff --git a/src/utils/calcCart/calcCart.test.ts b/src/utils/calcCart/calcCart.test.ts index 7022225..04ac79c 100644 --- a/src/utils/calcCart/calcCart.test.ts +++ b/src/utils/calcCart/calcCart.test.ts @@ -28,6 +28,7 @@ describe("Cart calculations", () => { serviceKey: "templategen", description: "d1", price: 100 * 100, + amount: 100, appliedPrivilegeDiscount: null, }, ], @@ -66,6 +67,7 @@ describe("Cart calculations", () => { serviceKey: "templategen", description: "d1", price: 100 * 100, + amount: 100, appliedPrivilegeDiscount: null, }, ], @@ -88,6 +90,7 @@ describe("Cart calculations", () => { price: 200 * 200, privilegeId: "p2", serviceKey: "squiz", + amount: 100, appliedPrivilegeDiscount: null, }, ], @@ -107,6 +110,7 @@ describe("Cart calculations", () => { privileges: [ { description: "d3", + amount: 100, price: 300 * 300, privilegeId: "p3", serviceKey: "reducer", @@ -145,6 +149,7 @@ describe("Cart calculations", () => { privileges: [ { privilegeId: "p1", + amount: 100, serviceKey: "templategen", description: "d1", price: 100 * 100, @@ -159,6 +164,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d5", price: 600 * 600, privilegeId: "p5", @@ -181,6 +187,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d3", price: 300 * 300, privilegeId: "p3", @@ -242,6 +249,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -280,6 +288,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d3", price: 300 * 300 * 0.95, privilegeId: "p3", @@ -319,6 +328,7 @@ describe("Cart calculations", () => { privileges: [ { privilegeId: "p1", + amount: 100, serviceKey: "templategen", description: "d1", price: 100 * 100 * 0.8, @@ -334,6 +344,7 @@ describe("Cart calculations", () => { privileges: [ { description: "d5", + amount: 100, price: 600 * 600 * 0.8, privilegeId: "p5", serviceKey: "templategen", @@ -371,6 +382,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -388,6 +400,7 @@ describe("Cart calculations", () => { { description: "d5", price: 600 * 600, + amount: 100, privilegeId: "p5", serviceKey: "templategen", appliedPrivilegeDiscount: null, @@ -424,6 +437,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -462,6 +476,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -500,6 +515,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -538,6 +554,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -578,6 +595,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -620,6 +638,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -662,6 +681,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -684,6 +704,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d3", price: 300 * 300 * 0.95, privilegeId: "p3", @@ -726,6 +747,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, privilegeId: "p1", serviceKey: "templategen", description: "d1", @@ -741,6 +763,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d5", price: 600 * 600 * 0.8, privilegeId: "p5", @@ -763,6 +786,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d2", price: 200 * 200, privilegeId: "p2", @@ -785,6 +809,7 @@ describe("Cart calculations", () => { isCustom: false, privileges: [ { + amount: 100, description: "d3", price: 300 * 300 * 0.95, privilegeId: "p3", @@ -810,6 +835,7 @@ const templategenTariff1: Tariff = { _id: "t1", name: "templategenTariff1", price: 0, + description: "test", isCustom: false, privileges: [ { @@ -830,6 +856,7 @@ const templategenTariff1: Tariff = { }; const templategenTariff2: Tariff = { + description: "test", _id: "t5", name: "templategenTariff2", price: 0, @@ -853,6 +880,7 @@ const templategenTariff2: Tariff = { }; const customTemplategenTariff: Tariff = { + description: "test", _id: "t1", name: "templategenTariff3", price: 0, @@ -876,6 +904,7 @@ const customTemplategenTariff: Tariff = { }; const squizTariff: Tariff = { + description: "test", _id: "t2", name: "squizTariff", price: 0, @@ -899,6 +928,7 @@ const squizTariff: Tariff = { }; const reducerTariff: Tariff = { + description: "test", _id: "t3", name: "reducerTariff", price: 0, diff --git a/src/utils/calcCart/calcCart.ts b/src/utils/calcCart/calcCart.ts index d03ccfb..8275e76 100644 --- a/src/utils/calcCart/calcCart.ts +++ b/src/utils/calcCart/calcCart.ts @@ -51,6 +51,7 @@ export function calcCart( const privilegeCartData: PrivilegeCartData = { serviceKey: privilege.serviceKey, + amount: privilege.amount, privilegeId: privilege.privilegeId, description: privilege.description, price: privilegePrice, diff --git a/yarn.lock b/yarn.lock index fc9cd09..b0afa7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1433,10 +1433,10 @@ lodash.isundefined "^3.0.1" lodash.uniq "^4.5.0" -"@frontend/kitui@^1.0.54": - version "1.0.54" - resolved "https://penahub.gitlab.yandexcloud.net/api/v4/projects/21/packages/npm/@frontend/kitui/-/@frontend/kitui-1.0.54.tgz#0235d5a8effb9b92351471c3c7775f28cb2839f6" - integrity sha1-AjXVqO/7m5I1FHHDx3dfKMsoOfY= +"@frontend/kitui@^1.0.59": + version "1.0.59" + resolved "https://penahub.gitlab.yandexcloud.net/api/v4/projects/21/packages/npm/@frontend/kitui/-/@frontend/kitui-1.0.59.tgz#c4584506bb5cab4fc1df35f5b1d0d66ec379a9a1" + integrity sha1-xFhFBrtcq0/B3zX1sdDWbsN5qaE= dependencies: immer "^10.0.2" reconnecting-eventsource "^1.6.2"