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 }) => {
return (
<Stack sx={{ width: '100%', height: '100%' }}>
<Stack sx={{ width: "100%", height: "100%" }}>
<HeaderWithLogo />
<HeaderWithSidebar>{children}</HeaderWithSidebar>
</Stack>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,21 +12,26 @@ const MarkerLocation = ({ setValue, defaultLatLon }) => {
const location = useRef();
const map = useMapEvents({
move: (e) => {
const latlon = e.target.getCenter()
const latlon = e.target.getCenter();
location.current?.setLatLng(latlon);
setValue('lat', latlon.lat)
setValue('lon', latlon.lng)
setValue("lat", latlon.lat);
setValue("lon", latlon.lng);
},
zoom: (e) => {
const latlon = e.target.getCenter()
const latlon = e.target.getCenter();
location.current?.setLatLng(latlon);
setValue('lat', latlon.lat)
setValue('lon', latlon.lng)
setValue("lat", latlon.lat);
setValue("lon", latlon.lng);
},
});
return (
<Marker ref={location} icon={locationMarker} position={defaultLatLon ? L.LatLng(defaultLatLon.lat, defaultLatLon.lon) : map.getCenter()} key="location" />
)
}
export default MarkerLocation
<Marker
ref={location}
icon={locationMarker}
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 }) => {
return (
<Stack sx={{ height: "100%", position: "relative" }}>
<Paper sx={{ flexGrow: 1, border: 1, borderRadius: 1, borderColor: 'divider' }} elevation={0}>
<MapLayer style={{ borderRadius: '4px' }}>
<Paper sx={{ flexGrow: 1, border: 1, borderRadius: 1, borderColor: "divider" }} elevation={0}>
<MapLayer style={{ borderRadius: "4px" }}>
<MarkerLocation setValue={setValue} defaultLatLon={defaultLatLon} />
</MapLayer>
</Paper>
</Stack>
)
}
export default LocationOnMap
);
};
export default LocationOnMap;

View File

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

View File

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

View File

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

View File

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

View File

@@ -90,7 +90,7 @@ const HeaderWithSidebar = ({ children }) => {
boxSizing: "border-box",
borderTop: 1,
borderTopColor: "divider",
position: 'inherit'
position: "inherit",
},
}}
variant="persistent"
@@ -103,7 +103,9 @@ const HeaderWithSidebar = ({ children }) => {
</IconButton>
</DrawerHeader>
<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>
<Main open={open} sx={{ height: "100%", width: "100%", overflow: "hidden" }}>
<DrawerHeader />
@@ -114,4 +116,4 @@ const HeaderWithSidebar = ({ children }) => {
</Box>
);
};
export default HeaderWithSidebar;
export default HeaderWithSidebar;

View File

