Merge branch 'release/v0.9.2'

This commit is contained in:
Amirhossein Mahmoodi
2024-11-19 11:23:20 +03:30
39 changed files with 977 additions and 1304 deletions

View File

@@ -1,3 +1,3 @@
NEXT_PUBLIC_VERSION="0.9.0"
NEXT_PUBLIC_VERSION="0.9.2"
NEXT_PUBLIC_API_URL="https://rms.witel.ir"
NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map"

2
.gitignore vendored
View File

@@ -33,4 +33,4 @@ cypress/screenshots
package-lock.json
ecosystem.config.js
packages*.tar.gz
/versions

View File

@@ -1,7 +1,7 @@
services:
app:
build: .
volumes:
- .:/var/www/app
- /var/www/app/node_modules
command: sh -c "cd /var/www/app && tar -czvf packages_$(date +%Y_%m_%d).tar.gz node_modules"
app:
build: .
volumes:
- .:/var/www/app
- /var/www/app/node_modules
command: sh -c "cd /var/www/app && tar -czvf rms_v3_$(date +%Y_%m_%d).tar.gz node_modules"

View File

@@ -1,7 +1,12 @@
import TestPage from "@/components/dashboard/azmayesh";
import AzmayeshPage from "@/components/dashboard/azmayesh";
import WithPermission from "@/core/middlewares/withPermission";
const Page = () => {
return <TestPage />;
return (
<WithPermission permission_name={["azmayesh-management"]}>
<AzmayeshPage />
</WithPermission>
);
};
export default Page;

View File

@@ -0,0 +1,12 @@
import AzmayeshTypePage from "@/components/dashboard/azmayeshType";
import WithPermission from "@/core/middlewares/withPermission";
const Page = () => {
return (
<WithPermission permission_name={["azmayesh-type-management"]}>
<AzmayeshTypePage />
</WithPermission>
);
};
export default Page;

View File

@@ -1,7 +0,0 @@
import InquiryPrivacyFencingPage from "@/components/dashboard/inquiryPrivacyFencing";
const Page = () => {
return <InquiryPrivacyFencingPage />;
};
export default Page;

View File

@@ -1,7 +1,12 @@
import AssistantZaminGovComponent from "@/components/dashboard/inquiryPrivacy/assistant/zaminGov";
import WithPermission from "@/core/middlewares/withPermission";
const Page = () => {
return <AssistantZaminGovComponent />;
return (
<WithPermission>
<AssistantZaminGovComponent />
</WithPermission>
);
};
export default Page;

View File

@@ -1,7 +1,12 @@
import CityAdminZaminGovComponent from "@/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov";
import WithPermission from "@/core/middlewares/withPermission";
const Page = () => {
return <CityAdminZaminGovComponent />;
return (
<WithPermission>
<CityAdminZaminGovComponent />
</WithPermission>
);
};
export default Page;

View File

@@ -1,7 +1,12 @@
import GeneralManagerZaminGovComponent from "@/components/dashboard/inquiryPrivacy/generalManager/zaminGov";
import WithPermission from "@/core/middlewares/withPermission";
const Page = () => {
return <GeneralManagerZaminGovComponent />;
return (
<WithPermission>
<GeneralManagerZaminGovComponent />
</WithPermission>
);
};
export default Page;

View File

