Feature/kargrouh refahi cartable
This commit is contained in:
@@ -1,134 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { CONFIRM_COMMERCIAL_CHIEF } from "@/core/data/apiRoutes";
|
||||
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
||||
import { useState } from "react";
|
||||
|
||||
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
confirm_img: null,
|
||||
},
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_COMMERCIAL_CHIEF}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenConfirmDialog(false);
|
||||
update_notification();
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
};
|
||||
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("confirm_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={
|
||||
<>
|
||||
<span>{t("ConfirmDialog.description")}</span>
|
||||
<small>{t("ConfirmDialog.optional")}</small>
|
||||
</>
|
||||
}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="confirm_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250, 150]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenConfirmDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting}
|
||||
>
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmContent;
|
||||
@@ -1,135 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import * as Yup from "yup";
|
||||
import { REJECT_COMMERCIAL_CHIEF } from "@/core/data/apiRoutes";
|
||||
|
||||
const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => {
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const t = useTranslations();
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
description: Yup.string().required(t("RejectDialog.description_error")),
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
reject_img: null,
|
||||
},
|
||||
validationSchema,
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_COMMERCIAL_CHIEF}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenRejectDialog(false);
|
||||
mutate();
|
||||
update_notification();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
formik.handleChange(event);
|
||||
};
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("reject_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={t("RejectDialog.description")}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
onBlur={formik.handleBlur("description")}
|
||||
error={formik.touched.description && Boolean(formik.errors.description)}
|
||||
helperText={formik.touched.description && formik.errors.description}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="reject_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250 /*width*/, 150 /*height*/]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenRejectDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("RejectDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}
|
||||
>
|
||||
{t("RejectDialog.button-reject")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RejectContent;
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<Confirm rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Reject rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRow;
|
||||
@@ -1,134 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { CONFIRM_DEVELOPMENT_ASSISTANT } from "@/core/data/apiRoutes";
|
||||
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
||||
import { useState } from "react";
|
||||
|
||||
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
confirm_img: null,
|
||||
},
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_DEVELOPMENT_ASSISTANT}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenConfirmDialog(false);
|
||||
mutate();
|
||||
update_notification();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
};
|
||||
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("confirm_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={
|
||||
<>
|
||||
<span>{t("ConfirmDialog.description")}</span>
|
||||
<small>{t("ConfirmDialog.optional")}</small>
|
||||
</>
|
||||
}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="confirm_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250, 150]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenConfirmDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting}
|
||||
>
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmContent;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt";
|
||||
import { useState } from "react";
|
||||
import ConfirmContent from "./ConfirmContent";
|
||||
|
||||
const Confirm = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("ConfirmDialog.confirm")}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setOpenConfirmDialog(true);
|
||||
}}
|
||||
>
|
||||
<ThumbUpAltIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openConfirmDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>{t("ConfirmDialog.confirm")}</DialogTitle>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Confirm;
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<Confirm rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Reject rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRow;
|
||||
@@ -1,134 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { CONFIRM_INSPECTOR_EXPERT } from "@/core/data/apiRoutes";
|
||||
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
||||
import { useState } from "react";
|
||||
|
||||
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
confirm_img: null,
|
||||
},
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_INSPECTOR_EXPERT}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenConfirmDialog(false);
|
||||
mutate();
|
||||
update_notification();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
};
|
||||
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("confirm_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={
|
||||
<>
|
||||
<span>{t("ConfirmDialog.description")}</span>
|
||||
<small>{t("ConfirmDialog.optional")}</small>
|
||||
</>
|
||||
}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="confirm_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250, 150]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenConfirmDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting}
|
||||
>
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmContent;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import ReplyIcon from "@mui/icons-material/Reply";
|
||||
import { useState } from "react";
|
||||
import ReviseContent from "./ReviseContent";
|
||||
|
||||
const Revise = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
const [openReviseDialog, setOpenReviseDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("ReviseDialog.revise")}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setOpenReviseDialog(true);
|
||||
}}
|
||||
>
|
||||
<ReplyIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openReviseDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>{t("ReviseDialog.revise")}</DialogTitle>
|
||||
<ReviseContent mutate={mutate} rowId={rowId} setOpenReviseDialog={setOpenReviseDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Revise;
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Revise from "./Form/ReviseForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<Confirm rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Reject rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Revise rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRow;
|
||||
@@ -2,7 +2,7 @@ import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
import EditContent from "@/components/dashboard/bank-management/Form/Edit/EditContent";
|
||||
import EditContent from "./Edit/EditContent";
|
||||
|
||||
const EditForm = ({ rowId, row, mutate, vehicle_type }) => {
|
||||
const t = useTranslations();
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Box } from "@mui/material";
|
||||
import UpdateForm from "@/components/dashboard/bank-management/Form/Update";
|
||||
import EditForm from "@/components/dashboard/bank-management/Form/Edit";
|
||||
import RejectForm from "@/components/dashboard/bank-management/Form/Reject";
|
||||
import UpdateForm from "./Form/Update";
|
||||
import EditForm from "./Form/Edit";
|
||||
import RejectForm from "./Form/Reject";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
return (
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Stack } from "@mui/material";
|
||||
import PrintExcel from "@/components/dashboard/bank-management/Buttons/printExcel";
|
||||
import PrintExcel from "./Buttons/printExcel";
|
||||
|
||||
const TableToolbar = ({ table }) => {
|
||||
return (
|
||||
@@ -3,9 +3,9 @@ import { useMemo } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import moment from "jalali-moment";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import TableRowActions from "@/components/dashboard/bank-management/TableRowActions";
|
||||
import TableRowActions from "./TableRowActions";
|
||||
import { GET_BANK_STATEMENT } from "@/core/data/apiRoutes";
|
||||
import TableToolbar from "@/components/dashboard/bank-management/TableToobar";
|
||||
import TableToolbar from "./TableToobar";
|
||||
|
||||
function DashboardBankManagementComponent() {
|
||||
const t = useTranslations();
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Box } from "@mui/material";
|
||||
import ReferPassengerBoss from "@/components/dashboard/loan-followup/Form/ReferPassengerBoss";
|
||||
import ReferPassengerBoss from "./Form/ReferPassengerBoss";
|
||||
import UserInfoForm from "./Form/UserInfoForm";
|
||||
import PlanningCouncilForm from "@/components/dashboard/loan-followup/Form/PlanningCouncilForm";
|
||||
import ComebackLoanDetail from "@/components/dashboard/loan-followup/Form/ComebackLoanDetail";
|
||||
import BankPayment from "@/components/dashboard/loan-followup/Form/BankPayment";
|
||||
import ApprovedBankLoan from "@/components/dashboard/loan-followup/Form/ApprovedBankLoan";
|
||||
import PlanningCouncilForm from "./Form/PlanningCouncilForm";
|
||||
import ComebackLoanDetail from "./Form/ComebackLoanDetail";
|
||||
import BankPayment from "./Form/BankPayment";
|
||||
import ApprovedBankLoan from "./Form/ApprovedBankLoan";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
return (
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Stack } from "@mui/material";
|
||||
import PrintExcel from "@/components/dashboard/passenger-boss/Buttons/printExcel";
|
||||
import PrintExcel from "./Buttons/printExcel";
|
||||
|
||||
const TableToolbar = ({ table }) => {
|
||||
return (
|
||||
@@ -6,7 +6,7 @@ import TableRowActions from "./TableRowActions";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import moment from "jalali-moment";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import TableToolbar from "@/components/dashboard/navgan-loan-management/TableToolbar";
|
||||
import TableToolbar from "./TableToolbar";
|
||||
|
||||
function DashboardNavganLoanManagementComponent() {
|
||||
const t = useTranslations();
|
||||
@@ -2,7 +2,7 @@ import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import CallReceivedIcon from "@mui/icons-material/CallReceived";
|
||||
import RevertContent from "@/components/dashboard/navgan-province-manager/Form/RevertForm/RevertContent";
|
||||
import RevertContent from "./RevertContent";
|
||||
|
||||
const Revert = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Revert from "@/components/dashboard/navgan-province-manager/Form/RevertForm";
|
||||
import Revert from "./Form/RevertForm";
|
||||
import UserInfoForm from "./Form/UserInfoForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Stack } from "@mui/material";
|
||||
import PrintExcel from "@/components/dashboard/navgan-loan-management/Buttons/printExcel";
|
||||
import PrintExcel from "./Buttons/printExcel";
|
||||
|
||||
const TableToolbar = ({ table }) => {
|
||||
return (
|
||||
@@ -6,7 +6,7 @@ import TableRowActions from "./TableRowActions";
|
||||
import moment from "jalali-moment";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import TableToolbar from "@/components/dashboard/navgan-province-manager/TableToolbar";
|
||||
import TableToolbar from "./TableToolbar";
|
||||
|
||||
function DashboardNavganProvinceManagerComponent() {
|
||||
const t = useTranslations();
|
||||
@@ -2,7 +2,7 @@ import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import ContactMailIcon from "@mui/icons-material/ContactMail";
|
||||
import ReferUserContent from "@/components/dashboard/passenger-boss/Form/ReferUser/ReferUserContent";
|
||||
import ReferUserContent from "./ReferUserContent";
|
||||
const ReferUser = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
const [openReferDialog, setOpenReferDialog] = useState(false);
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import ReserveForm from "@/components/dashboard/passenger-boss/Form/ReserveForm";
|
||||
import ReferReason from "@/components/dashboard/passenger-boss/Form/ReferReason";
|
||||
import ReferUser from "@/components/dashboard/passenger-boss/Form/ReferUser";
|
||||
import ReserveForm from "./Form/ReserveForm";
|
||||
import ReferReason from "./Form/ReferReason";
|
||||
import ReferUser from "./Form/ReferUser";
|
||||
import UserInfoForm from "./Form/UserInfoForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Stack } from "@mui/material";
|
||||
import PrintExcel from "@/components/dashboard/navgan-province-manager/Buttons/printExcel";
|
||||
import PrintExcel from "./Buttons/printExcel";
|
||||
|
||||
const TableToolbar = ({ table }) => {
|
||||
return (
|
||||
@@ -6,7 +6,7 @@ import TableRowActions from "./TableRowActions";
|
||||
import moment from "jalali-moment";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import TableToolbar from "@/components/dashboard/passenger-boss/TableToolbar";
|
||||
import TableToolbar from "./TableToolbar";
|
||||
|
||||
function DashboardPassengerOfficeComponent() {
|
||||
const t = useTranslations();
|
||||
@@ -6,7 +6,7 @@ import TableRowActions from "./TableRowActions";
|
||||
import moment from "jalali-moment";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import TableToolbar from "@/components/dashboard/reserve-loan/TableToolbar";
|
||||
import TableToolbar from "./TableToolbar";
|
||||
|
||||
function DashboardReserveLoan() {
|
||||
const t = useTranslations();
|
||||
@@ -2,7 +2,7 @@ import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import CallReceivedIcon from "@mui/icons-material/CallReceived";
|
||||
import RevertContent from "@/components/dashboard/transportation-assistance/Form/RevertForm/RevertContent";
|
||||
import RevertContent from "./RevertContent";
|
||||
|
||||
const Revert = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Revert from "@/components/dashboard/transportation-assistance/Form/RevertForm";
|
||||
import ReferReason from "@/components/dashboard/transportation-assistance/Form/ReferReason";
|
||||
import Revert from "./Form/RevertForm";
|
||||
import ReferReason from "./Form/ReferReason";
|
||||
import UserInfoForm from "./Form/UserInfoForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Stack } from "@mui/material";
|
||||
import PrintExcel from "./Buttons/printExcel";
|
||||
|
||||
const TableToolbar = ({ table }) => {
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<PrintExcel table={table} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableToolbar;
|
||||
@@ -6,7 +6,7 @@ import TableRowActions from "./TableRowActions";
|
||||
import moment from "jalali-moment";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import TableToolbar from "@/components/dashboard/transportation-assistance/TableToolbar";
|
||||
import TableToolbar from "./TableToolbar";
|
||||
|
||||
function DashboardTransportationAssistanceComponent() {
|
||||
const t = useTranslations();
|
||||
@@ -1,134 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { CONFIRM_PROVINCE_HEAD_EXPERT } from "@/core/data/apiRoutes";
|
||||
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
||||
import { useState } from "react";
|
||||
|
||||
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
confirm_img: null,
|
||||
},
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_PROVINCE_HEAD_EXPERT}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenConfirmDialog(false);
|
||||
mutate();
|
||||
update_notification();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
};
|
||||
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("confirm_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={
|
||||
<>
|
||||
<span>{t("ConfirmDialog.description")}</span>
|
||||
<small>{t("ConfirmDialog.optional")}</small>
|
||||
</>
|
||||
}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="confirm_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250, 150]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenConfirmDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting}
|
||||
>
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmContent;
|
||||
@@ -1,135 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import * as Yup from "yup";
|
||||
import { REJECT_PROVINCE_HEAD_EXPERT } from "@/core/data/apiRoutes";
|
||||
|
||||
const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => {
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const t = useTranslations();
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
description: Yup.string().required(t("RejectDialog.description_error")),
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
reject_img: null,
|
||||
},
|
||||
validationSchema,
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_PROVINCE_HEAD_EXPERT}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenRejectDialog(false);
|
||||
mutate();
|
||||
update_notification();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
formik.handleChange(event);
|
||||
};
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("reject_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={t("RejectDialog.description")}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
onBlur={formik.handleBlur("description")}
|
||||
error={formik.touched.description && Boolean(formik.errors.description)}
|
||||
helperText={formik.touched.description && formik.errors.description}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="reject_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250 /*width*/, 150 /*height*/]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenRejectDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("RejectDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}
|
||||
>
|
||||
{t("RejectDialog.button-reject")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RejectContent;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import ReplyIcon from "@mui/icons-material/Reply";
|
||||
import { useState } from "react";
|
||||
import ReviseContent from "./ReviseContent";
|
||||
|
||||
const Revise = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
const [openReviseDialog, setOpenReviseDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("ReviseDialog.revise")}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setOpenReviseDialog(true);
|
||||
}}
|
||||
>
|
||||
<ReplyIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openReviseDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>{t("ReviseDialog.revise")}</DialogTitle>
|
||||
<ReviseContent mutate={mutate} rowId={rowId} setOpenReviseDialog={setOpenReviseDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Revise;
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
import Revise from "./Form/ReviseForm";
|
||||
|
||||
const TableRowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<Confirm rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Reject rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Revise rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRowActions;
|
||||
@@ -1,119 +0,0 @@
|
||||
import { Box, Typography } from "@mui/material";
|
||||
import { useMemo } from "react";
|
||||
import { GET_PROVINCE_HEAD_EXPERT } from "@/core/data/apiRoutes";
|
||||
import { useTranslations } from "next-intl";
|
||||
import moment from "jalali-moment";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import TableRowActions from "./TableRowActions";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
|
||||
function DashboardProvinceHeadExpertComponent() {
|
||||
const t = useTranslations();
|
||||
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => row.id,
|
||||
id: "id",
|
||||
header: t("ProvinceHeadExpert.id"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"],
|
||||
Cell: ({ renderedCellValue }) => <Typography variant="body2">{renderedCellValue}</Typography>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.name,
|
||||
id: "name",
|
||||
header: t("ProvinceHeadExpert.name"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
||||
Cell: ({ renderedCellValue }) => <Typography variant="body2">{renderedCellValue}</Typography>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.national_id,
|
||||
id: "national_id",
|
||||
header: t("ProvinceHeadExpert.national_id"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"],
|
||||
Cell: ({ renderedCellValue }) => <Typography variant="body2">{renderedCellValue}</Typography>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.phone_number,
|
||||
id: "phone_number",
|
||||
header: t("ProvinceHeadExpert.phone_number"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: ["equals", "notEquals", "contains", "lessThan", "greaterThan", "between"],
|
||||
Cell: ({ renderedCellValue }) => <Typography variant="body2">{renderedCellValue}</Typography>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||
id: "created_at",
|
||||
header: t("ProvinceHeadExpert.created_at"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterFn: "lessThan",
|
||||
columnFilterModeOptions: ["lessThan", "greaterThan"],
|
||||
Cell: ({ renderedCellValue }) => {
|
||||
return <Typography variant="body2">{renderedCellValue}</Typography>;
|
||||
},
|
||||
Header: ({ column }) => <>{column.columnDef.header}</>,
|
||||
Filter: ({ column }) => {
|
||||
return <MuiDatePicker column={column} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||
id: "updated_at",
|
||||
header: t("ProvinceHeadExpert.updated_at"),
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
Cell: ({ renderedCellValue }) => <Typography variant="body2">{renderedCellValue}</Typography>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.state_name,
|
||||
id: "state_id",
|
||||
header: t("ProvinceHeadExpert.state_name"),
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
Cell: ({ renderedCellValue }) => <Typography variant="body2">{renderedCellValue}</Typography>,
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
return (
|
||||
<Box sx={{ px: 3 }}>
|
||||
<DataTable
|
||||
tableUrl={GET_PROVINCE_HEAD_EXPERT}
|
||||
columns={columns}
|
||||
selectableRow={false}
|
||||
enableCustomToolbar={false}
|
||||
enableLastUpdate={true}
|
||||
sorting={[
|
||||
{
|
||||
id: "id",
|
||||
desc: false,
|
||||
},
|
||||
]}
|
||||
enablePinning={true}
|
||||
enableDensityToggle={false}
|
||||
initialState={{ density: "compact" }} //compact (small) //comfortable (medium) //spacious (large)
|
||||
enableColumnFilters={true}
|
||||
enableHiding={true}
|
||||
enableFullScreenToggle={false}
|
||||
enableGlobalFilter={false}
|
||||
enableColumnResizing={false} // if you want true this you should change renderRowActions props ** see https://www.material-react-table.com/docs/guides/row-actions
|
||||
enableRowActions={true}
|
||||
TableRowAction={TableRowActions}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
export default DashboardProvinceHeadExpertComponent;
|
||||
@@ -1,134 +0,0 @@
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material";
|
||||
import { useFormik } from "formik";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { CONFIRM_REFAHI_PROVINCE_MANAGER } from "@/core/data/apiRoutes";
|
||||
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
|
||||
import { useState } from "react";
|
||||
|
||||
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
||||
const t = useTranslations();
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
const [fileType, setfileType] = useState(null);
|
||||
const [fileName, setfileName] = useState(null);
|
||||
const [showAddIcon, setShowAddIcon] = useState(true);
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const { update_notification } = useNotification();
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
description: "",
|
||||
confirm_img: null,
|
||||
},
|
||||
onSubmit: (values, { setSubmitting }) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_REFAHI_PROVINCE_MANAGER}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
setOpenConfirmDialog(false);
|
||||
mutate();
|
||||
update_notification();
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDescriptionChange = (event) => {
|
||||
formik.setFieldValue("description", event.target.value);
|
||||
};
|
||||
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const maxFileSize = 2 * 1024 * 1024;
|
||||
if (uploadedFile.size > maxFileSize) {
|
||||
UploadFileNotification(t);
|
||||
event.target.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setSelectedImage(URL.createObjectURL(uploadedFile));
|
||||
setfileType(fileType);
|
||||
setfileName(fileName);
|
||||
formik.setFieldValue("confirm_img", uploadedFile);
|
||||
setShowAddIcon(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="description"
|
||||
multiline
|
||||
rows={8}
|
||||
label={
|
||||
<>
|
||||
<span>{t("ConfirmDialog.description")}</span>
|
||||
<small>{t("ConfirmDialog.optional")}</small>
|
||||
</>
|
||||
}
|
||||
value={formik.values.description}
|
||||
onChange={handleDescriptionChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Typography>
|
||||
{t("UploadSystem.upload_file")}
|
||||
{t("UploadSystem.optional")}
|
||||
</Typography>
|
||||
<UploadSystem
|
||||
selectedImage={selectedImage}
|
||||
handleUploadChange={handleUploadChange} // Pass the updated function directly
|
||||
setselectedImage={setSelectedImage}
|
||||
setFieldValue={formik.setFieldValue} // Remove props.setFieldValue, use formik.setFieldValue
|
||||
fieldname="confirm_img"
|
||||
fileType={fileType}
|
||||
fileName={fileName}
|
||||
imageAlt={t("app_name")}
|
||||
imageSize={[250, 150]}
|
||||
setShowAddIcon={setShowAddIcon}
|
||||
showAddIcon={showAddIcon}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenConfirmDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={formik.isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={formik.handleSubmit}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={formik.isSubmitting}
|
||||
>
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmContent;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt";
|
||||
import { useState } from "react";
|
||||
import ConfirmContent from "./ConfirmContent";
|
||||
|
||||
const Confirm = ({ rowId, mutate }) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("ConfirmDialog.confirm")}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setOpenConfirmDialog(true);
|
||||
}}
|
||||
>
|
||||
<ThumbUpAltIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openConfirmDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>{t("ConfirmDialog.confirm")}</DialogTitle>
|
||||
<ConfirmContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Confirm;
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Box } from "@mui/material";
|
||||
import Confirm from "./Form/ConfirmForm";
|
||||
import Reject from "./Form/RejectForm";
|
||||
|
||||
const TableRow = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<Confirm rowId={row.getValue("id")} mutate={mutate} />
|
||||
<Reject rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRow;
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Button, CircularProgress } from "@mui/material";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useMemo, useState } from "react";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import { EXPORT_REFAHI_PASSENGER_BOSS } from "@/core/data/apiRoutes";
|
||||
import moment from "jalali-moment";
|
||||
import FileSaver from "file-saver";
|
||||
import DescriptionIcon from "@mui/icons-material/Description";
|
||||
|
||||
const PrintExcel = ({ table }) => {
|
||||
const t = useTranslations();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const requestServer = useRequest({ auth: true, pending: false, success: { notification: { show: false } } });
|
||||
const { columnFilters, columnFilterFns, sorting } = table.getState();
|
||||
const columns = table.getAllColumns();
|
||||
|
||||
const filterParams = useMemo(() => {
|
||||
const params = new URLSearchParams();
|
||||
const filters = columnFilters.map((filter) => {
|
||||
let datatype;
|
||||
for (const i in columns) {
|
||||
if (columns[i].id == filter.id) {
|
||||
datatype = columns[i].columnDef.datatype;
|
||||
}
|
||||
}
|
||||
return {
|
||||
...filter,
|
||||
fn: columnFilterFns[filter.id],
|
||||
datatype: datatype,
|
||||
};
|
||||
});
|
||||
params.set("start", "0");
|
||||
params.set("filters", JSON.stringify(filters ?? []));
|
||||
params.set("sorting", JSON.stringify(sorting ?? []));
|
||||
return params;
|
||||
}, [columnFilters, columnFilterFns, sorting, columns]);
|
||||
|
||||
const clickHandler = () => {
|
||||
setLoading(true);
|
||||
requestServer(`${EXPORT_REFAHI_PASSENGER_BOSS}?${filterParams}`, "get", {
|
||||
auth: true,
|
||||
requestOptions: { responseType: "blob" },
|
||||
})
|
||||
.then((response) => {
|
||||
const filename = `خروجی کارتابل کارگروه تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||
FileSaver.saveAs(response.data, filename);
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <DescriptionIcon />}
|
||||
onClick={clickHandler}
|
||||
>
|
||||
{t("PassengerBoss.excel_report")}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrintExcel;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user