Feature/inquiry privacy tasks details
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
InputLabel,
|
||||
OutlinedInput,
|
||||
} from "@mui/material";
|
||||
import { object, string } from "yup";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
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 DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => {
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const handleClose = () => {
|
||||
setTaskModal(false);
|
||||
};
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors, touchedFields },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "onBlur" });
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`api-for-send-to-harim/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
handleClose();
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<Dialog open={taskModal} onClose={handleClose} maxWidth="lg" fullWidth>
|
||||
<DialogContent dividers>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={8}
|
||||
autoComplete="off"
|
||||
{...register("description")}
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ justifyContent: "center", py: 2 }}>
|
||||
<Button size="large" variant="contained">
|
||||
ارسال به دفتر حریم
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default DetailDialog;
|
||||
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import AssignmentIcon from "@mui/icons-material/Assignment";
|
||||
import DetailDialog from "./DetailDialog";
|
||||
import { useState } from "react";
|
||||
|
||||
const TaskDetail = ({ rowId, mutate }) => {
|
||||
const [taskModal, setTaskModal] = useState(false);
|
||||
|
||||
const openDetailDialog = () => {
|
||||
setTaskModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="جزئیات طرح متقاضی" arrow placement="right">
|
||||
<IconButton color="primary" onClick={openDetailDialog}>
|
||||
<AssignmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<DetailDialog taskModal={taskModal} setTaskModal={setTaskModal} rowId={rowId} mutate={mutate} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskDetail;
|
||||
@@ -1,8 +1,15 @@
|
||||
import ReferForm from "@/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer";
|
||||
"use client";
|
||||
|
||||
import ReferForm from "./Refer";
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<ReferForm mutate={mutate} rowId={row.getValue("id")} /> //rowId should pass
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<ReferForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
|
||||
Reference in New Issue
Block a user