@@ -1,7 +1,12 @@
import ProvinceAdminZaminGovComponent from "@/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov";
import WithPermission from "@/core/middlewares/withPermission";
const Page = () => {
return <ProvinceAdminZaminGovComponent />;
return (
<WithPermission>
<ProvinceAdminZaminGovComponent />
</WithPermission>
);
};
export default Page;

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="647.63626" height="632.17383" viewBox="0 0 647.63626 632.17383" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M687.3279,276.08691H512.81813a15.01828,15.01828,0,0,0-15,15v387.85l-2,.61005-42.81006,13.11a8.00676,8.00676,0,0,1-9.98974-5.31L315.678,271.39691a8.00313,8.00313,0,0,1,5.31006-9.99l65.97022-20.2,191.25-58.54,65.96972-20.2a7.98927,7.98927,0,0,1,9.99024,5.3l32.5498,106.32Z" transform="translate(-276.18187 -133.91309)" fill="#f2f2f2"/><path d="M725.408,274.08691l-39.23-128.14a16.99368,16.99368,0,0,0-21.23-11.28l-92.75,28.39L380.95827,221.60693l-92.75,28.4a17.0152,17.0152,0,0,0-11.28028,21.23l134.08008,437.93a17.02661,17.02661,0,0,0,16.26026,12.03,16.78926,16.78926,0,0,0,4.96972-.75l63.58008-19.46,2-.62v-2.09l-2,.61-64.16992,19.65a15.01489,15.01489,0,0,1-18.73-9.95l-134.06983-437.94a14.97935,14.97935,0,0,1,9.94971-18.73l92.75-28.4,191.24024-58.54,92.75-28.4a15.15551,15.15551,0,0,1,4.40966-.66,15.01461,15.01461,0,0,1,14.32032,10.61l39.0498,127.56.62012,2h2.08008Z" transform="translate(-276.18187 -133.91309)" fill="#3f3d56"/><path d="M398.86279,261.73389a9.0157,9.0157,0,0,1-8.61133-6.3667l-12.88037-42.07178a8.99884,8.99884,0,0,1,5.9712-11.24023l175.939-53.86377a9.00867,9.00867,0,0,1,11.24072,5.9707l12.88037,42.07227a9.01029,9.01029,0,0,1-5.9707,11.24072L401.49219,261.33887A8.976,8.976,0,0,1,398.86279,261.73389Z" transform="translate(-276.18187 -133.91309)" fill="#2070af"/><circle cx="190.15351" cy="24.95465" r="20" fill="#2070af"/><circle cx="190.15351" cy="24.95465" r="12.66462" fill="#fff"/><path d="M878.81836,716.08691h-338a8.50981,8.50981,0,0,1-8.5-8.5v-405a8.50951,8.50951,0,0,1,8.5-8.5h338a8.50982,8.50982,0,0,1,8.5,8.5v405A8.51013,8.51013,0,0,1,878.81836,716.08691Z" transform="translate(-276.18187 -133.91309)" fill="#e6e6e6"/><path d="M723.31813,274.08691h-210.5a17.02411,17.02411,0,0,0-17,17v407.8l2-.61v-407.19a15.01828,15.01828,0,0,1,15-15H723.93825Zm183.5,0h-394a17.02411,17.02411,0,0,0-17,17v458a17.0241,17.0241,0,0,0,17,17h394a17.0241,17.0241,0,0,0,17-17v-458A17.02411,17.02411,0,0,0,906.81813,274.08691Zm15,475a15.01828,15.01828,0,0,1-15,15h-394a15.01828,15.01828,0,0,1-15-15v-458a15.01828,15.01828,0,0,1,15-15h394a15.01828,15.01828,0,0,1,15,15Z" transform="translate(-276.18187 -133.91309)" fill="#3f3d56"/><path d="M801.81836,318.08691h-184a9.01015,9.01015,0,0,1-9-9v-44a9.01016,9.01016,0,0,1,9-9h184a9.01016,9.01016,0,0,1,9,9v44A9.01015,9.01015,0,0,1,801.81836,318.08691Z" transform="translate(-276.18187 -133.91309)" fill="#2070af"/><circle cx="433.63626" cy="105.17383" r="20" fill="#2070af"/><circle cx="433.63626" cy="105.17383" r="12.18187" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -18,7 +18,7 @@ const AzmayeshCreate = ({ mutate }) => {
return (
<>
{isMobile ? (
<IconButton aria-label="ایجاد آزمایش جدید" color="primary" onClick={handleOpen}>
<IconButton aria-label="ثبت آزمایش جدید" color="primary" onClick={handleOpen}>
<AddCircle sx={{ fontSize: "25px" }} />
</IconButton>
) : (

View File

@@ -127,7 +127,7 @@ const AzmayeshList = () => {
<>
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
<DataTableWithAuth
table_title={"لیست آزمایش ها"}
table_title={"لیست آزمایشات"}
need_filter={false}
columns={columns}
table_url={GET_AZMAYESH_LIST}

View File

@@ -4,7 +4,7 @@ import PageTitle from "@/core/components/PageTitle";
import { Stack } from "@mui/material";
import AzmayeshList from "./AzmayeshList";
const TestPage = () => {
const AzmayeshPage = () => {
return (
<Stack spacing={1}>
<PageTitle title={"آزمایشات"} />
@@ -12,4 +12,4 @@ const TestPage = () => {
</Stack>
);
};
export default TestPage;
export default AzmayeshPage;

View File

@@ -0,0 +1,33 @@
"use client";
import { Button, IconButton, useMediaQuery } from "@mui/material";
import { useTheme } from "@emotion/react";
import { useState } from "react";
import { AddCircle } from "@mui/icons-material";
import CandUAzmayeshType from "@/components/dashboard/azmayeshType/Forms/CandUAzmayeshType";
const AzmayeshTypeCreate = ({ mutate }) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const [open, setOpen] = useState(false);
const handleOpen = () => {
setOpen(true);
};
return (
<>
{isMobile ? (
<IconButton aria-label="ثبت نوع آزمایش جدید" color="primary" onClick={handleOpen}>
<AddCircle sx={{ fontSize: "25px" }} />
</IconButton>
) : (
<Button variant="contained" color="primary" startIcon={<AddCircle />} onClick={handleOpen}>
ثبت نوع آزمایش
</Button>
)}
{open && <CandUAzmayeshType open={open} setOpen={setOpen} mutate={mutate} />}
</>
);
};
export default AzmayeshTypeCreate;

View File

@@ -0,0 +1,65 @@
"use client";
import { useMemo } from "react";
import { Box, Typography } from "@mui/material";
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
import Toolbar from "./Toolbar";
import { GET_AZMAYESH_TYPE_LIST_TABLE } from "@/core/utils/routes";
import moment from "jalali-moment";
import RowActions from "./RowActions";
const AzmayeshTypeList = () => {
const columns = useMemo(
() => [
{
accessorKey: "id",
header: "کد یکتا",
id: "id",
enableColumnFilter: false,
datatype: "text",
filterFn: "notEquals",
},
{
accessorKey: "name",
header: "عنوان",
id: "name",
enableColumnFilter: false,
datatype: "text",
filterFn: "notEquals",
},
{
accessorKey: "created_at",
header: "تاریخ ثبت",
id: "created_at",
enableColumnFilter: false,
datatype: "date",
filterFn: "equals",
Cell: ({ renderedCellValue }) => (
<Typography variant="body2">
{renderedCellValue ? moment(renderedCellValue).locale("fa").format("HH:mm | YYYY/MM/DD") : "-"}
</Typography>
),
},
],
[]
);
return (
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
<DataTableWithAuth
table_title={"لیست انواع آزمایشات"}
need_filter={false}
columns={columns}
sorting={[{ id: "id", desc: true }]}
table_url={GET_AZMAYESH_TYPE_LIST_TABLE}
page_name={"azmayesh_type"}
table_name={"azmayeshTypeList"}
TableToolbar={Toolbar}
enableRowActions
positionActionsColumn={"last"}
RowActions={RowActions}
/>
</Box>
);
};
export default AzmayeshTypeList;

View File

@@ -0,0 +1,181 @@
"use client";
import React, { useEffect, useState } from "react";
import {
Button,
Chip,
FormControl,
FormHelperText,
Grid,
InputAdornment,
InputLabel,
MenuItem,
OutlinedInput,
Select,
Typography,
} from "@mui/material";
import ExtensionIcon from "@mui/icons-material/Extension";
import SelectItemBox from "@/components/dashboard/azmayeshType/Forms/CandUAzmayeshType/SelectItemBox";
import KeyboardIcon from "@mui/icons-material/Keyboard";
import TextFieldsIcon from "@mui/icons-material/TextFields";
import ViewListIcon from "@mui/icons-material/ViewList";
import CalendarMonthIcon from "@mui/icons-material/CalendarMonth";
const fieldTypeList = [
{ value: "input", label: "متن", icon: <TextFieldsIcon /> },
{ value: "select", label: "انتخابی", icon: <ViewListIcon /> },
{ value: "date", label: "تاریخ", icon: <CalendarMonthIcon /> },
];
const AzmayeshFields = ({ errors, selectedListItem, register, setValue, fields, watch }) => {
const watchedFields = watch("fields");
const [isSelectType, setIsSelectType] = useState(false);
const [openSelectItem, setOpenSelectItem] = useState(false);
const [typeIcon, setTypeIcon] = useState(<KeyboardIcon />);
useEffect(() => {
const selectedIcon = fieldTypeList.find((option) => option.value === watchedFields?.[selectedListItem]?.type)
?.icon || <KeyboardIcon />;
setTypeIcon(selectedIcon);
setIsSelectType(watchedFields[selectedListItem]?.type === "select");
}, [watchedFields, selectedListItem]);
return (
<Grid container>
<Grid xs={12} sm={6} sx={{ px: { xs: 0, sm: 1 }, py: 1 }}>
<FormControl
error={!!errors.fields?.[selectedListItem]?.type}
size="small"
fullWidth
variant="outlined"
>
<InputLabel htmlFor={`fields.${selectedListItem}.type`}>نوع</InputLabel>
<Select
id={`fields.${selectedListItem}.type`}
label="نوع"
autoComplete="off"
{...register(`fields.${selectedListItem}.type`)}
size="small"
fullWidth
value={watchedFields?.[selectedListItem]?.type || ""}
onChange={(event) => {
const selectedValue = event.target.value;
const selectedIcon = fieldTypeList.find((option) => option.value === selectedValue)
?.icon || <KeyboardIcon />;
setValue(`fields.${selectedListItem}.type`, selectedValue);
setIsSelectType(selectedValue === "select");
setTypeIcon(selectedIcon);
}}
startAdornment={<InputAdornment position="start">{typeIcon}</InputAdornment>}
>
<MenuItem value="">نوع</MenuItem>
{fieldTypeList.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</Select>
<FormHelperText>{errors.fields?.[selectedListItem]?.type?.message}</FormHelperText>
</FormControl>
</Grid>
{isSelectType && (
<Grid
xs={12}
sm={6}
sx={{
px: { xs: 0, sm: 1 },
py: 1,
mb: 0.5,
display: "flex",
flexDirection: "column",
alignItems: "start",
justifyContent: "space-around",
position: "relative",
}}
>
<Chip
sx={{
position: "absolute",
top: "-6px",
right: "-6px",
zIndex: "1",
}}
color="error"
label={watchedFields?.[selectedListItem].options.length}
/>
<Button
variant="outlined"
color="success"
sx={{ width: "100%", height: "37px" }}
startIcon={<ExtensionIcon />}
onClick={() => setOpenSelectItem(true)}
>
افزودن آیتم نوع انتخابی
</Button>
<Typography variant="caption" color="error">
{errors.fields?.[selectedListItem]?.options?.message}
</Typography>
{openSelectItem && (
<SelectItemBox
open={openSelectItem}
setOpen={setOpenSelectItem}
fields={fields}
setValue={setValue}
index={selectedListItem}
watch={watch}
/>
)}
</Grid>
)}
<Grid xs={12} sm={6} sx={{ px: { xs: 0, sm: 1 }, py: 1 }}>
<FormControl
error={!!errors.fields?.[selectedListItem]?.name}
size="small"
fullWidth
variant="outlined"
>
<InputLabel htmlFor={`fields[${selectedListItem}].name`}>نام فیلد</InputLabel>
<OutlinedInput
id={`fields[${selectedListItem}].name`}
label="نام فیلد"
autoComplete="off"
{...register(`fields[${selectedListItem}].name`)}
value={watchedFields?.[selectedListItem]?.name || ""}
onInput={(event) => setValue(`fields.${selectedListItem}.name`, event.target.value)}
size="small"
fullWidth
type="text"
/>
<FormHelperText>
{errors.fields?.[selectedListItem]?.name ? errors.fields[selectedListItem].name.message : null}
</FormHelperText>
</FormControl>
</Grid>
<Grid xs={12} sm={6} sx={{ px: { xs: 0, sm: 1 }, py: 1 }}>
<FormControl
error={!!errors.fields?.[selectedListItem]?.unit}
size="small"
fullWidth
variant="outlined"
>
<InputLabel htmlFor={`fields[${selectedListItem}].unit`}>واحد اندازه گیری</InputLabel>
<OutlinedInput
id={`fields[${selectedListItem}].unit`}
label="واحد اندازه گیری"
autoComplete="off"
{...register(`fields[${selectedListItem}].unit`)}
value={watchedFields?.[selectedListItem]?.unit || ""}
onChange={(event) => setValue(`fields.${selectedListItem}.unit`, event.target.value)}
size="small"
fullWidth
type="text"
/>
<FormHelperText>
{errors.fields?.[selectedListItem]?.unit ? errors.fields[selectedListItem].unit.message : null}
</FormHelperText>
</FormControl>
</Grid>
</Grid>
);
};
export default AzmayeshFields;

View File

@@ -0,0 +1,77 @@
"use client";
import { Box, IconButton, ListItem, Stack, Typography } from "@mui/material";
import React from "react";
import DeleteIcon from "@mui/icons-material/Delete";
import SettingsIcon from "@mui/icons-material/Settings";
import TextFieldsIcon from "@mui/icons-material/TextFields";
import ViewListIcon from "@mui/icons-material/ViewList";
import CalendarMonthIcon from "@mui/icons-material/CalendarMonth";
const fieldsType = {
input: "متن",
date: "تاریخ",
select: "انتخابی",
};
const fieldsTypeIcon = {
input: <TextFieldsIcon sx={{ fontSize: "18px" }} />,
date: <CalendarMonthIcon sx={{ fontSize: "18px" }} />,
select: <ViewListIcon sx={{ fontSize: "18px" }} />,
};
const ListItems = ({ index, handleRemove, selectedListItem, setSelectedListItem, watch }) => {
const watchedFields = watch("fields");
return (
<ListItem
sx={{
transition: "all 0.3s",
boxShadow:
selectedListItem === index
? "rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px"
: "rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px",
borderRadius: 2,
mb: 1.5,
px: 1,
py: 0.7,
backgroundColor: selectedListItem === index ? "#6ea1714d" : "#ebebeb7a",
"&:last-child": {
mb: 0,
},
}}
disablePadding
secondaryAction={
<Box sx={{ display: "flex", alignItems: "center" }}>
<IconButton
edge="start"
aria-label="edit"
color="primary"
onClick={() => setSelectedListItem(index)}
>
<SettingsIcon />
</IconButton>
<IconButton edge="end" aria-label="delete" color="error" onClick={() => handleRemove(index)}>
<DeleteIcon />
</IconButton>
</Box>
}
>
<Stack sx={{ width: "100%" }}>
<Typography
sx={{ color: watchedFields[index].name !== "" ? "" : "error.main" }}
variant="body1"
fontWeight={500}
noWrap
>
{watchedFields[index].name !== "" ? watchedFields[index].name : "نام تعیین نشده"}
</Typography>
<Box sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
{fieldsTypeIcon[watchedFields[index].type] || null}
<Typography sx={{ color: watchedFields[index].type !== "" ? "" : "error.main" }} variant="caption">
{watchedFields[index].type !== "" ? fieldsType[watchedFields[index].type] : "واحد تعیین نشده"}
</Typography>
</Box>
</Stack>
</ListItem>
);
};
export default ListItems;

View File

@@ -0,0 +1,108 @@
import {
Box,
Button,
Chip,
Dialog,
DialogActions,
DialogContent,
Divider,
IconButton,
List,
ListItem,
ListItemText,
TextField,
Typography,
} from "@mui/material";
import DeleteIcon from "@mui/icons-material/Delete";
import React, { useState } from "react";
const SelectItemBox = ({ open, setOpen, setValue, index, watch }) => {
const watchedFields = watch("fields");
const [itemValue, setItemValue] = useState("");
const [listArr, setListArr] = useState(watchedFields?.[index]?.options);
const addToList = () => {
if (itemValue) {
setListArr([...listArr, itemValue]);
setItemValue("");
}
};
const removeFromList = (index) => {
setListArr(listArr.filter((_, i) => i !== index));
};
const saveAndCloseList = () => {
setValue(`fields.${index}.options`, listArr);
closeModal();
};
const closeModal = () => {
setOpen(false);
};
return (
<Dialog open={open} fullWidth={true} maxWidth={"xs"} onClose={closeModal}>
<DialogContent>
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "center", gap: 2 }}>
<TextField
fullWidth
size="small"
id="outlined-controlled"
label="نام آیتم را وارد کنید"
value={itemValue}
onChange={(event) => {
setItemValue(event.target.value);
}}
/>
<Button variant="contained" color="primary" disabled={!itemValue} onClick={addToList}>
افزودن
</Button>
</Box>
<Box sx={{ borderRadius: "5px", mt: 2 }}>
<Divider>
<Chip label="لیست آیتم ها" />
</Divider>
<List>
{listArr.length !== 0 ? (
listArr.map((item, index) => (
<ListItem
key={index}
sx={{
boxShadow:
"rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 1px 3px 1px",
my: 1,
borderRadius: "5px",
}}
secondaryAction={
<IconButton
edge="end"
aria-label="delete"
color="error"
onClick={() => removeFromList(index)}
>
<DeleteIcon />
</IconButton>
}
>
<ListItemText primary={item} />
</ListItem>
))
) : (
<Typography variant="h6" sx={{ textAlign: "center", letterSpacing: "1px" }}>
هنوز آیتمی ثبت نشده است
</Typography>
)}
</List>
</Box>
</DialogContent>
<DialogActions>
<Button variant="outlined" color="primary" onClick={saveAndCloseList}>
ذخیره لیست
</Button>
</DialogActions>
</Dialog>
);
};
export default SelectItemBox;

View File

@@ -0,0 +1,224 @@
import {
Box,
Button,
Chip,
Dialog,
DialogActions,
DialogContent,
Divider,
FormControl,
FormHelperText,
Grid,
InputLabel,
List,
OutlinedInput,
Typography,
} from "@mui/material";
import StyledForm from "@/core/components/StyledForm";
import useRequest from "@/lib/hooks/useRequest";
import { useState } from "react";
import { useFieldArray, useForm } from "react-hook-form";
import { array, object, string } from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
import ListItems from "./ListItems";
import AzmayeshFields from "./AzmayeshFields";
import { ADD_AZMAYESH_TYPE, UPDATE_AZMAYESH_TYPE } from "@/core/utils/routes";
const validationSchema = object({
name: string().required("عنوان نوع آزمایش را مشخص کنید!"),
fields: array()
.of(
object({
name: string().required("نام فیلد الزامی است"),
type: string().required("نوع فیلد الزامی است"),
options: array().when("type", {
is: "select",
then: (schema) => schema.min(1, "حداقل باید یک آیتم برای نوع انتخابی ایجاد کنید."),
otherwise: (schema) => schema.notRequired(),
}),
})
)
.min(1, "حداقل باید یک فیلد ایجاد نمایید."),
});
const CandUAzmayeshType = ({ open, setOpen, mutate, rowId, updateInfo }) => {
const requestServer = useRequest({ auth: true });
const [selectedListItem, setSelectedListItem] = useState(null);
const [isSubmitting, setIsSubmitting] = useState(false);
const handleClose = () => {
setOpen(false);
};
const defaultValues = {
name: updateInfo?.name || "",
fields: Array.isArray(updateInfo?.azmayesh_fields)
? updateInfo.azmayesh_fields.map((field) => ({
name: field.name || "",
type: field.type || "",
unit: field.unit || "",
options: field.option ? field.option : [],
}))
: [],
};
const {
control,
register,
handleSubmit,
setValue,
watch,
formState: { errors },
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur" });
const { fields, append, remove } = useFieldArray({
control,
name: "fields",
});
const handleRemove = (index) => {
remove(index);
if (selectedListItem === index) {
setSelectedListItem(null);
} else if (selectedListItem > index) {
setSelectedListItem((prev) => prev - 1);
}
};
const handleAddField = () => {
append({ name: "", type: "", unit: "", options: [] });
};
const onSubmit = async (data) => {
setIsSubmitting(true);
const formData = new FormData();
formData.append("name", data.name);
data.fields.map((field, index) => {
formData.append(`fields[${index}][name]`, field.name);
formData.append(`fields[${index}][unit]`, field.unit);
formData.append(`fields[${index}][type]`, field.type);
if (field.options.length !== 0) formData.append(`fields[${index}][option]`, JSON.stringify(field.options));
});
requestServer(updateInfo ? `${UPDATE_AZMAYESH_TYPE}/${rowId}` : ADD_AZMAYESH_TYPE, "post", {
data: formData,
})
.then(() => {
mutate();
handleClose();
})
.catch(() => {})
.finally(() => setIsSubmitting(false));
};
return (
<Dialog open={open} fullWidth={true} maxWidth={"lg"}>
<StyledForm onSubmit={handleSubmit(onSubmit)}>
<DialogContent dividers>
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "center", my: 2 }}>
<FormControl error={!!errors.name} size="small" variant="outlined" sx={{ width: "250px" }}>
<InputLabel htmlFor="name">عنوان نوع آزمایش</InputLabel>
<OutlinedInput
id="name"
label={"عنوان نوع آزمایش"}
autoComplete="off"
{...register("name")}
size="small"
type="text"
/>
<FormHelperText id="name">{errors.name ? errors.name.message : null}</FormHelperText>
</FormControl>
</Box>
<Grid container spacing={2} sx={{ justifyContent: "space-between" }}>
<Grid xs={12} md={4} lg={3} sx={{ px: 1 }}>
<Divider sx={{ my: 2 }}>
<Chip label="لیست فیلد ها" />
</Divider>
<Button
variant="contained"
color="success"
fullWidth
startIcon={<DataSaverOnIcon />}
sx={{ mb: 2 }}
onClick={handleAddField}
>
ایجاد فیلد جدید
</Button>
<List
sx={{
border: "1px dashed #e1e1e1",
borderRadius: "5px",
p: 1,
maxHeight: "300px",
overflowY: "auto",
}}
>
{fields.length !== 0 ? (
fields.map((item, index) => (
<ListItems
key={index}
index={index}
selectedListItem={selectedListItem}
fields={fields}
handleRemove={handleRemove}
setSelectedListItem={setSelectedListItem}
watch={watch}
/>
))
) : (
<Typography
variant="h6"
sx={{ color: "#a2a2a2", textAlign: "center", letterSpacing: "1px" }}
>
فیلدی وجود ندارد
</Typography>
)}
</List>
<Typography variant="caption" color="error">
{errors.fields ? errors.fields.message : null}
</Typography>
</Grid>
<Divider orientation="vertical" variant="middle" flexItem />
<Grid xs={12} md={7} lg={8} sx={{ pl: 2 }}>
<Divider sx={{ my: 2 }}>
<Chip label="اطلاعات فیلد" />
</Divider>
{selectedListItem !== null ? (
<AzmayeshFields
errors={errors}
selectedListItem={selectedListItem}
register={register}
setValue={setValue}
fields={fields}
watch={watch}
/>
) : (
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "center", py: 2 }}>
<Typography variant="h6" sx={{ letterSpacing: "2px", color: "#a2a2a2" }}>
از بخش لیست فیلد ها یک آیتم را انتخاب نمایید
</Typography>
</Box>
)}
</Grid>
</Grid>
</DialogContent>
<DialogActions sx={{ alignItems: "center", justifyContent: "center", py: 2 }}>
<Button variant="outlined" color="error" onClick={handleClose}>
بستن
</Button>
<Button
type={"submit"}
variant="contained"
color="primary"
disabled={isSubmitting}
sx={{ width: "200px" }}
>
{isSubmitting ? "در حال ثبت..." : "ثبت نوع آزمایش"}
</Button>
</DialogActions>
</StyledForm>
</Dialog>
);
};
export default CandUAzmayeshType;

View File

@@ -0,0 +1,78 @@
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
IconButton,
Tooltip,
Typography,
} from "@mui/material";
import DeleteIcon from "@mui/icons-material/Delete";
import useRequest from "@/lib/hooks/useRequest";
import { useState } from "react";
import { DELETE_AZMAYESH_TYPE_LIST } from "@/core/utils/routes";
const DeleteAzmayeshType = ({ rowId, mutate }) => {
const requestServer = useRequest({ auth: true });
const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const handleSubmit = () => {
setIsSubmitting(true);
requestServer(`${DELETE_AZMAYESH_TYPE_LIST}/${rowId}`, "post")
.then(() => {
setOpenDeleteDialog(false);
mutate();
})
.catch(() => {})
.finally(() => {
setIsSubmitting(false);
});
};
return (
<>
<Tooltip title="حذف نوع آزمایش" arrow placement="right">
<IconButton
color="error"
sx={{ textTransform: "unset", alignSelf: "center" }}
onClick={() => {
setOpenDeleteDialog(true);
}}
>
<DeleteIcon />
</IconButton>
</Tooltip>
<Dialog
maxWidth="sm"
open={openDeleteDialog}
PaperProps={{
sx: {
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
},
}}
>
<DialogTitle>حذف نوع آزمایش</DialogTitle>
<DialogContent>
<Typography>آیا از حذف این نوع آزمایش مطمئن هستید؟</Typography>
</DialogContent>
<DialogActions>
<Button
onClick={() => setOpenDeleteDialog(false)}
variant="outlined"
color="primary"
disabled={isSubmitting}
autoFocus
>
بستن
</Button>
<Button onClick={handleSubmit} variant="contained" color="error" disabled={isSubmitting}>
حذف
</Button>
</DialogActions>
</Dialog>
</>
);
};
export default DeleteAzmayeshType;

