formatting

This commit is contained in:
Amirhossein Mahmoodi
2024-08-18 11:11:58 +03:30
parent f7c93d0404
commit f2e199ee8a
40 changed files with 733 additions and 450 deletions

View File

@@ -4,7 +4,7 @@ import { Stack } from "@mui/material";
const Layout = ({ children }) => { const Layout = ({ children }) => {
return ( return (
<Stack sx={{ width: '100%', height: '100%' }}> <Stack sx={{ width: "100%", height: "100%" }}>
<HeaderWithLogo /> <HeaderWithLogo />
<HeaderWithSidebar>{children}</HeaderWithSidebar> <HeaderWithSidebar>{children}</HeaderWithSidebar>
</Stack> </Stack>

View File

@@ -1,9 +1,7 @@
import WithAuthMiddleware from "@/core/middlewares/withAuth"; import WithAuthMiddleware from "@/core/middlewares/withAuth";
const Layout = ({ children }) => { const Layout = ({ children }) => {
return ( return <WithAuthMiddleware>{children}</WithAuthMiddleware>;
<WithAuthMiddleware>{children}</WithAuthMiddleware>
);
}; };
export default Layout; export default Layout;

View File

@@ -8,7 +8,7 @@ export const metadata = {
export default function RootLayout({ children }) { export default function RootLayout({ children }) {
return ( return (
<html lang="fa" dir={"rtl"}> <html lang="fa" dir={"rtl"}>
<body style={{ height: "100vh", width: '100vw' }}> <body style={{ height: "100vh", width: "100vw" }}>
<AuthProvider> <AuthProvider>
<TableSettingProvider>{children}</TableSettingProvider> <TableSettingProvider>{children}</TableSettingProvider>
</AuthProvider> </AuthProvider>

View File

@@ -8,7 +8,7 @@ import Link from "next/link";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
const Page = ({ searchParams }) => { const Page = ({ searchParams }) => {
const { getUser } = useAuth() const { getUser } = useAuth();
const { username } = searchParams; const { username } = searchParams;
const [login, setLogin] = useState(0); const [login, setLogin] = useState(0);
const request = useRequest(); const request = useRequest();
@@ -17,7 +17,7 @@ const Page = ({ searchParams }) => {
const login = async () => { const login = async () => {
try { try {
await request(`${GET_LOGIN_ROUTE}?username=${username}`); await request(`${GET_LOGIN_ROUTE}?username=${username}`);
await getUser() await getUser();
setLogin(1); setLogin(1);
} catch (error) { } catch (error) {
setLogin(2); setLogin(2);
@@ -31,7 +31,7 @@ const Page = ({ searchParams }) => {
setLogin(0); setLogin(0);
try { try {
await request(`${GET_LOGIN_ROUTE}?username=${username}`); await request(`${GET_LOGIN_ROUTE}?username=${username}`);
await getUser() await getUser();
setLogin(1); setLogin(1);
} catch (error) { } catch (error) {
setLogin(2); setLogin(2);
@@ -44,8 +44,8 @@ const Page = ({ searchParams }) => {
{login === 0 {login === 0
? "درحال دریافت مجوز برای ارتباط با سرور..." ? "درحال دریافت مجوز برای ارتباط با سرور..."
: login === 1 : login === 1
? "ارتباط با سرور برقرار شد." ? "ارتباط با سرور برقرار شد."
: "ارتباط با سرور برقرار نشد. مشکلی وجود دارد."} : "ارتباط با سرور برقرار نشد. مشکلی وجود دارد."}
</Typography> </Typography>
<Zoom in={login === 1}> <Zoom in={login === 1}>
<Button component={Link} href="/"> <Button component={Link} href="/">

View File

@@ -27,12 +27,7 @@ const InquiryPrivacyFencingCreate = ({ mutate }) => {
<AddCircle sx={{ fontSize: "25px" }} /> <AddCircle sx={{ fontSize: "25px" }} />
</IconButton> </IconButton>
) : ( ) : (
<Button <Button variant="contained" color="primary" startIcon={<AddCircle />} onClick={handleOpen}>
variant="contained"
color="primary"
startIcon={<AddCircle />}
onClick={handleOpen}
>
ایجاد پاسخ به استعلام ایجاد پاسخ به استعلام
</Button> </Button>
)} )}

View File

@@ -1,7 +1,21 @@
import LtrTextField from "@/core/components/LtrTextField"; import LtrTextField from "@/core/components/LtrTextField";
import StyledForm from "@/core/components/StyledForm"; import StyledForm from "@/core/components/StyledForm";
import useRequest from "@/lib/hooks/useRequest"; import useRequest from "@/lib/hooks/useRequest";
import { Autocomplete, Box, Button, Chip, Container, DialogActions, DialogContent, Fade, Grid, InputAdornment, Stack, TextField, Typography } from "@mui/material"; import {
Autocomplete,
Box,
Button,
Chip,
Container,
DialogActions,
DialogContent,
Fade,
Grid,
InputAdornment,
Stack,
TextField,
Typography,
} from "@mui/material";
import { DatePicker, LocalizationProvider, faIR } from "@mui/x-date-pickers"; import { DatePicker, LocalizationProvider, faIR } from "@mui/x-date-pickers";
import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali";
import moment from "jalali-moment"; import moment from "jalali-moment";
@@ -9,130 +23,135 @@ import { Controller, useForm } from "react-hook-form";
import LocationOnMap from "./LocationOnMap"; import LocationOnMap from "./LocationOnMap";
const initValues = { const initValues = {
dabirkhaneh_number: '', dabirkhaneh_number: "",
nameh_date: moment(), nameh_date: moment(),
nameh_date_fa: '', nameh_date_fa: "",
marjae_pasokh: '', marjae_pasokh: "",
motaghazi_is_legal_id: null, motaghazi_is_legal_id: null,
motaghazi_is_legal: '', motaghazi_is_legal: "",
motaghazi_type_id: '', motaghazi_type_id: "",
motaghazi_type: null, motaghazi_type: null,
motaghazi_firstname: '', motaghazi_firstname: "",
motaghazi_lastname: '', motaghazi_lastname: "",
national_id: '', national_id: "",
shenase_melli: '', shenase_melli: "",
tel_number: '', tel_number: "",
mobile_number: '', mobile_number: "",
address: '', address: "",
edare_kol_id: null, edare_kol_id: null,
edare_kol: '', edare_kol: "",
edare_shahri_id: null, edare_shahri_id: null,
edare_shahri: '', edare_shahri: "",
rah_type_id: null, rah_type_id: null,
rah_type: '', rah_type: "",
name_mehvar_id: '', name_mehvar_id: "",
name_mehvar_fa: null, name_mehvar_fa: null,
mizan_harim: null, mizan_harim: null,
arze_navar: null, arze_navar: null,
samt_id: null, samt_id: null,
samt: '', samt: "",
kilometr: '', kilometr: "",
lat: '', lat: "",
lon: '', lon: "",
zone: null, zone: null,
karbari_type_id: null, karbari_type_id: null,
karbari_type: '', karbari_type: "",
tarh_title: '', tarh_title: "",
masahat_zirbana: '', masahat_zirbana: "",
ehdasat_type_id: [], ehdasat_type_id: [],
ehdasat_type: '', ehdasat_type: "",
divarkeshi_distance: '', divarkeshi_distance: "",
mostahadesat_distance: '', mostahadesat_distance: "",
mahale_ejra_id: null, mahale_ejra_id: null,
mahale_ejra: '', mahale_ejra: "",
traffic_id: null, traffic_id: null,
traffic: '', traffic: "",
vaziat_eghtesadi_id: null, vaziat_eghtesadi_id: null,
vaziat_eghtesadi: '', vaziat_eghtesadi: "",
has_access_id: null, has_access_id: null,
has_access: '', has_access: "",
shomare_estelam_harim: '', shomare_estelam_harim: "",
max_month: '', max_month: "",
max_day: '', max_day: "",
shomare_tahaodname: '', shomare_tahaodname: "",
shomare_daftarkhaneh: '', shomare_daftarkhaneh: "",
description: '', description: "",
ronevesht: '', ronevesht: "",
} };
const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => { const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
const request = useRequest() const request = useRequest();
const { control, watch, register, handleSubmit, setValue, formState: { isSubmitting } } = useForm({ defaultValues: defaultValues || initValues }); const {
control,
watch,
register,
handleSubmit,
setValue,
formState: { isSubmitting },
} = useForm({ defaultValues: defaultValues || initValues });
const onSubmit = async (data) => { const onSubmit = async (data) => {
const formData = new FormData() const formData = new FormData();
formData.append('dabirkhaneh_number', data.dabirkhaneh_number) formData.append("dabirkhaneh_number", data.dabirkhaneh_number);
formData.append('nameh_date', data.nameh_date.format('YYYY-MM-DD')) formData.append("nameh_date", data.nameh_date.format("YYYY-MM-DD"));
formData.append('nameh_date_fa', data.nameh_date) formData.append("nameh_date_fa", data.nameh_date);
formData.append('marjae_pasokh', data.marjae_pasokh) formData.append("marjae_pasokh", data.marjae_pasokh);
formData.append('motaghazi_is_legal_id', data.motaghazi_is_legal_id) formData.append("motaghazi_is_legal_id", data.motaghazi_is_legal_id);
formData.append('motaghazi_is_legal', data.motaghazi_is_legal_id) formData.append("motaghazi_is_legal", data.motaghazi_is_legal_id);
formData.append('motaghazi_type_id', 1) formData.append("motaghazi_type_id", 1);
formData.append('motaghazi_type', data.motaghazi_type) formData.append("motaghazi_type", data.motaghazi_type);
formData.append('motaghazi_firstname', data.motaghazi_firstname) formData.append("motaghazi_firstname", data.motaghazi_firstname);
formData.append('motaghazi_lastname', data.motaghazi_lastname) formData.append("motaghazi_lastname", data.motaghazi_lastname);
formData.append('national_id', data.national_id) formData.append("national_id", data.national_id);
formData.append('shenase_melli', data.national_id) formData.append("shenase_melli", data.national_id);
formData.append('tel_number', data.tel_number) formData.append("tel_number", data.tel_number);
formData.append('mobile_number', data.mobile_number) formData.append("mobile_number", data.mobile_number);
formData.append('address', data.address) formData.append("address", data.address);
formData.append('edare_kol_id', data.edare_kol_id) formData.append("edare_kol_id", data.edare_kol_id);
formData.append('edare_kol', data.edare_kol_id) formData.append("edare_kol", data.edare_kol_id);
formData.append('edare_shahri_id', data.edare_shahri_id) formData.append("edare_shahri_id", data.edare_shahri_id);
formData.append('edare_shahri', data.edare_shahri_id) formData.append("edare_shahri", data.edare_shahri_id);
formData.append('rah_type_id', data.rah_type_id) formData.append("rah_type_id", data.rah_type_id);
formData.append('rah_type', data.rah_type_id) formData.append("rah_type", data.rah_type_id);
formData.append('name_mehvar_id', 1) formData.append("name_mehvar_id", 1);
formData.append('name_mehvar_fa', data.name_mehvar_fa) formData.append("name_mehvar_fa", data.name_mehvar_fa);
formData.append('mizan_harim', data.mizan_harim) formData.append("mizan_harim", data.mizan_harim);
formData.append('arze_navar', data.arze_navar) formData.append("arze_navar", data.arze_navar);
formData.append('samt_id', data.samt_id) formData.append("samt_id", data.samt_id);
formData.append('samt', data.samt_id) formData.append("samt", data.samt_id);
formData.append('kilometr', data.kilometr) formData.append("kilometr", data.kilometr);
formData.append('lat', data.lat) formData.append("lat", data.lat);
formData.append('lon', data.lon) formData.append("lon", data.lon);
formData.append('zone', data.zone) formData.append("zone", data.zone);
formData.append('karbari_type_id', data.karbari_type_id) formData.append("karbari_type_id", data.karbari_type_id);
formData.append('karbari_type', data.karbari_type_id) formData.append("karbari_type", data.karbari_type_id);
formData.append('tarh_title', data.tarh_title) formData.append("tarh_title", data.tarh_title);
formData.append('masahat_zirbana', data.masahat_zirbana) formData.append("masahat_zirbana", data.masahat_zirbana);
formData.append('ehdasat_type_id', data.ehdasat_type_id.join("|")) formData.append("ehdasat_type_id", data.ehdasat_type_id.join("|"));
formData.append('ehdasat_type', data.ehdasat_type_id.join("|")) formData.append("ehdasat_type", data.ehdasat_type_id.join("|"));
formData.append('divarkeshi_distance', data.divarkeshi_distance) formData.append("divarkeshi_distance", data.divarkeshi_distance);
formData.append('mostahadesat_distance', data.mostahadesat_distance) formData.append("mostahadesat_distance", data.mostahadesat_distance);
formData.append('mahale_ejra_id', data.mahale_ejra_id) formData.append("mahale_ejra_id", data.mahale_ejra_id);
formData.append('mahale_ejra', data.mahale_ejra) formData.append("mahale_ejra", data.mahale_ejra);
formData.append('traffic_id', data.traffic_id) formData.append("traffic_id", data.traffic_id);
formData.append('traffic', data.traffic_id) formData.append("traffic", data.traffic_id);
formData.append('vaziat_eghtesadi_id', data.vaziat_eghtesadi_id) formData.append("vaziat_eghtesadi_id", data.vaziat_eghtesadi_id);
formData.append('vaziat_eghtesadi', data.vaziat_eghtesadi) formData.append("vaziat_eghtesadi", data.vaziat_eghtesadi);
formData.append('has_access_id', data.has_access_id) formData.append("has_access_id", data.has_access_id);
formData.append('has_access', data.has_access_id) formData.append("has_access", data.has_access_id);
formData.append('shomare_estelam_harim', data.shomare_estelam_harim) formData.append("shomare_estelam_harim", data.shomare_estelam_harim);
formData.append('max_month', data.max_month) formData.append("max_month", data.max_month);
formData.append('max_day', data.max_day) formData.append("max_day", data.max_day);
formData.append('shomare_tahaodname', data.shomare_tahaodname) formData.append("shomare_tahaodname", data.shomare_tahaodname);
formData.append('shomare_daftarkhaneh', data.shomare_daftarkhaneh) formData.append("shomare_daftarkhaneh", data.shomare_daftarkhaneh);
formData.append('description', data.description) formData.append("description", data.description);
formData.append('ronevesht', data.ronevesht) formData.append("ronevesht", data.ronevesht);
try { try {
await request(url, 'post', { data: formData }) await request(url, "post", { data: formData });
handleClose() handleClose();
mutate() mutate();
} catch (error) { } catch (error) {}
}
}; };
return ( return (
@@ -141,11 +160,18 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
localeText={faIR.components.MuiLocalizationProvider.defaultProps.localeText} localeText={faIR.components.MuiLocalizationProvider.defaultProps.localeText}
> >
<DialogContent> <DialogContent>
<Container maxWidth='lg'> <Container maxWidth="lg">
<StyledForm onSubmit={handleSubmit(onSubmit)} id={'InquiryPrivacyFencingCreateForm'}> <StyledForm onSubmit={handleSubmit(onSubmit)} id={"InquiryPrivacyFencingCreateForm"}>
<Grid container columns={{ xs: 1, sm: 2, md: 3 }} spacing={4}> <Grid container columns={{ xs: 1, sm: 2, md: 3 }} spacing={4}>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('dabirkhaneh_number')} label="شماره دبیرخانه درخواست *" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("dabirkhaneh_number")}
label="شماره دبیرخانه درخواست *"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Controller <Controller
@@ -157,14 +183,20 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
onChange={(newValue) => onChange(moment(newValue))} onChange={(newValue) => onChange(moment(newValue))}
label="تاریخ نامه درخواست *" label="تاریخ نامه درخواست *"
slotProps={{ slotProps={{
textField: { fullWidth: true, size: "small", autoComplete: 'off' }, textField: { fullWidth: true, size: "small", autoComplete: "off" },
}} }}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<TextField autoComplete="off" {...register('marjae_pasokh')} label="مرجع درخواست کننده پاسخ به استعلام" size="small" fullWidth /> <TextField
autoComplete="off"
{...register("marjae_pasokh")}
label="مرجع درخواست کننده پاسخ به استعلام"
size="small"
fullWidth
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Controller <Controller
@@ -176,16 +208,22 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["حقوقی", "حقیقی"]} options={["حقوقی", "حقیقی"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="متقاضی *" />} renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="متقاضی *" />
)}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Fade in={watch('motaghazi_is_legal_id') === 'حقوقی'} mountOnEnter={true} unmountOnExit={true}> <Fade
in={watch("motaghazi_is_legal_id") === "حقوقی"}
mountOnEnter={true}
unmountOnExit={true}
>
<Box> <Box>
<Controller <Controller
name="motaghazi_type" name="motaghazi_type"
@@ -196,10 +234,17 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["دولتی", "خصوصی"]} options={["دولتی", "خصوصی"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="نوع متقاضی *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نوع متقاضی *"
/>
)}
/> />
)} )}
/> />
@@ -208,26 +253,76 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
</Grid> </Grid>
<Grid item xs={1}></Grid> <Grid item xs={1}></Grid>
<Grid item xs={1}> <Grid item xs={1}>
<TextField autoComplete="off" {...register('motaghazi_firstname')} label="نام متقاضی *" size="small" fullWidth /> <TextField
autoComplete="off"
{...register("motaghazi_firstname")}
label="نام متقاضی *"
size="small"
fullWidth
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Fade in={watch('motaghazi_is_legal_id') === 'حقیقی'} mountOnEnter={true} unmountOnExit={true}> <Fade
<TextField autoComplete="off" {...register('motaghazi_lastname')} label="نام خانوادگی متقاضی *" size="small" fullWidth /> in={watch("motaghazi_is_legal_id") === "حقیقی"}
mountOnEnter={true}
unmountOnExit={true}
>
<TextField
autoComplete="off"
{...register("motaghazi_lastname")}
label="نام خانوادگی متقاضی *"
size="small"
fullWidth
/>
</Fade> </Fade>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('national_id')} label="کد ملی/شناسه ملی *" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("national_id")}
label="کد ملی/شناسه ملی *"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('tel_number')} label="تلفن" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("tel_number")}
label="تلفن"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Fade in={watch('motaghazi_type') !== 'دولتی' || watch('formik.values.motaghazi_is_legal_id') === 'حقیقی'} mountOnEnter={true} unmountOnExit={true}> <Fade
<LtrTextField autoComplete="off" {...register('mobile_number')} label="تلفن همراه *" size="small" fullWidth type="tel" /> in={
watch("motaghazi_type") !== "دولتی" ||
watch("formik.values.motaghazi_is_legal_id") === "حقیقی"
}
mountOnEnter={true}
unmountOnExit={true}
>
<LtrTextField
autoComplete="off"
{...register("mobile_number")}
label="تلفن همراه *"
size="small"
fullWidth
type="tel"
/>
</Fade> </Fade>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<TextField autoComplete="off" {...register('address')} label="آدرس *" size="small" fullWidth /> <TextField
autoComplete="off"
{...register("address")}
label="آدرس *"
size="small"
fullWidth
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Controller <Controller
@@ -239,11 +334,12 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["تهران"]} options={["تهران"]}
renderInput={(params) => ( renderInput={(params) => (
<TextField autoComplete="off" <TextField
autoComplete="off"
fullWidth fullWidth
{...params} {...params}
label="اداره كل راهداری و حمل و نقل جاده ای *" label="اداره كل راهداری و حمل و نقل جاده ای *"
@@ -263,10 +359,17 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["تهران"]} options={["تهران"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="اداره شهرستان *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="اداره شهرستان *"
/>
)}
/> />
)} )}
/> />
@@ -281,10 +384,12 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["آزاد راه", "بزرگراه", 'راه فرعی درجه 3']} options={["آزاد راه", "بزرگراه", "راه فرعی درجه 3"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="نوع راه *" />} renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="نوع راه *" />
)}
/> />
)} )}
/> />
@@ -299,16 +404,23 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["سایر"]} options={["سایر"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="نام محور *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نام محور *"
/>
)}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Fade in={watch('name_mehvar_fa') === "سایر"} mountOnEnter={true} unmountOnExit={true}> <Fade in={watch("name_mehvar_fa") === "سایر"} mountOnEnter={true} unmountOnExit={true}>
<TextField autoComplete="off" label="سایر محورها" size="small" fullWidth /> <TextField autoComplete="off" label="سایر محورها" size="small" fullWidth />
</Fade> </Fade>
</Grid> </Grid>
@@ -322,10 +434,12 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["چپ", "راست"]} options={["چپ", "راست"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="سمت *" />} renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="سمت *" />
)}
/> />
)} )}
/> />
@@ -340,16 +454,27 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["12.5", "17.5"]} options={["12.5", "17.5"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="میزان حریم *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="میزان حریم *"
/>
)}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Fade in={watch('rah_type_id') !== 'راه فرعی درجه 3'} mountOnEnter={true} unmountOnExit={true}> <Fade
in={watch("rah_type_id") !== "راه فرعی درجه 3"}
mountOnEnter={true}
unmountOnExit={true}
>
<Box> <Box>
<Controller <Controller
name="arze_navar" name="arze_navar"
@@ -360,10 +485,17 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["15", "30"]} options={["15", "30"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="عرض نوار تاسیساتی زیربنایی *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="عرض نوار تاسیساتی زیربنایی *"
/>
)}
/> />
)} )}
/> />
@@ -371,15 +503,40 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
</Fade> </Fade>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('kilometr')} label="كيلومتر *" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("kilometr")}
label="كيلومتر *"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1} sm={2} sx={{ height: 300 }}> <Grid item xs={1} sm={2} sx={{ height: 300 }}>
<LocationOnMap setValue={setValue} defaultLatLon={defaultValues ? [defaultValues.lat, defaultValues.lon] : null} defaultValues /> <LocationOnMap
setValue={setValue}
defaultLatLon={defaultValues ? [defaultValues.lat, defaultValues.lon] : null}
defaultValues
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Stack spacing={3}> <Stack spacing={3}>
<LtrTextField autoComplete="off" {...register('lat')} label="عرض جغرافیایی" size="small" fullWidth disabled={true} /> <LtrTextField
<LtrTextField autoComplete="off" {...register('lon')} label="طول جغرافیایی" size="small" fullWidth disabled={true} /> autoComplete="off"
{...register("lat")}
label="عرض جغرافیایی"
size="small"
fullWidth
disabled={true}
/>
<LtrTextField
autoComplete="off"
{...register("lon")}
label="طول جغرافیایی"
size="small"
fullWidth
disabled={true}
/>
<Controller <Controller
name="zone" name="zone"
control={control} control={control}
@@ -389,10 +546,17 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["38", "39"]} options={["38", "39"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="Zone *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="Zone *"
/>
)}
/> />
)} )}
/> />
@@ -408,22 +572,42 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["اتاقک نگهبانی", "دولتی"]} options={["اتاقک نگهبانی", "دولتی"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="نوع کاربری *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نوع کاربری *"
/>
)}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<TextField autoComplete="off" {...register('tarh_title')} label="عنوان طرح *" size="small" fullWidth /> <TextField
autoComplete="off"
{...register("tarh_title")}
label="عنوان طرح *"
size="small"
fullWidth
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('masahat_zirbana')} label="مساحت زیربنا" size="small" fullWidth type="tel" InputProps={{ <LtrTextField
endAdornment: <InputAdornment position="end"> autoComplete="off"
مترمربع</InputAdornment>, {...register("masahat_zirbana")}
}} /> label="مساحت زیربنا"
size="small"
fullWidth
type="tel"
InputProps={{
endAdornment: <InputAdornment position="end">مترمربع</InputAdornment>,
}}
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Controller <Controller
@@ -436,31 +620,60 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
renderTags={(value, getTagProps) => renderTags={(value, getTagProps) =>
value.map((option, index) => { value.map((option, index) => {
const { key, ...tagProps } = getTagProps({ index }); const { key, ...tagProps } = getTagProps({ index });
return ( return (
<Chip label={option} key={key} size="small" sx={{ '&.MuiAutocomplete-tag': { my: 0 } }} {...tagProps} /> <Chip
label={option}
key={key}
size="small"
sx={{ "&.MuiAutocomplete-tag": { my: 0 } }}
{...tagProps}
/>
); );
}) })
} }
options={["تعمیرات", "احداث بنا"]} options={["تعمیرات", "احداث بنا"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="نوع احداثات *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نوع احداثات *"
/>
)}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('divarkeshi_distance')} label="فاصله دیوارکشی از آکس محور" size="small" fullWidth type="tel" InputProps={{ <LtrTextField
endAdornment: <InputAdornment position="end">متر</InputAdornment>, autoComplete="off"
}} /> {...register("divarkeshi_distance")}
label="فاصله دیوارکشی از آکس محور"
size="small"
fullWidth
type="tel"
InputProps={{
endAdornment: <InputAdornment position="end">متر</InputAdornment>,
}}
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('mostahadesat_distance')} label="فاصله مستحدثات از آکس محور" size="small" fullWidth type="tel" InputProps={{ <LtrTextField
endAdornment: <InputAdornment position="end">متر</InputAdornment>, autoComplete="off"
}} /> {...register("mostahadesat_distance")}
label="فاصله مستحدثات از آکس محور"
size="small"
fullWidth
type="tel"
InputProps={{
endAdornment: <InputAdornment position="end">متر</InputAdornment>,
}}
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Controller <Controller
@@ -472,10 +685,12 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["داخل حریم"]} options={["داخل حریم"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="محل اجرا" />} renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="محل اجرا" />
)}
/> />
)} )}
/> />
@@ -490,10 +705,17 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["سبک (ضریب ۱)"]} options={["سبک (ضریب ۱)"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="میزان ترافیک *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="میزان ترافیک *"
/>
)}
/> />
)} )}
/> />
@@ -508,10 +730,17 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["تست"]} options={["تست"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="وضعیت اقتصادی" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="وضعیت اقتصادی"
/>
)}
/> />
)} )}
/> />
@@ -526,46 +755,115 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
disablePortal disablePortal
value={value} value={value}
onChange={(event, newValue) => { onChange={(event, newValue) => {
onChange(newValue) onChange(newValue);
}} }}
options={["بله", "خیر"]} options={["بله", "خیر"]}
renderInput={(params) => <TextField autoComplete="off" fullWidth {...params} label="آیا راه دسترسی از قبل وجود دارد؟ *" />} renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="آیا راه دسترسی از قبل وجود دارد؟ *"
/>
)}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('shomare_estelam_harim')} label="شماره استعلام دفتر ایمنی و حریم" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("shomare_estelam_harim")}
label="شماره استعلام دفتر ایمنی و حریم"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<Stack direction={'row'} spacing={1} alignItems={'center'}> <Stack direction={"row"} spacing={1} alignItems={"center"}>
<Typography sx={{ flex: 2 }} variant="body2">حداکثر مدت زمان شروع عملیات: *</Typography> <Typography sx={{ flex: 2 }} variant="body2">
<LtrTextField autoComplete="off" {...register('max_month')} sx={{ width: 60 }} label="ماه" size="small" type="tel" /> حداکثر مدت زمان شروع عملیات: *
<LtrTextField autoComplete="off" {...register('max_day')} sx={{ width: 60 }} label="روز" size="small" type="tel" /> </Typography>
<LtrTextField
autoComplete="off"
{...register("max_month")}
sx={{ width: 60 }}
label="ماه"
size="small"
type="tel"
/>
<LtrTextField
autoComplete="off"
{...register("max_day")}
sx={{ width: 60 }}
label="روز"
size="small"
type="tel"
/>
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('shomare_tahaodname')} label="شماره تعهدنامه" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("shomare_tahaodname")}
label="شماره تعهدنامه"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<LtrTextField autoComplete="off" {...register('shomare_daftarkhaneh')} label="شماره دفترخانه" size="small" fullWidth type="tel" /> <LtrTextField
autoComplete="off"
{...register("shomare_daftarkhaneh")}
label="شماره دفترخانه"
size="small"
fullWidth
type="tel"
/>
</Grid> </Grid>
<Grid item xs={1}></Grid> <Grid item xs={1}></Grid>
<Grid item xs={1}> <Grid item xs={1}>
<TextField autoComplete="off" {...register('description')} multiline rows={2} label="توضیحات" size="small" fullWidth /> <TextField
autoComplete="off"
{...register("description")}
multiline
rows={2}
label="توضیحات"
size="small"
fullWidth
/>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<TextField autoComplete="off" {...register('ronevesht')} multiline rows={2} label="رونوشت" size="small" fullWidth /> <TextField
autoComplete="off"
{...register("ronevesht")}
multiline
rows={2}
label="رونوشت"
size="small"
fullWidth
/>
</Grid> </Grid>
<Grid item xs={1}></Grid> <Grid item xs={1}></Grid>
</Grid> </Grid>
</StyledForm> </StyledForm>
</Container> </Container>
</DialogContent> </DialogContent>
<DialogActions sx={{ p: 2, borderTop: 1, borderColor: 'divider' }}> <DialogActions sx={{ p: 2, borderTop: 1, borderColor: "divider" }}>
<Button variant="contained" size="large" sx={{ width: 150 }} type="submit" form={'InquiryPrivacyFencingCreateForm'} disabled={isSubmitting}>ثبت</Button> <Button
variant="contained"
size="large"
sx={{ width: 150 }}
type="submit"
form={"InquiryPrivacyFencingCreateForm"}
disabled={isSubmitting}
>
ثبت
</Button>
</DialogActions> </DialogActions>
</LocalizationProvider > </LocalizationProvider>
); );
}; };
export default CreateOrUpdateForm; export default CreateOrUpdateForm;

