formatting

This commit is contained in:
AmirHossein Mahmoodi
2025-02-25 15:06:10 +03:30
parent f6e8d4e582
commit 917551cef6
14 changed files with 82 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
import SelectBox from "@/core/components/SelectBox"
import SelectBox from "@/core/components/SelectBox";
import useEdaratLists from "@/lib/hooks/useEdaratLists";
import { useEffect, useState } from "react";
@@ -8,13 +8,21 @@ const CityContent = ({ provinceID, field, fieldState: { error } }) => {
useEffect(() => {
if (prevDependency === provinceID) return;
field.onChange(null)
field.onChange(null);
setPrevDependency(provinceID);
}, [provinceID])
}, [provinceID]);
return (
<SelectBox
value={!provinceID ? 'dependency' : errorEdaratList ? "error" : loadingEdaratList ? 'loading' : field.value || ""}
value={
!provinceID
? "dependency"
: errorEdaratList
? "error"
: loadingEdaratList
? "loading"
: field.value || ""
}
label={"شهرستان"}
selectors={edaratList}
schema={{ name: "name_fa", value: "id" }}
@@ -26,6 +34,6 @@ const CityContent = ({ provinceID, field, fieldState: { error } }) => {
isDependency={!provinceID}
dependencyLabel={"ابتدا استان را انتخاب کنید"}
/>
)
}
export default CityContent
);
};
export default CityContent;

View File