View File

@@ -0,0 +1,48 @@
import { IconButton, Tooltip } from "@mui/material";
import EditIcon from "@mui/icons-material/Edit";
import { GET_AZMAYESH_TYPE_LIST_TABLE } from "@/core/utils/routes";
import { useState } from "react";
import useRequest from "@/lib/hooks/useRequest";
import CandUAzmayeshType from "@/components/dashboard/azmayeshType/Forms/CandUAzmayeshType";
const UpdateAzmayeshType = ({ rowId, mutate }) => {
const requestServer = useRequest({ auth: true });
const [openUpdateDialog, setOpenUpdateDialog] = useState(false);
const [updateInfo, setUpdateInfo] = useState(null);
const handleGetInfo = () => {
requestServer(`${GET_AZMAYESH_TYPE_LIST_TABLE}/${rowId}`, "get")
.then((response) => {
setUpdateInfo(response.data.data);
})
.catch(() => {})
.finally(() => {
setOpenUpdateDialog(true);
});
};
return (
<>
<Tooltip title="ویرایش آزمایش" arrow placement="right">
<IconButton
color="success"
sx={{ textTransform: "unset", alignSelf: "center" }}
onClick={handleGetInfo}
>
<EditIcon />
</IconButton>
</Tooltip>
{openUpdateDialog && (
<CandUAzmayeshType
open={openUpdateDialog}
setOpen={setOpenUpdateDialog}
mutate={mutate}
updateInfo={updateInfo}
rowId={rowId}
/>
)}
</>
);
};
export default UpdateAzmayeshType;