View File

@@ -12,21 +12,26 @@ const MarkerLocation = ({ setValue, defaultLatLon }) => {
const location = useRef(); const location = useRef();
const map = useMapEvents({ const map = useMapEvents({
move: (e) => { move: (e) => {
const latlon = e.target.getCenter() const latlon = e.target.getCenter();
location.current?.setLatLng(latlon); location.current?.setLatLng(latlon);
setValue('lat', latlon.lat) setValue("lat", latlon.lat);
setValue('lon', latlon.lng) setValue("lon", latlon.lng);
}, },
zoom: (e) => { zoom: (e) => {
const latlon = e.target.getCenter() const latlon = e.target.getCenter();
location.current?.setLatLng(latlon); location.current?.setLatLng(latlon);
setValue('lat', latlon.lat) setValue("lat", latlon.lat);
setValue('lon', latlon.lng) setValue("lon", latlon.lng);
}, },
}); });
return ( return (
<Marker ref={location} icon={locationMarker} position={defaultLatLon ? L.LatLng(defaultLatLon.lat, defaultLatLon.lon) : map.getCenter()} key="location" /> <Marker
) ref={location}
} icon={locationMarker}
export default MarkerLocation position={defaultLatLon ? L.LatLng(defaultLatLon.lat, defaultLatLon.lon) : map.getCenter()}
key="location"
/>
);
};
export default MarkerLocation;