@@ -101,7 +101,7 @@ const DamageInfo = ({ control, setValue, errors }) => {
render={({ field, fieldState: { error } }) => {
return (
<SelectBox
value={errorProvinces ? "error" : loadingProvinces ? 'loading' : field.value || ""}
value={errorProvinces ? "error" : loadingProvinces ? "loading" : field.value || ""}
label="استان"
selectors={provinces}
schema={{ name: "name_fa", value: "id" }}

View File

@@ -46,7 +46,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => {
mutate();
setOpen(false);
})
.catch(() => { });
.catch(() => {});
};
const defaultData = {
accident_date: "",

View File

@@ -4,7 +4,18 @@ 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 {
Alert,
Box,
Button,
Chip,
DialogActions,
DialogContent,
Divider,
Grid,
Stack,
Typography,
} from "@mui/material";
import { useReducer, useState } from "react";
const initialState = {

View File

@@ -8,7 +8,7 @@ const CreateFactor = ({ row, rowId, mutate }) => {
return (
<>
<Tooltip title={row.original?.status == 2 ? "صدور فاکتور" : 'استعلام پرداخت'}>
<Tooltip title={row.original?.status == 2 ? "صدور فاکتور" : "استعلام پرداخت"}>
<IconButton color="primary" onClick={() => setOpenCreateFactorDialog(true)}>
<ReceiptLongIcon />
</IconButton>
@@ -25,7 +25,9 @@ const CreateFactor = ({ row, rowId, mutate }) => {
maxWidth={"sm"}
scroll="paper"
>
<DialogTitle sx={{ fontSize: "large" }}>{row.original?.status == 2 ? "صدور فاکتور" : 'استعلام پرداخت'}</DialogTitle>
<DialogTitle sx={{ fontSize: "large" }}>
{row.original?.status == 2 ? "صدور فاکتور" : "استعلام پرداخت"}
</DialogTitle>
{openCreateFactorDialog && (
<CreateFactorContent
setOpenCreateFactorDialog={setOpenCreateFactorDialog}

View File

@@ -128,7 +128,7 @@ const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate,
mutate();
setOpenRegisterInsuranceDialog(false);
})
.catch(() => { });
.catch(() => {});
};
return (
<StyledForm onSubmit={handleSubmit(onSubmitBase)}>

View File

@@ -127,8 +127,8 @@ const OperatorList = () => {
props.dependencyFieldValue?.value === ""
? "empty"
: loadingEdaratList
? "loading"
: props.filterParameters.value
? "loading"
: props.filterParameters.value
}
columnSelectOption={getColumnSelectOptions}
/>

View File

@@ -25,7 +25,11 @@ const PoliceRahLetter = ({ rowId, mutate }) => {
>
<DialogTitle sx={{ fontSize: "large" }}>صدور نامه پلیس راه</DialogTitle>
{openPoliceRahDialog && (
<PoliceRahLetterContent mutate={mutate} rowId={rowId} setOpenPoliceRahDialog={setOpenPoliceRahDialog} />
<PoliceRahLetterContent
mutate={mutate}
rowId={rowId}
setOpenPoliceRahDialog={setOpenPoliceRahDialog}
/>
)}
</Dialog>
</>

View File

@@ -9,8 +9,10 @@ import { usePermissions } from "@/lib/hooks/usePermissions";
const RowActions = ({ row, mutate }) => {
const { data: userPermissions } = usePermissions();
const hasDeletePermission = userPermissions.some(item => ['delete-receipt', 'delete-receipt-province'].includes(item))
const hasEditPermission = userPermissions.some(item => ['edit-receipt', 'edit-receipt-province'].includes(item))
const hasDeletePermission = userPermissions.some((item) =>
["delete-receipt", "delete-receipt-province"].includes(item)
);
const hasEditPermission = userPermissions.some((item) => ["edit-receipt", "edit-receipt-province"].includes(item));
return (
<Box sx={{ display: "flex", gap: 1 }}>
{[4, 5].includes(row.original?.status) && <PoliceRahLetter mutate={mutate} rowId={row.getValue("id")} />}
@@ -24,9 +26,7 @@ const RowActions = ({ row, mutate }) => {
{hasEditPermission && [0, 1, 2].includes(row.original?.status) && (
<EditForm row={row} mutate={mutate} rowId={row.getValue("id")} />
)}
{hasDeletePermission && (
<DeleteDialog mutate={mutate} rowId={row.getValue("id")} />
)}
{hasDeletePermission && <DeleteDialog mutate={mutate} rowId={row.getValue("id")} />}
</Box>
);
};

View File

@@ -5,13 +5,11 @@ import { usePermissions } from "@/lib/hooks/usePermissions";
const Toolbar = ({ table, filterData, mutate }) => {
const { data: userPermissions } = usePermissions();
const hasAddPermission = userPermissions.some(item => ['add-receipt', 'add-receipt-province'].includes(item))
const hasAddPermission = userPermissions.some((item) => ["add-receipt", "add-receipt-province"].includes(item));
return (
<Box sx={{ display: "flex", gap: 1 }}>
<PrintExcel table={table} filterData={filterData} />
{hasAddPermission && (
<OperatorCreate mutate={mutate} />
)}
{hasAddPermission && <OperatorCreate mutate={mutate} />}
</Box>
);
};

View File

@@ -1,5 +1,10 @@
import DialogLoading from "@/core/components/DialogLoading";
import { GET_CMMS_MACHINE_ROAD_ITEM, GET_IMAGES_ROAD_ITEM, GET_RAHDARAN_ROAD_ITEM, UPDATE_ROAD_ITEMS } from "@/core/utils/routes";
import {
GET_CMMS_MACHINE_ROAD_ITEM,
GET_IMAGES_ROAD_ITEM,
GET_RAHDARAN_ROAD_ITEM,
UPDATE_ROAD_ITEMS,
} from "@/core/utils/routes";
import useRequest from "@/lib/hooks/useRequest";
import { Typography } from "@mui/material";
import { useEffect, useState } from "react";
@@ -76,7 +81,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog, openEditDialog, row
mutate();
setOpenEditDialog(false);
})
.catch((error) => { });
.catch((error) => {});
};
return loadingImages || loadingCmmsMachine || loadingRahdaran ? (

View File

@@ -8,16 +8,11 @@ const PersianTextField = (props) => {
const handleChange = (value) => {
fieldOnChange(value);
}
};
usePersianInput(inputRef, handleChange);
return (
<TextField
ref={inputRef}
{...rest}
/>
);
return <TextField ref={inputRef} {...rest} />;
};
export default PersianTextField
export default PersianTextField;

View File

@@ -5,7 +5,7 @@ function SelectBox({
value,
onChange,
isDependency = false,
dependencyLabel = '',
dependencyLabel = "",
onBlur,
selectors,
label,
@@ -31,11 +31,17 @@ function SelectBox({
onBlur={onBlur}
>
{isDependency ? (
<MenuItem value={'dependency'} sx={{ color: "primary.main" }}>{dependencyLabel}</MenuItem>
<MenuItem value={"dependency"} sx={{ color: "primary.main" }}>
{dependencyLabel}
</MenuItem>
) : isLoading ? (
<MenuItem value={'loading'} sx={{ color: "primary.main" }}>درحال دریافت اطلاعات...</MenuItem>
<MenuItem value={"loading"} sx={{ color: "primary.main" }}>
درحال دریافت اطلاعات...
</MenuItem>
) : errorEcured ? (
<MenuItem value={'error'} sx={{ color: "secondary.main" }}>خطا در دریافت اطلاعات!!!</MenuItem>
<MenuItem value={"error"} sx={{ color: "secondary.main" }}>
خطا در دریافت اطلاعات!!!
</MenuItem>
) : (
selectors.map((selector) => {
return (

View File

@@ -1,11 +1,21 @@
function validateNationalCode(code) {
const invalidCodes = ["1111111111", "2222222222", "3333333333", "4444444444", "5555555555", "6666666666", "7777777777", "8888888888", "9999999999"];
const invalidCodes = [
"1111111111",
"2222222222",
"3333333333",
"4444444444",
"5555555555",
"6666666666",
"7777777777",
"8888888888",
"9999999999",
];
if (invalidCodes.includes(code)) return false;
const L = code.length;
if (L < 8 || parseInt(code, 10) === 0) return false;
code = code.padStart(10, '0');
code = code.padStart(10, "0");
if (parseInt(code.substr(3, 6), 10) === 0) return false;
const c = parseInt(code.charAt(9), 10);
@@ -14,7 +24,7 @@ function validateNationalCode(code) {
s += parseInt(code.charAt(i), 10) * (10 - i);
}
s = s % 11;
return (s < 2 && c === s) || (s >= 2 && c === (11 - s));
return (s < 2 && c === s) || (s >= 2 && c === 11 - s);
}
export default validateNationalCode;
export default validateNationalCode;