@@ -32,13 +32,11 @@ const DataTable_Main = (props) => {
const fetchUrl = useMemo(() => {
const isValueEmpty = (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;
};
const filteredFilterData = Object.values(filterData).filter(
(filter) => !isValueEmpty(filter.value),
);
const filteredFilterData = Object.values(filterData).filter((filter) => !isValueEmpty(filter.value));
const params = new URLSearchParams();
params.set("start", `${pagination.pageIndex * pagination.pageSize}`);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -37,12 +37,7 @@ function HideBody({ columns, drawerState, setDrawerState }) {
<ScrollBox>
<Box sx={{ px: 1, py: 2, display: "flex", flexDirection: "column" }}>
{columns.map((column) => (
<HideBodyField
key={column.id}
column={column}
hideData={hideData}
setHideData={setHideData}
/>
<HideBodyField key={column.id} column={column} hideData={hideData} setHideData={setHideData} />
))}
</Box>
</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 }) {
const handleCheckboxChange = () => {
setHideData(prevData => {
setHideData((prevData) => {
const updateHideData = (data, id) => {
if (data.hasOwnProperty(id)) {
return { ...data, [id]: !data[id] };
@@ -44,11 +44,7 @@ function HideBodyField({ column, hideData, setHideData }) {
if (typeof hideData[column.id] === "boolean") {
return (
<Box sx={{ display: "flex", alignItems: "center" }}>
<Checkbox
checked={hideData[column.id]}
onChange={handleCheckboxChange}
name={column.id}
/>
<Checkbox checked={hideData[column.id]} onChange={handleCheckboxChange} name={column.id} />
<Typography variant="subtitle1">{column.header}</Typography>
</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";
const DataTable_Paper = ({
table,
table_name,
columns,
user_id,
page_name,
mutate,
need_filter,
table_url,
table_title,
...rest
}) => {
table,
table_name,
columns,
user_id,
page_name,
mutate,
need_filter,
table_url,
table_title,
...rest
}) => {
const {
getState,
options: {
@@ -50,19 +50,19 @@ const DataTable_Paper = ({
style={{
...(isFullScreen
? {
bottom: 0,
height: "100dvh",
left: 0,
margin: 0,
maxHeight: "100dvh",
maxWidth: "100dvw",
padding: 0,
position: "fixed",
right: 0,
top: 0,
width: "100dvw",
zIndex: 999,
}
bottom: 0,
height: "100dvh",
left: 0,
margin: 0,
maxHeight: "100dvh",
maxWidth: "100dvw",
padding: 0,
position: "fixed",
right: 0,
top: 0,
width: "100dvw",
zIndex: 999,
}
: {}),
...paperProps?.style,
}}

View File

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

View File

@@ -5,4 +5,4 @@ const DialogTransition = React.forwardRef(function Transition(props, ref) {
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() {
return (
<Stack
sx={{ height: "100%" }}
alignItems={"center"}
justifyContent={"center"}
>
<Stack sx={{ height: "100%" }} alignItems={"center"} justifyContent={"center"}>
<Box sx={{ width: 200 }}>
<LinearProgress />
</Box>
@@ -14,4 +10,4 @@ function MapLoading() {
);
}
export default MapLoading;
export default MapLoading;

View File

@@ -1,7 +1,7 @@
"use client";
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 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 }) {
const { filterAction, sortAction, hideAction } = useTableSetting();
const filteredHideData = Object.fromEntries(
Object.entries(hideData).filter(([key, value]) => value === false),
);
const filteredHideData = Object.fromEntries(Object.entries(hideData).filter(([key, value]) => value === false));
const flattenHideData = flattenObjectOfObjects(filteredHideData);
@@ -53,19 +51,10 @@ function AskForKeepData({ filterData, sortData, hideData, user_id, page_name, ta
<Typography variant="caption">آیا مایل به ذخیره تغییر های اعمال شده برای دفعات بعد هستید؟</Typography>
</Box>
<Box sx={{ display: "flex", gap: 1, mt: 2 }}>
<Button
variant="contained"
size="small"
endIcon={<DownloadIcon />}
onClick={onSaveFilter}
>
<Button variant="contained" size="small" endIcon={<DownloadIcon />} onClick={onSaveFilter}>
ذخیره
</Button>
<Button
variant="outlined"
size="small"
onClick={handleDismiss}
>
<Button variant="outlined" size="small" onClick={handleDismiss}>
رد کردن
</Button>
</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 }) => {
return (
<Divider><Chip
label={<Typography fontSize={14} fontWeight={500}>{title}</Typography>} /></Divider>
<Divider>
<Chip
label={
<Typography fontSize={14} fontWeight={500}>
{title}
</Typography>
}
/>
</Divider>
);
};
export default PageTitle;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,4 +9,4 @@ export const flattenObjectOfObjects = (obj, 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) => {
if (!column.enableColumnFilter) return acc;
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") {
acc[column.id] = {
@@ -100,7 +100,7 @@ const DataTableProvider = ({ children, user_id, page_name, table_name, columns }
position: "bottom-left",
draggable: true,
autoClose: false,
},
}
);
} else {
toast.update("keep_data", {

View File

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

View File

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

View File

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