View File

@@ -11,12 +11,12 @@ const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
const LocationOnMap = ({ setValue, defaultLatLon }) => { const LocationOnMap = ({ setValue, defaultLatLon }) => {
return ( return (
<Stack sx={{ height: "100%", position: "relative" }}> <Stack sx={{ height: "100%", position: "relative" }}>
<Paper sx={{ flexGrow: 1, border: 1, borderRadius: 1, borderColor: 'divider' }} elevation={0}> <Paper sx={{ flexGrow: 1, border: 1, borderRadius: 1, borderColor: "divider" }} elevation={0}>
<MapLayer style={{ borderRadius: '4px' }}> <MapLayer style={{ borderRadius: "4px" }}>
<MarkerLocation setValue={setValue} defaultLatLon={defaultLatLon} /> <MarkerLocation setValue={setValue} defaultLatLon={defaultLatLon} />
</MapLayer> </MapLayer>
</Paper> </Paper>
</Stack> </Stack>
) );
} };
export default LocationOnMap export default LocationOnMap;

View File

@@ -1,7 +1,6 @@
import InquiryPrivacyFencingCreate from "./Actions/Create"; import InquiryPrivacyFencingCreate from "./Actions/Create";
const Toolbar = ({ mutate }) => { const Toolbar = ({ mutate }) => {
return ( return (
<> <>
<InquiryPrivacyFencingCreate mutate={mutate} /> <InquiryPrivacyFencingCreate mutate={mutate} />

View File

@@ -13,4 +13,3 @@ const InquiryPrivacyFencingPage = () => {
); );
}; };
export default InquiryPrivacyFencingPage; export default InquiryPrivacyFencingPage;

View File

@@ -231,12 +231,12 @@ const InquiryPrivacyFencingList = () => {
enableColumnFilter: false, enableColumnFilter: false,
}, },
], ],
[], []
); );
return ( return (
<> <>
<Box sx={{ p: 2, border: 1, borderColor: 'divider', borderRadius: 1 }}> <Box sx={{ p: 2, border: 1, borderColor: "divider", borderRadius: 1 }}>
<DataTable <DataTable
table_title={"لیست استعلام ها"} table_title={"لیست استعلام ها"}
need_filter={false} need_filter={false}
@@ -252,4 +252,3 @@ const InquiryPrivacyFencingList = () => {
); );
}; };
export default InquiryPrivacyFencingList; export default InquiryPrivacyFencingList;

