From 5a7697c5aae3d6d018f50a4ddf4e6f295b99d102 Mon Sep 17 00:00:00 2001 From: Tamara Date: Tue, 14 Nov 2023 19:29:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D1=84=D0=BE=D0=B2,=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D0=B0=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BD=D0=B0=20=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D0=B2=D0=BD=D1=83=D1=8E=20=D0=BD=D0=B0=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=83=20404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Error404/index.tsx | 10 ++- .../Content/Tariffs/CreateTariff.tsx | 69 ++++++++++++------- src/pages/dashboard/Menu/index.tsx | 1 - 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/pages/Error404/index.tsx b/src/pages/Error404/index.tsx index bb28b21..3709b15 100644 --- a/src/pages/Error404/index.tsx +++ b/src/pages/Error404/index.tsx @@ -1,8 +1,9 @@ import * as React from "react"; -import { Box, Typography } from "@mui/material"; +import {Box, Button, Typography} from "@mui/material"; import { ThemeProvider } from "@mui/material"; import theme from "../../theme"; import CssBaseline from '@mui/material/CssBaseline'; +import {Link} from "react-router-dom"; const Error404: React.FC = () => { @@ -46,6 +47,13 @@ const Error404: React.FC = () => { 4 + + + + + + diff --git a/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx b/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx index 467709c..2736884 100644 --- a/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx +++ b/src/pages/dashboard/Content/Tariffs/CreateTariff.tsx @@ -9,10 +9,9 @@ import { InputLabel, useTheme, Box, - OutlinedInput } from "@mui/material"; import { enqueueSnackbar } from "notistack"; - +import OutlinedInput from "@kitUI/outlinedInput"; import { CustomTextField } from "@root/kitUI/CustomTextField"; import { requestTariffs } from "@root/services/tariffs.service"; import { createTariff } from "@root/api/tariffs"; @@ -43,29 +42,28 @@ export default function CreateTariff() { const privilege = findPrivilegeById(privilegeIdField); - // const checkFulledFields = (values: Values) => { - // if (values.nameField.length === 0) { - // enqueueSnackbar("Пустое название тарифа"); - // return false; - // } - // if (values.amountField.length === 0) { - // enqueueSnackbar("Пустое кол-во едениц привилегии"); - // return false; - // } - // if (privilegeIdField.length === 0) { - // enqueueSnackbar("Не выбрана привилегия"); - // return false; - // } - // if (!privilege) { - // enqueueSnackbar("Привилегия с таким id не найдена"); - // return false; - // } - // return true; - // }; + const checkFulledFields = (values: Values) => { + const errors = {nameField: "", amountField: "", privilegeIdField: ""} as any; + // values.nameField = "aa" + // values.amountField = "aa" + + if (values.nameField.length === 0) { + errors.nameField = "Пустое название тарифа" + } + if (values.amountField.length === 0) { + errors.amountField = "Пустое кол-во едениц привилегии" + } + if (privilegeIdField.length === 0) { + errors.privilegeIdField = "Не выбрана привилегия" + } + console.log(values.amountField) + return errors; + + }; const initialValues: Values = { - nameField: "hello", - amountField: "54", + nameField: "", + amountField: "", customPriceField: "", privilegeIdField: "", }; @@ -119,10 +117,11 @@ export default function CreateTariff() { return ( {(props) => ( -
+ @@ -164,6 +164,7 @@ export default function CreateTariff() { id="privilege-select" value={privilegeIdField} label="Привилегия" + error={props.touched.privilegeIdField && !!props.errors.privilegeIdField} onChange={(e) => setPrivilegeIdField(e.target.value)} sx={{ color: theme.palette.secondary.main, @@ -214,15 +215,29 @@ export default function CreateTariff() { as={OutlinedInput} id="tariff-name" name="nameField" + variant="filled" label="Название тарифа" type="text" + error={props.touched.nameField && !!props.errors.nameField} + helperText={ + + {props.errors.nameField} + + } /> + {props.errors.amountField} + + } /> Создать +
)} diff --git a/src/pages/dashboard/Menu/index.tsx b/src/pages/dashboard/Menu/index.tsx index e9c55db..aec86e4 100644 --- a/src/pages/dashboard/Menu/index.tsx +++ b/src/pages/dashboard/Menu/index.tsx @@ -106,7 +106,6 @@ const links: { path: string; element: JSX.Element; title: string; className: str { path: "/discounts", element: , title: "Скидки", className: "menu" }, { path: "/promocode", element: , title: "Промокод", className: "menu" }, { path: "/settingRoles", element: , title: "Настройки", className: "menu" }, - { path: "/jjj", element: , title: "Камера", className: "menu" }, { path: "/support", element: , title: "Служба поддержки", className: "menu" }, ];