View File

@@ -0,0 +1,13 @@
import { Box } from "@mui/material";
import UpdateAzmayeshType from "./UpdateAzmayeshType";
import DeleteAzmayeshType from "./DeleteAzmayeshType";
const RowActions = ({ row, mutate }) => {
return (
<Box sx={{ display: "flex", gap: 1 }}>
<UpdateAzmayeshType rowId={row.getValue("id")} mutate={mutate} />
<DeleteAzmayeshType rowId={row.getValue("id")} mutate={mutate} />
</Box>
);
};
export default RowActions;

View File

@@ -0,0 +1,10 @@
import AzmayeshTypeCreate from "./Actions/Create";
const Toolbar = ({ mutate }) => {
return (
<>
<AzmayeshTypeCreate mutate={mutate} />
</>
);
};
export default Toolbar;

View File

@@ -0,0 +1,15 @@
"use client";
import PageTitle from "@/core/components/PageTitle";
import { Stack } from "@mui/material";
import AzmayeshTypeList from "./AzmayeshTypeList";
const AzmayeshTypePage = () => {
return (
<Stack spacing={1}>
<PageTitle title={"نوع آزمایشات"} />
<AzmayeshTypeList />
</Stack>
);
};
export default AzmayeshTypePage;

View File

@@ -1,55 +0,0 @@
"use client";
import DialogTransition from "@/core/components/DialogTransition";
import { AddCircle, Close } from "@mui/icons-material";
import { Button, Dialog, DialogTitle, IconButton, useMediaQuery } from "@mui/material";
import CreateOrUpdateForm from "../../Forms/CreateOrUpdate";
import { SET_INQUIRE_PRIVACY_FENCING } from "@/core/utils/routes";
import { useState } from "react";
import { useTheme } from "@emotion/react";
const InquiryPrivacyFencingCreate = ({ mutate }) => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const [open, setOpen] = useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
return (
<>
{isMobile ? (
<IconButton aria-label="ایجاد پاسخ به استعلام" color="primary" onClick={handleOpen}>
<AddCircle sx={{ fontSize: "25px" }} />
</IconButton>
) : (
<Button variant="contained" color="primary" startIcon={<AddCircle />} onClick={handleOpen}>
ایجاد پاسخ به استعلام
</Button>
)}
<Dialog open={open} fullScreen TransitionComponent={DialogTransition}>
<DialogTitle sx={{ m: 0, p: 2, borderBottom: 1, borderColor: "divider" }} id="create-dialog">
ایجاد پاسخ به استعلام
</DialogTitle>
<IconButton
aria-label="close"
onClick={handleClose}
sx={{
position: "absolute",
right: 8,
top: 8,
color: (theme) => theme.palette.grey[500],
}}
>
<Close />
</IconButton>
<CreateOrUpdateForm handleClose={handleClose} mutate={mutate} url={SET_INQUIRE_PRIVACY_FENCING} />
</Dialog>
</>
);
};
export default InquiryPrivacyFencingCreate;