View File

@@ -4,7 +4,7 @@ import HeaderBottom from "./HaederBottom";
const HeaderWithLogo = () => { const HeaderWithLogo = () => {
return ( return (
<Stack sx={{ width: '100%', position: 'fixed', zIndex: 1200, background: '#fff' }}> <Stack sx={{ width: "100%", position: "fixed", zIndex: 1200, background: "#fff" }}>
<HeaderTop /> <HeaderTop />
<HeaderBottom /> <HeaderBottom />
</Stack> </Stack>

View File

@@ -90,7 +90,7 @@ const HeaderWithSidebar = ({ children }) => {
boxSizing: "border-box", boxSizing: "border-box",
borderTop: 1, borderTop: 1,
borderTopColor: "divider", borderTopColor: "divider",
position: 'inherit' position: "inherit",
}, },
}} }}
variant="persistent" variant="persistent"
@@ -103,7 +103,9 @@ const HeaderWithSidebar = ({ children }) => {
</IconButton> </IconButton>
</DrawerHeader> </DrawerHeader>
<SidebarMenu /> <SidebarMenu />
<Typography textAlign={'center'} variant="caption" sx={{ py: .2, fontFamily: 'sans-serif' }}>v{process.env.NEXT_PUBLIC_VERSION}</Typography> <Typography textAlign={"center"} variant="caption" sx={{ py: 0.2, fontFamily: "sans-serif" }}>
v{process.env.NEXT_PUBLIC_VERSION}
</Typography>
</Drawer> </Drawer>
<Main open={open} sx={{ height: "100%", width: "100%", overflow: "hidden" }}> <Main open={open} sx={{ height: "100%", width: "100%", overflow: "hidden" }}>
<DrawerHeader /> <DrawerHeader />
@@ -114,4 +116,4 @@ const HeaderWithSidebar = ({ children }) => {
</Box> </Box>
); );
}; };
export default HeaderWithSidebar; export default HeaderWithSidebar;

