Merge branch 'feature/road_safety_form' into 'develop'
Feature/road safety form See merge request witel-front-end/rms!26
This commit is contained in:
9
src/app/api/fake-prev-state-opinion/route.js
Normal file
9
src/app/api/fake-prev-state-opinion/route.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export async function GET() {
|
||||
return Response.json({
|
||||
message:
|
||||
"به موجب این نامه، به استحضار جنابعالی می رساند، این جانب ……… از تاریخ ……… افتخار همکاری\n" +
|
||||
"با مجموعه ……… را دارم. اما متاسفانه، به علت ………، تقاضای استعفای خود را از تاریخ ………\n" +
|
||||
"اعلام میدارم. ضمن تشکر پیشاپیش از همکاری شما خواهشمند است، دستور اقدامات لازم در این\n" +
|
||||
"زمینه را صادر فرمایید.",
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material";
|
||||
|
||||
const DescriptionForm = ({ errors, register }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={6}
|
||||
{...register("description")}
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DescriptionForm;
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
const ManagerOrAssistantSubmit = ({ isSubmitting }) => {
|
||||
return (
|
||||
<>
|
||||
<Button fullWidth variant="outlined" color="secondary" disabled={isSubmitting} type={"submit"}>
|
||||
{isSubmitting ? "در حال ارسال..." : "مخالفت"}
|
||||
</Button>
|
||||
<Button fullWidth variant="contained" color="primary" type={"submit"} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ارسال..." : "موافقت"}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ManagerOrAssistantSubmit;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material";
|
||||
|
||||
const PrevCartableOpinion = ({ message, loadingMessage, errorMessage }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<Card variant="outlined">
|
||||
<CardHeader sx={{ pb: 0 }} title="نظر معاون راهداری استان :" />
|
||||
<CardContent>
|
||||
{errorMessage ? (
|
||||
<Typography color={"red"}>خطا در دریافت اطلاعات !!!</Typography>
|
||||
) : loadingMessage ? (
|
||||
<Typography sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||
<CircularProgress size={20} />
|
||||
درحال دریافت اطلاعات
|
||||
</Typography>
|
||||
) : (
|
||||
<Typography>{message}</Typography>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Divider sx={{ mt: 2 }} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PrevCartableOpinion;
|
||||
@@ -0,0 +1,35 @@
|
||||
import {Card, CardContent, FormControl, FormLabel, Stack, Typography} from "@mui/material";
|
||||
|
||||
const QuestionSafetyForm = () => {
|
||||
return (
|
||||
<Stack sx={{py: 2}}>
|
||||
<Card
|
||||
sx={{display: "flex", justifyContent: "center", alignItems: "center", borderColor: "primary.main"}}
|
||||
variant="outlined"
|
||||
>
|
||||
<CardContent>
|
||||
<FormControl>
|
||||
<FormLabel>
|
||||
<Typography color={"primary"} variant={"h5"} fontWeight={"bolder"}>
|
||||
آیا ایمنی راه این طرح مورد تایید است ؟
|
||||
</Typography>
|
||||
</FormLabel>
|
||||
<Stack
|
||||
sx={{pt: 2, display: "flex", justifyContent: "center", alignItems: "center"}}
|
||||
spacing={1}
|
||||
direction={"row"}
|
||||
>
|
||||
<Typography variant={"subtitle1"}>
|
||||
دفتر حریم راه :{" "}
|
||||
</Typography>
|
||||
<Typography variant={"h5"} fontWeight={"bolder"}>
|
||||
بله
|
||||
</Typography>
|
||||
</Stack>
|
||||
</FormControl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default QuestionSafetyForm;
|
||||
@@ -0,0 +1,82 @@
|
||||
import { DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { object, string } from "yup";
|
||||
import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
import QuestionSafetyForm from "./QuestionSafetyForm";
|
||||
import PrevCartableOpinion from "./PrevCartableOpinion";
|
||||
import DescriptionForm from "./DescriptionForm";
|
||||
import ManagerOrAssistantSubmit from "./ManagerOrAssistantSubmit";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const requestServer = useRequest({ notification : {success : true, show : true} });
|
||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur" });
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
setOpenRoadSafetyForm(false);
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<Stack spacing={2}>
|
||||
<QuestionSafetyForm />
|
||||
<PrevCartableOpinion
|
||||
message={message}
|
||||
loadingMessage={loadingMessage}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<DescriptionForm register={register} errors={errors} />
|
||||
<DialogActions>
|
||||
<ManagerOrAssistantSubmit isSubmitting={isSubmitting} />
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyFormContext;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Dialog, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { useState } from "react";
|
||||
import { Close } from "@mui/icons-material";
|
||||
import RoadSafetyFormContext from "./RoadSafetyFormContext";
|
||||
|
||||
const RoadSafetyForm = ({ rowId, mutate }) => {
|
||||
const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false);
|
||||
return (
|
||||
<Stack>
|
||||
<Tooltip title="فرم ایمنی راه" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenRoadSafetyForm(true);
|
||||
}}
|
||||
>
|
||||
<EngineeringIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
open={openRoadSafetyForm}
|
||||
maxWidth={"lg"}
|
||||
TransitionComponent={DialogTransition}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRoadSafetyForm(false)}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 10,
|
||||
color: (theme) => theme.palette.grey[500],
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<RoadSafetyFormContext rowId={rowId} mutate={mutate} setOpenRoadSafetyForm={setOpenRoadSafetyForm} />
|
||||
</Dialog>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyForm;
|
||||
@@ -1,10 +1,12 @@
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
import RoadSafetyForm from "./RoadSafetyForm";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
<RoadSafetyForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,6 +8,14 @@ import RowActions from "./RowActions";
|
||||
const TaskList = () => {
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا",
|
||||
id: "id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "aplication_number",
|
||||
header: "شماره درخواست",
|
||||
@@ -32,6 +40,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
@@ -96,6 +112,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -112,7 +136,7 @@ const TaskList = () => {
|
||||
table_name={"assistantZaminGovList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
renderRowActions={({ row }) => <RowActions row={row} />}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
|
||||
@@ -31,7 +31,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => {
|
||||
city: "",
|
||||
};
|
||||
const { cities, loadingCities, errorCities } = useCities();
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const requestServer = useRequest({notification : {show : true, success : true}});
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
|
||||
@@ -40,6 +40,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
@@ -104,6 +112,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material";
|
||||
|
||||
const DescriptionForm = ({ errors, register }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={6}
|
||||
{...register("description")}
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DescriptionForm;
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
const ManagerOrAssistantSubmit = ({ isSubmitting }) => {
|
||||
return (
|
||||
<>
|
||||
<Button fullWidth variant="outlined" color="secondary" disabled={isSubmitting} type={"submit"}>
|
||||
{isSubmitting ? "در حال ارسال..." : "مخالفت"}
|
||||
</Button>
|
||||
<Button fullWidth variant="contained" color="primary" type={"submit"} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ارسال..." : "موافقت"}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ManagerOrAssistantSubmit;
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
|
||||
const PrevCartableOpinion = ({ message, loadingMessage, errorMessage }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<Card variant="outlined">
|
||||
<CardHeader sx={{ pb: 0 }} title="نظر معاون راهداری استان :" />
|
||||
<CardContent>
|
||||
{errorMessage ? (
|
||||
<Typography color={"red"}>خطا در دریافت اطلاعات !!!</Typography>
|
||||
) : loadingMessage ? (
|
||||
<Typography sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||
<CircularProgress size={20} />
|
||||
درحال دریافت اطلاعات
|
||||
</Typography>
|
||||
) : (
|
||||
<Typography>{message}</Typography>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Divider sx={{ mt: 2 }} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PrevCartableOpinion;
|
||||
@@ -0,0 +1,35 @@
|
||||
import {Card, CardContent, FormControl, FormLabel, Stack, Typography} from "@mui/material";
|
||||
|
||||
const QuestionSafetyForm = () => {
|
||||
return (
|
||||
<Stack sx={{py: 2}}>
|
||||
<Card
|
||||
sx={{display: "flex", justifyContent: "center", alignItems: "center", borderColor: "primary.main"}}
|
||||
variant="outlined"
|
||||
>
|
||||
<CardContent>
|
||||
<FormControl>
|
||||
<FormLabel>
|
||||
<Typography color={"primary"} variant={"h5"} fontWeight={"bolder"}>
|
||||
آیا ایمنی راه این طرح مورد تایید است ؟
|
||||
</Typography>
|
||||
</FormLabel>
|
||||
<Stack
|
||||
sx={{pt: 2, display: "flex", justifyContent: "center", alignItems: "center"}}
|
||||
spacing={1}
|
||||
direction={"row"}
|
||||
>
|
||||
<Typography variant={"subtitle1"}>
|
||||
دفتر حریم راه :{" "}
|
||||
</Typography>
|
||||
<Typography variant={"h5"} fontWeight={"bolder"}>
|
||||
بله
|
||||
</Typography>
|
||||
</Stack>
|
||||
</FormControl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default QuestionSafetyForm;
|
||||
@@ -0,0 +1,82 @@
|
||||
import { DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { object, string } from "yup";
|
||||
import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes";
|
||||
import QuestionSafetyForm from "./QuestionSafetyForm";
|
||||
import PrevCartableOpinion from "./PrevCartableOpinion";
|
||||
import DescriptionForm from "./DescriptionForm";
|
||||
import ManagerOrAssistantSubmit from "./ManagerOrAssistantSubmit";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const requestServer = useRequest({ notification : {success : true, show : true} });
|
||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur" });
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
setOpenRoadSafetyForm(false);
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<Stack spacing={2}>
|
||||
<QuestionSafetyForm />
|
||||
<PrevCartableOpinion
|
||||
message={message}
|
||||
loadingMessage={loadingMessage}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<DescriptionForm register={register} errors={errors} />
|
||||
<DialogActions>
|
||||
<ManagerOrAssistantSubmit isSubmitting={isSubmitting} />
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyFormContext;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Dialog, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { useState } from "react";
|
||||
import { Close } from "@mui/icons-material";
|
||||
import RoadSafetyFormContext from "./RoadSafetyFormContext";
|
||||
|
||||
const RoadSafetyForm = ({ rowId, mutate }) => {
|
||||
const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false);
|
||||
return (
|
||||
<Stack>
|
||||
<Tooltip title="فرم ایمنی راه" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenRoadSafetyForm(true);
|
||||
}}
|
||||
>
|
||||
<EngineeringIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
open={openRoadSafetyForm}
|
||||
maxWidth={"lg"}
|
||||
TransitionComponent={DialogTransition}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRoadSafetyForm(false)}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 10,
|
||||
color: (theme) => theme.palette.grey[500],
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<RoadSafetyFormContext rowId={rowId} mutate={mutate} setOpenRoadSafetyForm={setOpenRoadSafetyForm} />
|
||||
</Dialog>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyForm;
|
||||
@@ -1,10 +1,12 @@
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
import RoadSafetyForm from "./RoadSafetyForm";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
<RoadSafetyForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,6 +8,14 @@ import RowActions from "./RowActions";
|
||||
const TaskList = () => {
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا",
|
||||
id: "id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "aplication_number",
|
||||
header: "شماره درخواست",
|
||||
@@ -32,6 +40,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
@@ -96,6 +112,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -112,7 +136,7 @@ const TaskList = () => {
|
||||
table_name={"generalManagerZaminGovList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
renderRowActions={({ row }) => <RowActions row={row} />}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
|
||||
@@ -31,7 +31,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => {
|
||||
province: "",
|
||||
};
|
||||
const { provinces, loadingProvinces, errorProvinces } = useProvinces();
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const requestServer = useRequest({notification : {show : true, success : true}});
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material";
|
||||
|
||||
const DescriptionForm = ({ errors, register }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={6}
|
||||
{...register("description")}
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DescriptionForm;
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
|
||||
const PrevCartableOpinion = () => {
|
||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||
return (
|
||||
<Stack>
|
||||
<Card variant="outlined">
|
||||
<CardHeader sx={{ pb: 0 }} title="نظر معاون راهداری استان :" />
|
||||
<CardContent>
|
||||
{errorMessage ? (
|
||||
<Typography color={"red"}>خطا در دریافت اطلاعات !!!</Typography>
|
||||
) : loadingMessage ? (
|
||||
<Typography sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||
<CircularProgress size={20} />
|
||||
درحال دریافت اطلاعات
|
||||
</Typography>
|
||||
) : (
|
||||
<Typography>{message}</Typography>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Divider sx={{ mt: 2 }} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PrevCartableOpinion;
|
||||
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
FormControl,
|
||||
FormControlLabel,
|
||||
FormLabel,
|
||||
RadioGroup,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import Radio from "@mui/material/Radio";
|
||||
|
||||
const QuestionSafetyForm = ({ register, errors }) => {
|
||||
return (
|
||||
<Stack sx={{ py: 2 }}>
|
||||
<Card
|
||||
variant="outlined"
|
||||
sx={{ display: "flex", justifyContent: "center", alignItems: "center", borderColor: "primary.main" }}
|
||||
>
|
||||
<CardContent>
|
||||
<FormControl error={!!errors.RadioGroup}>
|
||||
<FormLabel>
|
||||
<Typography color={"primary"} variant={"h5"} fontWeight={"bolder"}>
|
||||
آیا ایمنی راه این طرح مورد تایید است ؟
|
||||
</Typography>
|
||||
</FormLabel>
|
||||
<Stack
|
||||
sx={{ pt: 2, display: "flex", justifyContent: "center", alignItems: "center" }}
|
||||
direction={"row"}
|
||||
>
|
||||
<RadioGroup row>
|
||||
<FormControlLabel
|
||||
value="1"
|
||||
control={<Radio />}
|
||||
label="بله"
|
||||
{...register("RadioGroup")}
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="0"
|
||||
control={<Radio />}
|
||||
label="خیر"
|
||||
{...register("RadioGroup")}
|
||||
/>
|
||||
</RadioGroup>
|
||||
</Stack>
|
||||
{errors.RadioGroup && (
|
||||
<Typography textAlign={"center"} variant="body2" color="error">
|
||||
{errors.RadioGroup.message}
|
||||
</Typography>
|
||||
)}
|
||||
</FormControl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default QuestionSafetyForm;
|
||||
@@ -0,0 +1,80 @@
|
||||
import { DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { object, string } from "yup";
|
||||
import QuestionSafetyForm from "./QuestionSafetyForm";
|
||||
import PrevCartableOpinion from "./PrevCartableOpinion";
|
||||
import DescriptionForm from "./DescriptionForm";
|
||||
import SubmitButtonsAdmin from "./SubmitButtonsAdmin";
|
||||
import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
RadioGroup: string().required("تاییدیه ایمنی راه ضروریست!"),
|
||||
});
|
||||
const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
RadioGroup: "",
|
||||
};
|
||||
const requestServer = useRequest({ notification : {success : true, show : true} });
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur" });
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
formData.append("provinceId", data.RadioGroup);
|
||||
|
||||
requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
setOpenRoadSafetyForm(false);
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<Stack spacing={2}>
|
||||
<QuestionSafetyForm register={register} errors={errors} />
|
||||
<PrevCartableOpinion />
|
||||
<DescriptionForm register={register} errors={errors} />
|
||||
<DialogActions>
|
||||
<SubmitButtonsAdmin isSubmitting={isSubmitting} setOpenRoadSafetyForm={setOpenRoadSafetyForm} />
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyFormContext;
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
const SubmitButtonsAdmin = ({ setOpenRoadSafetyForm, isSubmitting }) => {
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => setOpenRoadSafetyForm(false)}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
autoFocus
|
||||
>
|
||||
{"انصراف"}
|
||||
</Button>
|
||||
<Button fullWidth variant="contained" color="primary" type={"submit"} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ارسال..." : "ارسال"}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default SubmitButtonsAdmin;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Dialog, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { useState } from "react";
|
||||
import RoadSafetyFormContext from "./RoadSaftyFormContext";
|
||||
import { Close } from "@mui/icons-material";
|
||||
|
||||
const RoadSafetyForm = ({ rowId, mutate }) => {
|
||||
const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false);
|
||||
return (
|
||||
<Stack>
|
||||
<Tooltip title="فرم ایمنی راه" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenRoadSafetyForm(true);
|
||||
}}
|
||||
>
|
||||
<EngineeringIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
open={openRoadSafetyForm}
|
||||
maxWidth={"lg"}
|
||||
TransitionComponent={DialogTransition}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRoadSafetyForm(false)}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 10,
|
||||
color: (theme) => theme.palette.grey[500],
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<RoadSafetyFormContext rowId={rowId} mutate={mutate} setOpenRoadSafetyForm={setOpenRoadSafetyForm} />
|
||||
</Dialog>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyForm;
|
||||
@@ -1,12 +1,14 @@
|
||||
import ReferForm from "./Refer";
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
import RoadSafetyForm from "./RoadSafetyForm";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<ReferForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
<RoadSafetyForm rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -40,6 +40,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
@@ -104,6 +112,14 @@ const TaskList = () => {
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterFn: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -120,7 +136,7 @@ const TaskList = () => {
|
||||
table_name={"provinceAdminZaminGovList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
renderRowActions={({ row }) => <RowActions row={row} />}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
|
||||
@@ -16,7 +16,7 @@ export const successToast = (toastContainer) =>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Beenhere color="success" sx={{ mr: 1.6 }} />
|
||||
<Box sx={{ display: "flex", flexDirection: "column" }}>
|
||||
<Typography variant="caption">{"Your operation was successful"}</Typography>
|
||||
<Typography variant="caption">{"عملیات با موفقیت انجام شد"}</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -10,3 +10,5 @@ export const REFER_ADMIN_PROVINCE = "/v3/api/fake-submit";
|
||||
export const REFER_ADMIN_CITY = "/v3/api/fake-submit";
|
||||
export const GET_CITY_LISTS = "/v3/api/fake-cities";
|
||||
export const GET_PROVINCE_LISTS = "/v3/api/fake-provinces";
|
||||
export const GET_PREV_STATE_OPINION = "/v3/api/fake-prev-state-opinion";
|
||||
export const SUBMIT_ROAD_SAFETY_FORM = "/v3/api/fake-submit";
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import axios from "axios";
|
||||
import { GET_CITY_LISTS } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
|
||||
const useCities = () => {
|
||||
const requestServer = useRequest()
|
||||
const [cities, setCities] = useState([]);
|
||||
const [loadingCities, setLoadingCities] = useState(true);
|
||||
const [errorCities, setErrorCities] = useState(null);
|
||||
@@ -10,7 +12,7 @@ const useCities = () => {
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
try {
|
||||
const response = await axios.get(`${GET_CITY_LISTS}`);
|
||||
const response = await requestServer(`${GET_CITY_LISTS}`);
|
||||
setCities(response.data.data);
|
||||
setLoadingCities(false);
|
||||
} catch (e) {
|
||||
|
||||
31
src/lib/hooks/usePrevStateopinion.js
Normal file
31
src/lib/hooks/usePrevStateopinion.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import axios from "axios";
|
||||
import { GET_PREV_STATE_OPINION } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
|
||||
const usePrevStateOpinion = () => {
|
||||
const requestServer = useRequest()
|
||||
const [message, setMessage] = useState([]);
|
||||
const [loadingMessage, setLoadingMessage] = useState(true);
|
||||
const [errorMessage, setErrorMessage] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_PREV_STATE_OPINION}`);
|
||||
setMessage(response.data.message);
|
||||
setLoadingMessage(false);
|
||||
} catch (e) {
|
||||
console.error("Error fetching cities:", e);
|
||||
setErrorMessage(e);
|
||||
setLoadingMessage(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCities();
|
||||
}, []);
|
||||
|
||||
return { message, loadingMessage, errorMessage };
|
||||
};
|
||||
|
||||
export default usePrevStateOpinion;
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import axios from "axios";
|
||||
import { GET_PROVINCE_LISTS } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
|
||||
const useProvinces = () => {
|
||||
const requestServer = useRequest()
|
||||
const [provinces, setProvinces] = useState([]);
|
||||
const [loadingProvinces, setLoadingProvinces] = useState(true);
|
||||
const [errorProvinces, setErrorProvinces] = useState(null);
|
||||
@@ -10,7 +12,7 @@ const useProvinces = () => {
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
try {
|
||||
const response = await axios.get(`${GET_PROVINCE_LISTS}`); // Fetch the cities from the API
|
||||
const response = await requestServer(`${GET_PROVINCE_LISTS}`); // Fetch the cities from the API
|
||||
setProvinces(response.data.data); // Set the cities data
|
||||
setLoadingProvinces(false); // Set loading to false after successful fetch
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user