View File

@@ -1,869 +0,0 @@
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 { DatePicker, LocalizationProvider, faIR } from "@mui/x-date-pickers";
import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali";
import moment from "jalali-moment";
import { Controller, useForm } from "react-hook-form";
import LocationOnMap from "./LocationOnMap";
const initValues = {
dabirkhaneh_number: "",
nameh_date: moment(),
nameh_date_fa: "",
marjae_pasokh: "",
motaghazi_is_legal_id: null,
motaghazi_is_legal: "",
motaghazi_type_id: "",
motaghazi_type: null,
motaghazi_firstname: "",
motaghazi_lastname: "",
national_id: "",
shenase_melli: "",
tel_number: "",
mobile_number: "",
address: "",
edare_kol_id: null,
edare_kol: "",
edare_shahri_id: null,
edare_shahri: "",
rah_type_id: null,
rah_type: "",
name_mehvar_id: "",
name_mehvar_fa: null,
mizan_harim: null,
arze_navar: null,
samt_id: null,
samt: "",
kilometr: "",
lat: "",
lon: "",
zone: null,
karbari_type_id: null,
karbari_type: "",
tarh_title: "",
masahat_zirbana: "",
ehdasat_type_id: [],
ehdasat_type: "",
divarkeshi_distance: "",
mostahadesat_distance: "",
mahale_ejra_id: null,
mahale_ejra: "",
traffic_id: null,
traffic: "",
vaziat_eghtesadi_id: null,
vaziat_eghtesadi: "",
has_access_id: null,
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 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);
try {
await request(url, "post", { data: formData });
handleClose();
mutate();
} catch (error) {}
};
return (
<LocalizationProvider
dateAdapter={AdapterDateFnsJalali}
localeText={faIR.components.MuiLocalizationProvider.defaultProps.localeText}
>
<DialogContent>
<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"
/>
</Grid>
<Grid item xs={1}>
<Controller
name="nameh_date"
control={control}
render={({ field: { onChange, value } }) => (
<DatePicker
value={value.toDate()}
onChange={(newValue) => onChange(moment(newValue))}
label="تاریخ نامه درخواست *"
slotProps={{
textField: { fullWidth: true, size: "small", autoComplete: "off" },
}}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<TextField
autoComplete="off"
{...register("marjae_pasokh")}
label="مرجع درخواست کننده پاسخ به استعلام"
size="small"
fullWidth
/>
</Grid>
<Grid item xs={1}>
<Controller
name="motaghazi_is_legal_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["حقوقی", "حقیقی"]}
renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="متقاضی *" />
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Fade
in={watch("motaghazi_is_legal_id") === "حقوقی"}
mountOnEnter={true}
unmountOnExit={true}
>
<Box>
<Controller
name="motaghazi_type"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["دولتی", "خصوصی"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نوع متقاضی *"
/>
)}
/>
)}
/>
</Box>
</Fade>
</Grid>
<Grid item xs={1}></Grid>
<Grid item xs={1}>
<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>
</Grid>
<Grid item xs={1}>
<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"
/>
</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>
</Grid>
<Grid item xs={1}>
<TextField
autoComplete="off"
{...register("address")}
label="آدرس *"
size="small"
fullWidth
/>
</Grid>
<Grid item xs={1}>
<Controller
name="edare_kol_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["تهران"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="اداره كل راهداری و حمل و نقل جاده ای *"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="edare_shahri_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["تهران"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="اداره شهرستان *"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="rah_type_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["آزاد راه", "بزرگراه", "راه فرعی درجه 3"]}
renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="نوع راه *" />
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="name_mehvar_fa"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["سایر"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نام محور *"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Fade in={watch("name_mehvar_fa") === "سایر"} mountOnEnter={true} unmountOnExit={true}>
<TextField autoComplete="off" label="سایر محورها" size="small" fullWidth />
</Fade>
</Grid>
<Grid item xs={1}>
<Controller
name="samt_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["چپ", "راست"]}
renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="سمت *" />
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="mizan_harim"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["12.5", "17.5"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="میزان حریم *"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Fade
in={watch("rah_type_id") !== "راه فرعی درجه 3"}
mountOnEnter={true}
unmountOnExit={true}
>
<Box>
<Controller
name="arze_navar"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["15", "30"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="عرض نوار تاسیساتی زیربنایی *"
/>
)}
/>
)}
/>
</Box>
</Fade>
</Grid>
<Grid item xs={1}>
<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
/>
</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}
/>
<Controller
name="zone"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["38", "39"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="Zone *"
/>
)}
/>
)}
/>
</Stack>
</Grid>
<Grid item xs={1}>
<Controller
name="karbari_type_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["اتاقک نگهبانی", "دولتی"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="نوع کاربری *"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<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>,
}}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="ehdasat_type_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
multiple
size="small"
disablePortal
value={value}
onChange={(event, 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}
/>
);
})
}
options={["تعمیرات", "احداث بنا"]}
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>,
}}
/>
</Grid>
<Grid item xs={1}>
<LtrTextField
autoComplete="off"
{...register("mostahadesat_distance")}
label="فاصله مستحدثات از آکس محور"
size="small"
fullWidth
type="tel"
InputProps={{
endAdornment: <InputAdornment position="end">متر</InputAdornment>,
}}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="mahale_ejra_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["داخل حریم"]}
renderInput={(params) => (
<TextField autoComplete="off" fullWidth {...params} label="محل اجرا" />
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="traffic_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["سبک (ضریب ۱)"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="میزان ترافیک *"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="vaziat_eghtesadi_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["تست"]}
renderInput={(params) => (
<TextField
autoComplete="off"
fullWidth
{...params}
label="وضعیت اقتصادی"
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={1}>
<Controller
name="has_access_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
size="small"
disablePortal
value={value}
onChange={(event, newValue) => {
onChange(newValue);
}}
options={["بله", "خیر"]}
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"
/>
</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>
</Grid>
<Grid item xs={1}>
<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"
/>
</Grid>
<Grid item xs={1}></Grid>
<Grid item xs={1}>
<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
/>
</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>
</LocalizationProvider>
);
};
export default CreateOrUpdateForm;

View File

@@ -1,37 +0,0 @@
import { useRef } from "react";
import { Marker, useMapEvents } from "react-leaflet";
import LocationMarker from "@/assets/images/locationMarker.png";
const locationMarker = L.icon({
iconUrl: LocationMarker.src,
iconSize: [50, 50],
iconAnchor: [25, 50],
});
const MarkerLocation = ({ setValue, defaultLatLon }) => {
const location = useRef();
const map = useMapEvents({
move: (e) => {
const latlon = e.target.getCenter();
location.current?.setLatLng(latlon);
setValue("lat", latlon.lat);
setValue("lon", latlon.lng);
},
zoom: (e) => {
const latlon = e.target.getCenter();
location.current?.setLatLng(latlon);
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;

View File

@@ -1,22 +0,0 @@
import MapLoading from "@/core/components/MapLayer/Loading";
import { Paper, Stack } from "@mui/material";
import dynamic from "next/dynamic";
import MarkerLocation from "./MarkerLocation";
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
loading: () => <MapLoading />,
ssr: false,
});
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" }}>
<MarkerLocation setValue={setValue} defaultLatLon={defaultLatLon} />
</MapLayer>
</Paper>
</Stack>
);
};
export default LocationOnMap;

View File

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

View File

@@ -1,15 +0,0 @@
"use client";
import PageTitle from "@/core/components/PageTitle";
import InquiryPrivacyFencingList from "./inquiryPrivacyFencingList";
import { Stack } from "@mui/material";
const InquiryPrivacyFencingPage = () => {
return (
<Stack spacing={1}>
<PageTitle title={"احداث و بهره برداری دیوارکشی و مستحدثات"} />
<InquiryPrivacyFencingList />
</Stack>
);
};
export default InquiryPrivacyFencingPage;

View File

@@ -1,254 +0,0 @@
"use client";
import { useMemo } from "react";
import Toolbar from "@/components/dashboard/inquiryPrivacyFencing/Toolbar";
import DataTable from "@/core/components/DataTable";
import { GET_INQUIRY_PRIVACY_FENCING_ROUTE } from "@/core/utils/routes";
import { Box } from "@mui/material";
import PageTitle from "@/core/components/PageTitle";
const InquiryPrivacyFencingList = () => {
const columns = useMemo(
() => [
{
accessorKey: "dabirkhaneh_number",
header: "شماره دبیرخانه درخواست",
id: "dabirkhaneh_number",
enableColumnFilter: false,
datatype: "text",
filterFn: "notEquals",
},
{
accessorKey: "marjae_pasokh",
header: "مرجع درخواست کننده پاسخ به استعلام",
id: "marjae_pasokh",
enableColumnFilter: false,
datatype: "text",
filterFn: "equals",
},
{
accessorKey: "motaghazi_is_legal",
header: "متقاضی",
id: "motaghazi_is_legal",
enableColumnFilter: false,
},
{
accessorKey: "nameh_date",
header: "تاریخ نامه درخواست",
id: "nameh_date",
enableColumnFilter: false,
},
{
accessorKey: "motaghazi_type",
header: "نوع متقاضی",
id: "motaghazi_type",
enableColumnFilter: false,
},
{
accessorKey: "motaghazi_firstname",
header: "نام متقاضی",
id: "motaghazi_firstname",
enableColumnFilter: false,
},
{
accessorKey: "motaghazi_lastname",
header: "نام خانوادگی متقاضی",
id: "motaghazi_lastname",
enableColumnFilter: false,
},
{
accessorKey: "national_id",
header: "کد ملی/شناسه ملی",
id: "national_id",
enableColumnFilter: false,
},
{
accessorKey: "tel_number",
header: "تلفن",
id: "tel_number",
enableColumnFilter: false,
},
{
accessorKey: "mobile_number",
header: "تلفن همراه",
id: "mobile_number",
enableColumnFilter: false,
},
{
accessorKey: "address",
header: "آدرس",
id: "address",
enableColumnFilter: false,
},
{
accessorKey: "edare_kol",
header: "اداره كل راهداری",
id: "edare_kol",
enableColumnFilter: false,
},
{
accessorKey: "edare_shahri",
header: "اداره شهرستان",
id: "edare_shahri",
enableColumnFilter: false,
},
{
accessorKey: "rah_type",
header: "نوع راه",
id: "rah_type",
enableColumnFilter: false,
},
{
accessorKey: "name_mehvar_fa",
header: "نام محور",
id: "name_mehvar_fa",
enableColumnFilter: false,
},
{
accessorKey: "mizan_harim",
header: "میزان حریم",
id: "mizan_harim",
enableColumnFilter: false,
},
{
accessorKey: "arze_navar",
header: "عرض نوار تاسیساتی زیربنایی",
id: "arze_navar",
enableColumnFilter: false,
},
{
accessorKey: "samt",
header: "سمت",
id: "samt",
enableColumnFilter: false,
},
{
accessorKey: "kilometr",
header: "كيلومتر",
id: "kilometr",
enableColumnFilter: false,
},
{
accessorKey: "zone",
header: "zone",
id: "zone",
enableColumnFilter: false,
},
{
accessorKey: "karbari_type",
header: "نوع کاربری",
id: "karbari_type",
enableColumnFilter: false,
},
{
accessorKey: "tarh_title",
header: "عنوان طرح",
id: "tarh_title",
enableColumnFilter: false,
},
{
accessorKey: "masahat_zirbana",
header: "مساحت زیربنا",
id: "masahat_zirbana",
enableColumnFilter: false,
},
{
accessorKey: "ehdasat_type",
header: "نوع احداثات",
id: "ehdasat_type",
enableColumnFilter: false,
},
{
accessorKey: "divarkeshi_distance",
header: "فاصله دیوارکشی از آکس محور",
id: "divarkeshi_distance",
enableColumnFilter: false,
},
{
accessorKey: "mahale_ejra",
header: "محل اجرا",
id: "mahale_ejra",
enableColumnFilter: false,
},
{
accessorKey: "traffic",
header: "میزان ترافیک",
id: "traffic",
enableColumnFilter: false,
},
{
accessorKey: "vaziat_eghtesadi",
header: "وضعیت اقتصادی",
id: "vaziat_eghtesadi",
enableColumnFilter: false,
},
{
accessorKey: "has_access",
header: "آیا راه دسترسی از قبل وجود دارد؟",
id: "has_access",
enableColumnFilter: false,
},
{
accessorKey: "shomare_estelam_harim",
header: "شماره استعلام دفتر ایمنی و حریم",
id: "shomare_estelam_harim",
enableColumnFilter: false,
},
{
accessorKey: "max_month",
header: "ماه",
id: "max_month",
enableColumnFilter: false,
},
{
accessorKey: "max_day",
header: "روز",
id: "max_day",
enableColumnFilter: false,
},
{
accessorKey: "shomare_tahaodname",
header: "شماره تعهدنامه",
id: "shomare_tahaodname",
enableColumnFilter: false,
},
{
accessorKey: "shomare_daftarkhaneh",
header: "شماره دفترخانه",
id: "shomare_daftarkhaneh",
enableColumnFilter: false,
},
{
accessorKey: "description",
header: "توضیحات",
id: "description",
enableColumnFilter: false,
},
{
accessorKey: "ronevesht",
header: "رونوشت",
id: "ronevesht",
enableColumnFilter: false,
},
],
[]
);
return (
<>
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
<DataTable
table_title={"لیست استعلام ها"}
need_filter={false}
columns={columns}
table_url={GET_INQUIRY_PRIVACY_FENCING_ROUTE}
user_id={0}
page_name={"inquiryPrivacyFencing"}
table_name={"inquiryPrivacyFencingList"}
TableToolbar={Toolbar}
/>
</Box>
</>
);
};
export default InquiryPrivacyFencingList;

View File

@@ -26,6 +26,7 @@ const DataTable_Main = (props) => {
} = props;
const flatColumns = flattenArrayOfObjects(columns, "columns");
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [totalRowCount, setTotalRowCount] = useState(0);
const flattenHideData = flattenObjectOfObjects(hideData);
const onSortingChange = (event) => {
setSortData(event);
@@ -51,6 +52,7 @@ const DataTable_Main = (props) => {
const fetcher = async (url) => {
try {
const response = await request(url);
setTotalRowCount(response.data?.meta?.totalRowCount);
if (specific_data) {
return specific_data(response.data);
} else {
@@ -112,6 +114,7 @@ const DataTable_Main = (props) => {
manualSorting: true,
onPaginationChange: setPagination,
onSortingChange: onSortingChange,
rowCount: totalRowCount,
renderTopToolbarCustomActions: ({ table }) => <>{TableToolbar && <TableToolbar mutate={mutate} />}</>,
renderRowActions: ({ row }) => <RowActions row={row} mutate={mutate} />,
...props,

View File

@@ -8,6 +8,7 @@ const DataTable = (props) => {
page_name={props.page_name}
table_name={props.table_name}
columns={props.columns}
initialSort={props.sorting}
>
<DataTable_Main {...props} />
</DataTableProvider>

View File

@@ -52,6 +52,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
const request = useRequest();
const { user, getUser } = useAuth();
const [uploadBackDrop, setUploadBackDrop] = useState(false);
const [avatarUrl, setAvatarUrl] = useState(user?.avatar || "");
const defaultValues = {
first_name: user.first_name,
last_name: user.last_name,
@@ -70,6 +71,15 @@ const Form = ({ handleCloseForm, setLoading }) => {
formState: { isSubmitting, errors },
} = useForm({ defaultValues, resolver: yupResolver(validationSchema) });
const handleFileChange = (event) => {
const file = event.target.files[0];
if (file) {
const objectUrl = URL.createObjectURL(file);
setAvatarUrl(objectUrl);
setValue("avatar", file);
}
};
useEffect(() => {
setLoading(isSubmitting);
}, [isSubmitting]);
@@ -124,7 +134,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
onMouseEnter={() => setUploadBackDrop(true)}
onMouseLeave={() => setUploadBackDrop(false)}
>
<Avatar src={user?.avatar} sx={{ width: 120, height: 120, border: "1px solid #e1e1e1" }} />
<Avatar src={avatarUrl} sx={{ width: 120, height: 120, border: "1px solid #e1e1e1" }} />
<Backdrop
sx={{
color: "#fff",
@@ -141,11 +151,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
<CloudUploadIcon sx={{ fontSize: "2rem" }} color="inherit" />
</Backdrop>
</Box>
<VisuallyHiddenInput
type="file"
accept="image/*"
onChange={(event) => setValue("avatar", event.target.files[0])}
/>
<VisuallyHiddenInput type="file" accept="image/*" onChange={handleFileChange} />
</Button>
</Box>
<Grid container columns={{ xs: 1, sm: 2 }} spacing={2}>

View File

@@ -0,0 +1,29 @@
"use client";
import { Box, Typography } from "@mui/material";
import { usePermissions } from "@/lib/hooks/usePermissions";
function WithPermission({ children, permission_name }) {
const { data, error, isLoading } = usePermissions();
if (error || isLoading || !data || !permission_name) {
return null;
}
const hasPermission =
permission_name.includes("all") || permission_name.some((permission) => data.includes(permission));
if (!hasPermission) {
return (
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "center", height: "100%" }}>
<Typography variant="h5" sx={{ letterSpacing: "2px", color: "error.main" }}>
شما دسترسی لازم به این صفحه را ندارید
</Typography>
</Box>
);
}
return <>{children}</>;
}
export default WithPermission;

View File

@@ -19,6 +19,7 @@ import ReportIcon from "@mui/icons-material/Report";
import AssignmentLateIcon from "@mui/icons-material/AssignmentLate";
import LineAxisIcon from "@mui/icons-material/LineAxis";
import ScienceIcon from "@mui/icons-material/Science";
import BiotechIcon from "@mui/icons-material/Biotech";
export const pageMenu = [
{
@@ -254,28 +255,28 @@ export const pageMenu = [
label: "استعلام حرائم پنجره واحد",
type: "page",
route: "/dashboard/inquiry-privacy/city-admin/zamin-gov",
permissions: ["all"],
permissions: [],
},
{
id: "provinceAdminZaminGov",
label: "استعلام حرائم پنجره واحد",
type: "page",
route: "/dashboard/inquiry-privacy/province-admin/zamin-gov",
permissions: ["all"],
permissions: [],
},
{
id: "assistantZaminGov",
label: "استعلام حرائم پنجره واحد",
type: "page",
route: "/dashboard/inquiry-privacy/assistant/zamin-gov",
permissions: ["all"],
permissions: [],
},
{
id: "generalManagerZaminGov",
label: "استعلام حرائم پنجره واحد",
type: "page",
route: "/dashboard/inquiry-privacy/general-manager/zamin-gov",
permissions: ["all"],
permissions: [],
},
],
},
@@ -482,6 +483,14 @@ export const pageMenu = [
type: "page",
route: "/dashboard/azmayesh",
icon: <ScienceIcon sx={{ width: "inherit", height: "inherit" }} />,
permissions: ["all"],
permissions: ["azmayesh-management"],
},
{
id: "azmayeshType",
label: "نوع آزمایشات",
type: "page",
route: "/dashboard/azmayesh_type",
icon: <BiotechIcon sx={{ width: "inherit", height: "inherit" }} />,
permissions: ["azmayesh-type-management"],
},
];

View File

@@ -14,7 +14,8 @@ export const GET_PREV_STATE_OPINION = "/v3/api/fake-prev-state-opinion";
export const SUBMIT_ROAD_SAFETY_FORM = "/v3/api/fake-submit";
export const CREATE_AZMAYESH = api + "/api/v3/azmayeshes/store";
export const UPDATE_AZMAYESH = api + "/api/v3/azmayeshes/update";
export const GET_AZMAYESH_TYPE_LIST = api + "/api/v3/azmayesh_types";
export const GET_AZMAYESH_TYPE_LIST = api + "/api/v3/azmayesh_types/list";
export const GET_AZMAYESH_TYPE_LIST_TABLE = api + "/api/v3/azmayesh_types";
export const GET_AZMAYESH_LIST = api + "/api/v3/azmayeshes";
export const DELETE_AZMAYESH = api + "/api/v3/azmayeshes/delete";
export const GET_AZMAYESH_SAMPLE_FIELDS = api + "/api/v3/azmayesh_types/fields";
@@ -22,3 +23,6 @@ export const ADD_SAMPLE_TO_AZMAYESH = api + "/api/v3/azmayesh_samples/store";
export const UPDATE_SAMPLE_OF_AZMAYESH = api + "/api/v3/azmayesh_samples/update";
export const GET_SAMPLE_LIST = api + "/api/v3/azmayesh_samples";
export const DELETE_SAMPLE_LIST = api + "/api/v3/azmayesh_samples/delete";
export const DELETE_AZMAYESH_TYPE_LIST = api + "/api/v3/azmayesh_types/delete";
export const ADD_AZMAYESH_TYPE = api + "/api/v3/azmayesh_types/store";
export const UPDATE_AZMAYESH_TYPE = api + "/api/v3/azmayesh_types/update";

View File

@@ -7,14 +7,14 @@ import { LinearProgress } from "@mui/material";
export const DataTableContext = createContext();
const DataTableProvider = ({ children, user_id, page_name, table_name, columns }) => {
const DataTableProvider = ({ children, user_id, page_name, table_name, columns, initialSort = [] }) => {
const { settingStore } = useTableSetting();
const [isInitStates, setInitStates] = useState(false);
const flatColumns = flattenArrayOfObjects(columns, "columns");
const [initFilter, setInitFilter] = useState({});
const [filterData, setFilterData] = useState({});
const [initSort, setInitSort] = useState([]);
const [sortData, setSortData] = useState([]);
const [initSort, setInitSort] = useState(initialSort || []);
const [sortData, setSortData] = useState(initialSort || []);
const [initHide, setInitHide] = useState({});
const [hideData, setHideData] = useState({});
@@ -51,8 +51,8 @@ const DataTableProvider = ({ children, user_id, page_name, table_name, columns }
}, {});
setFilterData(filterValues);
setInitFilter(filterValues);
setSortData(settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || []);
setInitSort(settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || []);
setSortData(settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || initialSort);
setInitSort(settingStore?.[user_id]?.[page_name]?.[table_name]?.["sorts"] || initialSort);
setInitStates(true);
}, [settingStore, isInitStates]);