View File

@@ -32,13 +32,11 @@ const DataTable_Main = (props) => {
const fetchUrl = useMemo(() => { const fetchUrl = useMemo(() => {
const isValueEmpty = (value) => { const isValueEmpty = (value) => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value.length === 0 || value.every(v => v === ""); return value.length === 0 || value.every((v) => v === "");
} }
return value === "" || value === null || value === undefined; return value === "" || value === null || value === undefined;
}; };
const filteredFilterData = Object.values(filterData).filter( const filteredFilterData = Object.values(filterData).filter((filter) => !isValueEmpty(filter.value));
(filter) => !isValueEmpty(filter.value),
);
const params = new URLSearchParams(); const params = new URLSearchParams();
params.set("start", `${pagination.pageIndex * pagination.pageSize}`); params.set("start", `${pagination.pageIndex * pagination.pageSize}`);

View File

@@ -1,10 +1,10 @@
import { getCommonMRTCellStyles, parseFromValuesOrFunc } from '@/core/utils/utils'; import { getCommonMRTCellStyles, parseFromValuesOrFunc } from "@/core/utils/utils";
import { useTheme } from '@emotion/react'; import { useTheme } from "@emotion/react";
import { Skeleton, TableCell } from '@mui/material'; import { Skeleton, TableCell } from "@mui/material";
import { isCellEditable, openEditingCell } from 'material-react-table'; import { isCellEditable, openEditingCell } from "material-react-table";
import { memo, useEffect, useMemo, useState } from 'react'; import { memo, useEffect, useMemo, useState } from "react";
import DataTable_CopyButton from '../buttons/CopyButton'; import DataTable_CopyButton from "../buttons/CopyButton";
import DataTable_TableBodyCellValue from './TableBodyCellValue'; import DataTable_TableBodyCellValue from "./TableBodyCellValue";
const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, ...rest }) => { const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, ...rest }) => {
const theme = useTheme(); const theme = useTheme();
@@ -82,10 +82,10 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
const borderStyle = showResizeBorder const borderStyle = showResizeBorder
? `2px solid ${draggingBorderColor} !important` ? `2px solid ${draggingBorderColor} !important`
: isDraggingColumn || isDraggingRow : isDraggingColumn || isDraggingRow
? `1px dashed ${theme.palette.grey[500]} !important` ? `1px dashed ${theme.palette.grey[500]} !important`
: isHoveredColumn || isHoveredRow || isResizingColumn : isHoveredColumn || isHoveredRow || isResizingColumn
? `2px dashed ${draggingBorderColor} !important` ? `2px dashed ${draggingBorderColor} !important`
: undefined; : undefined;
if (showResizeBorder) { if (showResizeBorder) {
return columnResizeDirection === "ltr" ? { borderRight: borderStyle } : { borderLeft: borderStyle }; return columnResizeDirection === "ltr" ? { borderRight: borderStyle } : { borderLeft: borderStyle };
@@ -93,18 +93,18 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
return borderStyle return borderStyle
? { ? {
borderBottom: borderBottom:
isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn) ? borderStyle : undefined, isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn) ? borderStyle : undefined,
borderLeft: borderLeft:
isDraggingColumn || isHoveredColumn || ((isDraggingRow || isHoveredRow) && isFirstColumn) isDraggingColumn || isHoveredColumn || ((isDraggingRow || isHoveredRow) && isFirstColumn)
? borderStyle ? borderStyle
: undefined, : undefined,
borderRight: borderRight:
isDraggingColumn || isHoveredColumn || ((isDraggingRow || isHoveredRow) && isLastColumn) isDraggingColumn || isHoveredColumn || ((isDraggingRow || isHoveredRow) && isLastColumn)
? borderStyle ? borderStyle
: undefined, : undefined,
borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined, borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
} }
: undefined; : undefined;
}, [columnSizingInfo.isResizingColumn, draggingColumn, draggingRow, hoveredColumn, hoveredRow, staticRowIndex]); }, [columnSizingInfo.isResizingColumn, draggingColumn, draggingRow, hoveredColumn, hoveredRow, staticRowIndex]);
@@ -178,8 +178,8 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
"&:hover": { "&:hover": {
outline: outline:
actionCell?.id === cell.id || actionCell?.id === cell.id ||
(editDisplayMode === "cell" && isEditable) || (editDisplayMode === "cell" && isEditable) ||
(editDisplayMode === "table" && (isCreating || isEditing)) (editDisplayMode === "table" && (isCreating || isEditing))
? `1px solid ${theme.palette.grey[500]}` ? `1px solid ${theme.palette.grey[500]}`
: undefined, : undefined,
textOverflow: "clip", textOverflow: "clip",
@@ -188,8 +188,8 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
cursor: isRightClickable cursor: isRightClickable
? "context-menu" ? "context-menu"
: isEditable && editDisplayMode === "cell" : isEditable && editDisplayMode === "cell"
? "pointer" ? "pointer"
: "inherit", : "inherit",
outline: actionCell?.id === cell.id ? `1px solid ${theme.palette.grey[500]}` : undefined, outline: actionCell?.id === cell.id ? `1px solid ${theme.palette.grey[500]}` : undefined,
outlineOffset: "-1px", outlineOffset: "-1px",
overflow: "hidden", overflow: "hidden",
@@ -199,12 +199,12 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
? "0 0.5rem" ? "0 0.5rem"
: "0.5rem" : "0.5rem"
: density === "comfortable" : density === "comfortable"
? columnDefType === "display" ? columnDefType === "display"
? "0.5rem 0.75rem" ? "0.5rem 0.75rem"
: "1rem" : "1rem"
: columnDefType === "display" : columnDefType === "display"
? "1rem 1.25rem" ? "1rem 1.25rem"
: "1.5rem", : "1.5rem",
textOverflow: columnDefType !== "display" ? "ellipsis" : undefined, textOverflow: columnDefType !== "display" ? "ellipsis" : undefined,
whiteSpace: row.getIsPinned() || density === "compact" ? "nowrap" : "normal", whiteSpace: row.getIsPinned() || density === "compact" ? "nowrap" : "normal",
@@ -215,7 +215,7 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
theme, theme,
}), }),
...draggingBorders, ...draggingBorders,
backgroundColor: baseBackgroundColor backgroundColor: baseBackgroundColor,
})} })}
> >
{tableCellProps.children ?? ( {tableCellProps.children ?? (
@@ -225,8 +225,8 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
) : showSkeletons !== false && (isLoading || showSkeletons) ? ( ) : showSkeletons !== false && (isLoading || showSkeletons) ? (
<Skeleton animation="wave" height={20} width={skeletonWidth} {...skeletonProps} /> <Skeleton animation="wave" height={20} width={skeletonWidth} {...skeletonProps} />
) : columnDefType === "display" && ) : columnDefType === "display" &&
(["mrt-row-expand", "mrt-row-numbers", "mrt-row-select"].includes(column.id) || (["mrt-row-expand", "mrt-row-numbers", "mrt-row-select"].includes(column.id) ||
!row.getIsGrouped()) ? ( !row.getIsGrouped()) ? (
columnDef.Cell?.({ columnDef.Cell?.({
cell, cell,
column, column,

View File

@@ -91,16 +91,16 @@ const DataTable_TableBodyRow = ({
const cellHighlightColor = isRowSelected const cellHighlightColor = isRowSelected
? selectedRowBackgroundColor ? selectedRowBackgroundColor
: isRowPinned : isRowPinned
? pinnedRowBackgroundColor ? pinnedRowBackgroundColor
: undefined; : undefined;
const cellHighlightColorHover = const cellHighlightColorHover =
tableRowProps?.hover !== false tableRowProps?.hover !== false
? isRowSelected ? isRowSelected
? cellHighlightColor ? cellHighlightColor
: theme.palette.mode === "dark" : theme.palette.mode === "dark"
? `${lighten(baseBackgroundColor, 0.2)}` ? `${lighten(baseBackgroundColor, 0.2)}`
: `${darken(baseBackgroundColor, 0.2)}` : `${darken(baseBackgroundColor, 0.2)}`
: undefined; : undefined;
return ( return (
@@ -126,9 +126,9 @@ const DataTable_TableBodyRow = ({
sx={(theme) => ({ sx={(theme) => ({
"&:hover td:after": cellHighlightColorHover "&:hover td:after": cellHighlightColorHover
? { ? {
backgroundColor: alpha(cellHighlightColorHover, 0.3), backgroundColor: alpha(cellHighlightColorHover, 0.3),
...commonCellBeforeAfterStyles, ...commonCellBeforeAfterStyles,
} }
: undefined, : undefined,
bottom: bottom:
!virtualRow && bottomPinnedIndex !== undefined && isRowPinned !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
@@ -140,24 +140,25 @@ const DataTable_TableBodyRow = ({
position: virtualRow position: virtualRow
? "absolute" ? "absolute"
: rowPinningDisplayMode?.includes("sticky") && isRowPinned : rowPinningDisplayMode?.includes("sticky") && isRowPinned
? "sticky" ? "sticky"
: "relative", : "relative",
td: { td: {
...getCommonPinnedCellStyles({ table, theme }), ...getCommonPinnedCellStyles({ table, theme }),
}, },
"td:after": cellHighlightColor "td:after": cellHighlightColor
? { ? {
backgroundColor: cellHighlightColor, backgroundColor: cellHighlightColor,
...commonCellBeforeAfterStyles, ...commonCellBeforeAfterStyles,
} }
: undefined, : undefined,
top: virtualRow top: virtualRow
? 0 ? 0
: topPinnedIndex !== undefined && isRowPinned : topPinnedIndex !== undefined && isRowPinned
? `${topPinnedIndex * rowHeight + ? `${
(enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0) topPinnedIndex * rowHeight +
(enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)
}px` }px`
: undefined, : undefined,
transition: virtualRow ? "none" : "all 150ms ease-in-out", transition: virtualRow ? "none" : "all 150ms ease-in-out",
width: "100%", width: "100%",
zIndex: rowPinningDisplayMode?.includes("sticky") && isRowPinned ? 2 : 0, zIndex: rowPinningDisplayMode?.includes("sticky") && isRowPinned ? 2 : 0,
@@ -181,11 +182,11 @@ const DataTable_TableBodyRow = ({
}; };
return cell ? ( return cell ? (
memoMode === "cells" && memoMode === "cells" &&
cell.column.columnDef.columnDefType === "data" && cell.column.columnDef.columnDefType === "data" &&
!draggingColumn && !draggingColumn &&
!draggingRow && !draggingRow &&
editingCell?.id !== cell.id && editingCell?.id !== cell.id &&
editingRow?.id !== row.id ? ( editingRow?.id !== row.id ? (
<Memo_DataTable_TableBodyCell key={cell.id} {...props} /> <Memo_DataTable_TableBodyCell key={cell.id} {...props} />
) : ( ) : (
<DataTable_TableBodyCell key={cell.id} {...props} /> <DataTable_TableBodyCell key={cell.id} {...props} />

View File

@@ -18,15 +18,15 @@ const columnFilterModeOptionFa = {
}; };
function FilterBodyField({ function FilterBodyField({
column, column,
filterParameters, filterParameters,
handleChange, handleChange,
handleBlur, handleBlur,
setFieldValue, setFieldValue,
errors, errors,
touched, touched,
resetForm, resetForm,
}) { }) {
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
const defaultFilterTranslation = columnFilterModeOptionFa[filterParameters.filterFn] || filterParameters.filterFn; const defaultFilterTranslation = columnFilterModeOptionFa[filterParameters.filterFn] || filterParameters.filterFn;
@@ -48,8 +48,8 @@ function FilterBodyField({
touched={touched} touched={touched}
/> />
) : filterParameters.datatype === "numeric" && ) : filterParameters.datatype === "numeric" &&
filterParameters.filterFn === "equals" && filterParameters.filterFn === "equals" &&
Array.isArray(column.columnSelectOption) ? ( Array.isArray(column.columnSelectOption) ? (
<CustomSelect <CustomSelect
column={column} column={column}
filterParameters={filterParameters} filterParameters={filterParameters}

View File

@@ -4,15 +4,14 @@ import { ListItem, Menu } from "@mui/material";
import { useState } from "react"; import { useState } from "react";
function FilterOptionList({ function FilterOptionList({
column, column,
filterType, filterType,
filterOption, filterOption,
anchorEl, anchorEl,
columnFilterModeOptionFa, columnFilterModeOptionFa,
setAnchorEl, setAnchorEl,
setFieldValue, setFieldValue,
}) { }) {
const [selectedFilter, setSelectedFilter] = useState(filterType); const [selectedFilter, setSelectedFilter] = useState(filterType);
const handleChangeItem = (event, index) => { const handleChangeItem = (event, index) => {

View File

@@ -67,20 +67,20 @@ const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex,
const borderStyle = showResizeBorder const borderStyle = showResizeBorder
? `2px solid ${draggingBorderColor} !important` ? `2px solid ${draggingBorderColor} !important`
: draggingColumn?.id === column.id : draggingColumn?.id === column.id
? `1px dashed ${theme.palette.grey[500]}` ? `1px dashed ${theme.palette.grey[500]}`
: hoveredColumn?.id === column.id : hoveredColumn?.id === column.id
? `2px dashed ${draggingBorderColor}` ? `2px dashed ${draggingBorderColor}`
: undefined; : undefined;
if (showResizeBorder) { if (showResizeBorder) {
return columnResizeDirection === "ltr" ? { borderRight: borderStyle } : { borderLeft: borderStyle }; return columnResizeDirection === "ltr" ? { borderRight: borderStyle } : { borderLeft: borderStyle };
} }
const draggingBorders = borderStyle const draggingBorders = borderStyle
? { ? {
borderLeft: borderStyle, borderLeft: borderStyle,
borderRight: borderStyle, borderRight: borderStyle,
borderTop: borderStyle, borderTop: borderStyle,
} }
: undefined; : undefined;
return draggingBorders; return draggingBorders;
@@ -151,19 +151,19 @@ const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex,
density === "compact" density === "compact"
? "0.5rem" ? "0.5rem"
: density === "comfortable" : density === "comfortable"
? columnDefType === "display" ? columnDefType === "display"
? "0.75rem" ? "0.75rem"
: "1rem" : "1rem"
: columnDefType === "display" : columnDefType === "display"
? "1rem 1.25rem" ? "1rem 1.25rem"
: "1.5rem", : "1.5rem",
pb: columnDefType === "display" ? 0 : showColumnFilters || density === "compact" ? "0.4rem" : "0.6rem", pb: columnDefType === "display" ? 0 : showColumnFilters || density === "compact" ? "0.4rem" : "0.6rem",
pt: pt:
columnDefType === "group" || density === "compact" columnDefType === "group" || density === "compact"
? "0.25rem" ? "0.25rem"
: density === "comfortable" : density === "comfortable"
? ".75rem" ? ".75rem"
: "1.25rem", : "1.25rem",
userSelect: enableMultiSort && column.getCanSort() ? "none" : undefined, userSelect: enableMultiSort && column.getCanSort() ? "none" : undefined,
verticalAlign: "middle", verticalAlign: "middle",
...getCommonMRTCellStyles({ ...getCommonMRTCellStyles({
@@ -188,8 +188,8 @@ const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex,
columnDefType === "group" || tableCellProps?.align === "center" columnDefType === "group" || tableCellProps?.align === "center"
? "center" ? "center"
: column.getCanResize() : column.getCanResize()
? "space-between" ? "space-between"
: "flex-start", : "flex-start",
position: "relative", position: "relative",
width: "100%", width: "100%",
}} }}
@@ -218,7 +218,7 @@ const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex,
textAlign: "start", textAlign: "start",
color: "#fff", color: "#fff",
fontWeight: "400", fontWeight: "400",
whiteSpace: "nowrap" whiteSpace: "nowrap",
}} }}
> >
{HeaderElement} {HeaderElement}
@@ -226,9 +226,10 @@ const DataTable_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex,
{column.getCanSort() && columnDefType !== "group" && ( {column.getCanSort() && columnDefType !== "group" && (
<MRT_TableHeadCellSortLabel <MRT_TableHeadCellSortLabel
sx={{ sx={{
width: 20, '& .MuiTableSortLabel-icon': { width: 20,
"& .MuiTableSortLabel-icon": {
color: `#fff !important`, color: `#fff !important`,
} },
}} }}
header={header} header={header}
table={table} table={table}

View File

@@ -37,12 +37,7 @@ function HideBody({ columns, drawerState, setDrawerState }) {
<ScrollBox> <ScrollBox>
<Box sx={{ px: 1, py: 2, display: "flex", flexDirection: "column" }}> <Box sx={{ px: 1, py: 2, display: "flex", flexDirection: "column" }}>
{columns.map((column) => ( {columns.map((column) => (
<HideBodyField <HideBodyField key={column.id} column={column} hideData={hideData} setHideData={setHideData} />
key={column.id}
column={column}
hideData={hideData}
setHideData={setHideData}
/>
))} ))}
</Box> </Box>
</ScrollBox> </ScrollBox>
@@ -50,4 +45,4 @@ function HideBody({ columns, drawerState, setDrawerState }) {
); );
} }
export default HideBody; export default HideBody;

View File

@@ -22,7 +22,7 @@ const CustomTreeItem = styled(TreeItem)(({ theme }) => ({
function HideBodyField({ column, hideData, setHideData }) { function HideBodyField({ column, hideData, setHideData }) {
const handleCheckboxChange = () => { const handleCheckboxChange = () => {
setHideData(prevData => { setHideData((prevData) => {
const updateHideData = (data, id) => { const updateHideData = (data, id) => {
if (data.hasOwnProperty(id)) { if (data.hasOwnProperty(id)) {
return { ...data, [id]: !data[id] }; return { ...data, [id]: !data[id] };
@@ -44,11 +44,7 @@ function HideBodyField({ column, hideData, setHideData }) {
if (typeof hideData[column.id] === "boolean") { if (typeof hideData[column.id] === "boolean") {
return ( return (
<Box sx={{ display: "flex", alignItems: "center" }}> <Box sx={{ display: "flex", alignItems: "center" }}>
<Checkbox <Checkbox checked={hideData[column.id]} onChange={handleCheckboxChange} name={column.id} />
checked={hideData[column.id]}
onChange={handleCheckboxChange}
name={column.id}
/>
<Typography variant="subtitle1">{column.header}</Typography> <Typography variant="subtitle1">{column.header}</Typography>
</Box> </Box>
); );
@@ -77,4 +73,4 @@ function HideBodyField({ column, hideData, setHideData }) {
); );
} }
export default HideBodyField; export default HideBodyField;

View File

@@ -67,4 +67,4 @@ function HideOrShowAll({ hideData, setHideData }) {
); );
} }
export default HideOrShowAll; export default HideOrShowAll;

View File

@@ -19,4 +19,4 @@ function ResetStorage({ user_id, page_name, table_name }) {
); );
} }
export default ResetStorage; export default ResetStorage;

View File

@@ -5,17 +5,17 @@ import DataTable_TopToolbar from "../toolbar/TopToolbar";
import DataTable_TableContainer from "./TableContainer"; import DataTable_TableContainer from "./TableContainer";
const DataTable_Paper = ({ const DataTable_Paper = ({
table, table,
table_name, table_name,
columns, columns,
user_id, user_id,
page_name, page_name,
mutate, mutate,
need_filter, need_filter,
table_url, table_url,
table_title, table_title,
...rest ...rest
}) => { }) => {
const { const {
getState, getState,
options: { options: {
@@ -50,19 +50,19 @@ const DataTable_Paper = ({
style={{ style={{
...(isFullScreen ...(isFullScreen
? { ? {
bottom: 0, bottom: 0,
height: "100dvh", height: "100dvh",
left: 0, left: 0,
margin: 0, margin: 0,
maxHeight: "100dvh", maxHeight: "100dvh",
maxWidth: "100dvw", maxWidth: "100dvw",
padding: 0, padding: 0,
position: "fixed", position: "fixed",
right: 0, right: 0,
top: 0, top: 0,
width: "100dvw", width: "100dvw",
zIndex: 999, zIndex: 999,
} }
: {}), : {}),
...paperProps?.style, ...paperProps?.style,
}} }}

View File

@@ -8,16 +8,16 @@ import ResetStorage from "@/core/components/DataTable/reset/ResetStorage";
import HideColumn from "@/core/components/DataTable/hide"; import HideColumn from "@/core/components/DataTable/hide";
const DataTable_TopToolbar = ({ const DataTable_TopToolbar = ({
mutate, mutate,
need_filter, need_filter,
table, table,
columns, columns,
table_url, table_url,
user_id, user_id,
page_name, page_name,
table_name, table_name,
table_title, table_title,
}) => { }) => {
const { const {
getState, getState,
options: { options: {
@@ -70,13 +70,21 @@ const DataTable_TopToolbar = ({
width: "100%", width: "100%",
}} }}
> >
<Box sx={{ <Box
display: "flex", sx={{
alignItems: "center", display: "flex",
order: { xs: 2, sm: 1 }, alignItems: "center",
}}>{renderTopToolbarCustomActions?.({ table })}</Box> order: { xs: 2, sm: 1 },
<Typography sx={{ textAlign: "center", order: { xs: 1, sm: 2 }, width: { xs: "100%", sm: "unset" } }} }}
fontWeight={600}>{table_title || ""}</Typography> >
{renderTopToolbarCustomActions?.({ table })}
</Box>
<Typography
sx={{ textAlign: "center", order: { xs: 1, sm: 2 }, width: { xs: "100%", sm: "unset" } }}
fontWeight={600}
>
{table_title || ""}
</Typography>
{enableToolbarInternalActions && ( {enableToolbarInternalActions && (
<Box <Box
sx={{ sx={{
@@ -88,15 +96,14 @@ const DataTable_TopToolbar = ({
order: 3, order: 3,
}} }}
> >
<ResetStorage user_id={user_id} <ResetStorage user_id={user_id} page_name={page_name} table_name={table_name} />
page_name={page_name}
table_name={table_name} />
<UpdateTable mutate={mutate} /> <UpdateTable mutate={mutate} />
<HideColumn <HideColumn
columns={table.options.columns} columns={table.options.columns}
user_id={user_id} user_id={user_id}
page_name={page_name} page_name={page_name}
table_name={table_name} /> table_name={table_name}
/>
{need_filter && ( {need_filter && (
<FilterColumn <FilterColumn
columns={columns} columns={columns}

View File

@@ -5,4 +5,4 @@ const DialogTransition = React.forwardRef(function Transition(props, ref) {
return <Slide direction="up" ref={ref} {...props} />; return <Slide direction="up" ref={ref} {...props} />;
}); });
export default DialogTransition export default DialogTransition;

View File

@@ -2,11 +2,7 @@ import { Box, LinearProgress, Stack } from "@mui/material";
function MapLoading() { function MapLoading() {
return ( return (
<Stack <Stack sx={{ height: "100%" }} alignItems={"center"} justifyContent={"center"}>
sx={{ height: "100%" }}
alignItems={"center"}
justifyContent={"center"}
>
<Box sx={{ width: 200 }}> <Box sx={{ width: 200 }}>
<LinearProgress /> <LinearProgress />
</Box> </Box>
@@ -14,4 +10,4 @@ function MapLoading() {
); );
} }
export default MapLoading; export default MapLoading;

View File

@@ -1,7 +1,7 @@
"use client"; "use client";
import { MapContainer, TileLayer, useMap } from "react-leaflet"; import { MapContainer, TileLayer, useMap } from "react-leaflet";
export const IRAN_CENTER = L.latLng(32.4279, 53.6880); export const IRAN_CENTER = L.latLng(32.4279, 53.688);
const MapOptions = ({ options }) => { const MapOptions = ({ options }) => {
const map = useMap(); const map = useMap();
@@ -40,4 +40,4 @@ function MapLayer({ children, style, otherLayers, options }) {
); );
} }
export default MapLayer; export default MapLayer;

View File

@@ -10,9 +10,7 @@ import { flattenObjectOfObjects } from "@/core/utils/flattenObjectOfObjects";
function AskForKeepData({ filterData, sortData, hideData, user_id, page_name, table_name, columns }) { function AskForKeepData({ filterData, sortData, hideData, user_id, page_name, table_name, columns }) {
const { filterAction, sortAction, hideAction } = useTableSetting(); const { filterAction, sortAction, hideAction } = useTableSetting();
const filteredHideData = Object.fromEntries( const filteredHideData = Object.fromEntries(Object.entries(hideData).filter(([key, value]) => value === false));
Object.entries(hideData).filter(([key, value]) => value === false),
);
const flattenHideData = flattenObjectOfObjects(filteredHideData); const flattenHideData = flattenObjectOfObjects(filteredHideData);
@@ -53,19 +51,10 @@ function AskForKeepData({ filterData, sortData, hideData, user_id, page_name, ta
<Typography variant="caption">آیا مایل به ذخیره تغییر های اعمال شده برای دفعات بعد هستید؟</Typography> <Typography variant="caption">آیا مایل به ذخیره تغییر های اعمال شده برای دفعات بعد هستید؟</Typography>
</Box> </Box>
<Box sx={{ display: "flex", gap: 1, mt: 2 }}> <Box sx={{ display: "flex", gap: 1, mt: 2 }}>
<Button <Button variant="contained" size="small" endIcon={<DownloadIcon />} onClick={onSaveFilter}>
variant="contained"
size="small"
endIcon={<DownloadIcon />}
onClick={onSaveFilter}
>
ذخیره ذخیره
</Button> </Button>
<Button <Button variant="outlined" size="small" onClick={handleDismiss}>
variant="outlined"
size="small"
onClick={handleDismiss}
>
رد کردن رد کردن
</Button> </Button>
</Box> </Box>
@@ -73,4 +62,4 @@ function AskForKeepData({ filterData, sortData, hideData, user_id, page_name, ta
); );
} }
export default AskForKeepData; export default AskForKeepData;

View File

@@ -4,9 +4,15 @@ import { Chip, Divider, Typography } from "@mui/material";
const PageTitle = ({ title }) => { const PageTitle = ({ title }) => {
return ( return (
<Divider><Chip <Divider>
label={<Typography fontSize={14} fontWeight={500}>{title}</Typography>} /></Divider> <Chip
label={
<Typography fontSize={14} fontWeight={500}>
{title}
</Typography>
}
/>
</Divider>
); );
}; };
export default PageTitle; export default PageTitle;

View File

@@ -35,48 +35,48 @@ function reducer(state, action) {
return state.map((item) => return state.map((item) =>
action.id == item.id action.id == item.id
? { ? {
...item, ...item,
showSubitems: !item.showSubitems, showSubitems: !item.showSubitems,
} }
: item : item
); );
case "COLLAPSE_SUB_ITEMS": case "COLLAPSE_SUB_ITEMS":
return state.map((item) => { return state.map((item) => {
return item.hasSubitems return item.hasSubitems
? { ? {
...item, ...item,
Subitems: item.Subitems.map((subitem) => Subitems: item.Subitems.map((subitem) =>
action.id === subitem.id action.id === subitem.id
? { ? {
...subitem, ...subitem,
showSubitems: !subitem.showSubitems, showSubitems: !subitem.showSubitems,
} }
: subitem : subitem
), ),
} }
: item; : item;
}); });
case "COLLAPSE_SUB_SECOND_ITEMS": case "COLLAPSE_SUB_SECOND_ITEMS":
return state.map((item) => { return state.map((item) => {
return item.hasSubitems return item.hasSubitems
? { ? {
...item, ...item,
Subitems: item.Subitems.map((subitem) => { Subitems: item.Subitems.map((subitem) => {
return subitem.hasSubitems return subitem.hasSubitems
? { ? {
...subitem, ...subitem,
Subitems: subitem.Subitems.map((secondSubitem) => Subitems: subitem.Subitems.map((secondSubitem) =>
action.id === secondSubitem.id action.id === secondSubitem.id
? { ? {
...secondSubitem, ...secondSubitem,
showSubitems: !secondSubitem.showSubitems, showSubitems: !secondSubitem.showSubitems,
} }
: secondSubitem : secondSubitem
), ),
} }
: subitem; : subitem;
}), }),
} }
: item; : item;
}); });
case "SELECTED": case "SELECTED":

View File

@@ -1,5 +1,5 @@
import { styled } from "@mui/material"; import { styled } from "@mui/material";
const StyledForm = styled('form')``; const StyledForm = styled("form")``;
export default StyledForm; export default StyledForm;

View File

@@ -4,7 +4,7 @@ import { prefixer } from "stylis";
import stylisRTLPlugin from "stylis-plugin-rtl"; import stylisRTLPlugin from "stylis-plugin-rtl";
import { CacheProvider } from "@emotion/react"; import { CacheProvider } from "@emotion/react";
const isBrowser = typeof document !== 'undefined'; const isBrowser = typeof document !== "undefined";
const createEmotionCache = () => { const createEmotionCache = () => {
let insertionPoint; let insertionPoint;

View File

@@ -19,7 +19,7 @@ const errorServer = (response, notification, toastContainer) => {
const errorClient = (response, notification, toastContainer, logout) => { const errorClient = (response, notification, toastContainer, logout) => {
switch (response.status) { switch (response.status) {
case 401: case 401:
logout() logout();
if (notification) errorUnauthorizedToast(toastContainer); if (notification) errorUnauthorizedToast(toastContainer);
break; break;
case 422: case 422:

View File

@@ -7,4 +7,3 @@ export const flattenArrayOfObjects = (array, key) => {
return acc; return acc;
}, []); }, []);
}; };

View File

@@ -9,4 +9,4 @@ export const flattenObjectOfObjects = (obj, res = {}) => {
} }
} }
return res; return res;
}; };

View File

@@ -23,7 +23,7 @@ const DataTableProvider = ({ children, user_id, page_name, table_name, columns }
const filterValues = flatColumns.reduce((acc, column) => { const filterValues = flatColumns.reduce((acc, column) => {
if (!column.enableColumnFilter) return acc; if (!column.enableColumnFilter) return acc;
const storeFilter = settingStore?.[user_id]?.[page_name]?.[table_name]?.["filters"]?.find( const storeFilter = settingStore?.[user_id]?.[page_name]?.[table_name]?.["filters"]?.find(
(filter) => filter.id === column.id, (filter) => filter.id === column.id
); );
if (column.datatype === "array") { if (column.datatype === "array") {
acc[column.id] = { acc[column.id] = {
@@ -100,7 +100,7 @@ const DataTableProvider = ({ children, user_id, page_name, table_name, columns }
position: "bottom-left", position: "bottom-left",
draggable: true, draggable: true,
autoClose: false, autoClose: false,
}, }
); );
} else { } else {
toast.update("keep_data", { toast.update("keep_data", {

View File

@@ -49,7 +49,7 @@ export const AuthProvider = ({ children }) => {
clearUser(); clearUser();
changeAuthState(false); changeAuthState(false);
changeInitAuth(true); changeInitAuth(true);
} };
const getUser = useCallback(async () => { const getUser = useCallback(async () => {
try { try {
@@ -77,7 +77,7 @@ export const AuthProvider = ({ children }) => {
isAuth: state.isAuth, isAuth: state.isAuth,
initAuthState: state.initAuthState, initAuthState: state.initAuthState,
getUser, getUser,
logout logout,
}} }}
> >
{children} {children}

View File

@@ -130,4 +130,4 @@ export const TableSettingProvider = ({ children }) => {
{children} {children}
</TableSettingContext.Provider> </TableSettingContext.Provider>
); );
}; };

View File

@@ -16,7 +16,7 @@ const defaultOptions = {
}; };
const useRequest = (initOptions) => { const useRequest = (initOptions) => {
const { logout } = useAuth() const { logout } = useAuth();
const _options = Object.assign({}, defaultOptions, initOptions); const _options = Object.assign({}, defaultOptions, initOptions);
@@ -38,7 +38,8 @@ const useRequest = (initOptions) => {
errorResponse( errorResponse(
error.response, error.response,
mergedOptions.notification.show && mergedOptions.notification.failed, mergedOptions.notification.show && mergedOptions.notification.failed,
"request_data", logout "request_data",
logout
); );
} }
throw error; throw error;