diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CityContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CityContent.jsx new file mode 100644 index 0000000..263b859 --- /dev/null +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CityContent.jsx @@ -0,0 +1,31 @@ +import SelectBox from "@/core/components/SelectBox" +import useEdaratLists from "@/lib/hooks/useEdaratLists"; +import { useEffect, useState } from "react"; + +const CityContent = ({ provinceID, field, fieldState: { error } }) => { + const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(provinceID); + const [prevDependency, setPrevDependency] = useState(provinceID); + + useEffect(() => { + if (prevDependency === provinceID) return; + field.onChange(null) + setPrevDependency(provinceID); + }, [provinceID]) + + return ( + + ) +} +export default CityContent \ No newline at end of file diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CityController.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CityController.jsx index 65dc92c..f5b46d4 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/CityController.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CityController.jsx @@ -1,27 +1,15 @@ import SelectBox from "@/core/components/SelectBox"; -import { Controller, useWatch } from "react-hook-form"; import useEdaratLists from "@/lib/hooks/useEdaratLists"; +import { Controller, useWatch } from "react-hook-form"; +import CityContent from "./CityContent"; const CityController = ({ control }) => { const provinceID = useWatch({ control, name: "province_id" }); - const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(provinceID); return ( ( - - )} + render={(props) => } /> ); }; diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx index bf369b0..27422e4 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx @@ -14,6 +14,7 @@ import DamageInfo from "./DamageInfo"; import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; import DamageReport from "./DamageReport"; import DamageItem from "./DamageItem"; +import validateNationalCode from "@/core/utils/nationalCodeValidation"; function TabPanel(props) { const { children, value, index } = props; @@ -32,14 +33,12 @@ const validationSchema = object({ city_id: number().required("لطفا شهرستان را وارد کنید!!!"), axis_name: string().required("لطفا نام محور را وارد کنید!!!"), driver_name: string().required("لطفا نام و نام خانوادگی را وارد کنید!!!"), - phone_number: mixed() - .test("max", "تلفن همراه باید شامل 11 رقم باشد", (value) => { - const stringValue = String(value); - return stringValue.length === 11; - }) + phone_number: string() + .matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شده و 11 رقم باشد") .required("لطفا تلفن همراه را وارد کنید!!!"), national_code: mixed() .test("max", "کد ملی باید شامل 10 رقم باشد", (value) => value.toString().length === 10) + .test("validation", "کد ملی صحیح نمی باشد", (value) => validateNationalCode(value)) .required("لطفا کد ملی را وارد کنید!!!"), start_point: mixed() .test("start-point-required", "لطفاً نقطه تصادف را مشخص کنید!", function (value) { diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx index 5612293..111134b 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageInfo.jsx @@ -8,6 +8,7 @@ import PlateNumber from "@/core/components/PlateNumber"; import ImageUpload from "./ImageUpload"; import MapInfoOneMarker from "@/core/components/MapInfoOneMarker"; import CityController from "@/components/dashboard/damages/operator/Actions/create/Forms/CityController"; +import PersianTextField from "@/core/components/PersianTextField"; const DamageInfo = ({ control, setValue, errors }) => { const StartPoint = useWatch({ control, name: "start_point" }); @@ -100,8 +101,8 @@ const DamageInfo = ({ control, setValue, errors }) => { render={({ field, fieldState: { error } }) => { return ( { name="axis_name" control={control} render={({ field, fieldState: { error } }) => ( - )} /> @@ -144,17 +146,18 @@ const DamageInfo = ({ control, setValue, errors }) => { name="driver_name" control={control} render={({ field, fieldState: { error } }) => ( - )} /> diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx index 4a25e69..9bc269d 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx @@ -45,7 +45,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { mutate(); setOpen(false); }) - .catch(() => {}); + .catch(() => { }); }; const defaultData = { accident_date: "", @@ -74,12 +74,14 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { }; return ( - + {open && ( + + )} ); }; diff --git a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx index e33e5f8..73e1a04 100644 --- a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx +++ b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx @@ -1,11 +1,11 @@ -import { Box, Button, Chip, DialogActions, DialogContent, Divider, Grid, Typography } from "@mui/material"; -import PaymentIcon from "@mui/icons-material/Payment"; -import WebAssetIcon from "@mui/icons-material/WebAsset"; -import RequestQuoteIcon from "@mui/icons-material/RequestQuote"; -import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; -import { useReducer, useState } from "react"; import { CHECK_PAYMENT_STATUS, CREATE_FACTOR_DAMAGE, SEND_SMS_AGAIN } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; +import PaymentIcon from "@mui/icons-material/Payment"; +import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; +import RequestQuoteIcon from "@mui/icons-material/RequestQuote"; +import WebAssetIcon from "@mui/icons-material/WebAsset"; +import { Alert, Box, Button, Chip, DialogActions, DialogContent, Divider, Grid, Stack, Typography } from "@mui/material"; +import { useReducer, useState } from "react"; const initialState = { submittingCreateFactor: false, @@ -66,7 +66,7 @@ const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog }) return ( <> - + @@ -134,18 +134,14 @@ const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog }) {!factorCreated && ( - - * - - پس از ایجاد فاکتور امکان تغییر در اطلاعات کاربر و مبالغ وجود نخواهد داشت. - - - - * - - لینک پرداخت فاکتور به شماره {row.original?.driver_phone_number} ارسال خواهد شد. - - + + + بعد از صدور فاکتور، ویرایش اطلاعات کاربر و مبالغ امکان‌پذیر نخواهد بود. + + + لینک پرداخت فاکتور به شماره {row.original?.driver_phone_number} ارسال می شود. + + )} @@ -197,7 +193,7 @@ const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog }) color="primary" disabled={state.submittingCreateFactor} > - {state.submittingCreateFactor ? "درحال ایجاد فاکتور..." : "ایجاد فاکتور"} + {state.submittingCreateFactor ? "درحال صدور فاکتور..." : "صدور فاکتور"} )} diff --git a/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx b/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx index e245e0c..c862aa4 100644 --- a/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx +++ b/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx @@ -8,7 +8,7 @@ const CreateFactor = ({ row, rowId, mutate }) => { return ( <> - + setOpenCreateFactorDialog(true)}> @@ -25,13 +25,15 @@ const CreateFactor = ({ row, rowId, mutate }) => { maxWidth={"sm"} scroll="paper" > - مدیریت پرداخت - + {row.original?.status == 2 ? "صدور فاکتور" : 'استعلام پرداخت'} + {openCreateFactorDialog && ( + + )} ); diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx index c21dda6..91c4430 100644 --- a/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx @@ -30,7 +30,7 @@ const DaghiPayment = ({ control }) => { render={({ field }) => } /> } - label="صورتجلسه تحویل داغی به انبار (بیمه) ندارد" + label="صورتجلسه تحویل داغی به انبار ندارد" /> { render={({ field }) => } /> } - label="صورتجلسه تحویل داغی به انبار (بیمه) دارد" + label="صورتجلسه تحویل داغی به انبار دارد" /> diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx index 090609b..d08c9f8 100644 --- a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx @@ -128,7 +128,7 @@ const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, mutate(); setOpenRegisterInsuranceDialog(false); }) - .catch(() => {}); + .catch(() => { }); }; return ( @@ -192,7 +192,7 @@ const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, disabled={isSubmitting} endIcon={} > - {isSubmitting ? "در حال ثبت فیش" : "ثبت فیش"} + {isSubmitting ? "در حال ثبت" : "ثبت"} )} diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx index 8a02fdf..6858a8a 100644 --- a/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx @@ -24,12 +24,14 @@ const RegisterInsurance = ({ row, mutate, rowId }) => { maxWidth={"sm"} scroll="paper" > - + {openRegisterInsuranceDialog && ( + + )} ); diff --git a/src/components/dashboard/damages/operator/OperatorList.jsx b/src/components/dashboard/damages/operator/OperatorList.jsx index 4bc0359..52e3d01 100644 --- a/src/components/dashboard/damages/operator/OperatorList.jsx +++ b/src/components/dashboard/damages/operator/OperatorList.jsx @@ -127,8 +127,8 @@ const OperatorList = () => { props.dependencyFieldValue?.value === "" ? "empty" : loadingEdaratList - ? "loading" - : props.filterParameters.value + ? "loading" + : props.filterParameters.value } columnSelectOption={getColumnSelectOptions} /> @@ -361,7 +361,7 @@ const OperatorList = () => { }, { accessorKey: "status", - header: "اخرین وضعیت", + header: "وضعیت", id: "status", enableColumnFilter: true, datatype: "numeric", diff --git a/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx b/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx index b7f6d4b..145e323 100644 --- a/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx +++ b/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx @@ -24,7 +24,9 @@ const DeleteDialog = ({ rowId, mutate }) => { maxWidth={"md"} > حذف فعالیت - + {openDeleteDialog && ( + + )} ); diff --git a/src/components/dashboard/damages/operator/RowActions/ImageDialog/index.jsx b/src/components/dashboard/damages/operator/RowActions/ImageDialog/index.jsx index 6e442ca..74ade1d 100644 --- a/src/components/dashboard/damages/operator/RowActions/ImageDialog/index.jsx +++ b/src/components/dashboard/damages/operator/RowActions/ImageDialog/index.jsx @@ -26,12 +26,12 @@ const ImageDialog = ({ images }) => { scroll="paper" > تصاویر - - + {openImageDialog && ( + - - + + )}