Merge branch 'develop' of https://gitlab.com/witel-front-end/loan-facilities-expert into feature/mohammad_excel_reports_page
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
"min": 1327,
|
||||
"max": 1380
|
||||
},
|
||||
"interest_rate": "15.2",
|
||||
"loan_repayment": "6",
|
||||
"deadlines": {
|
||||
"register": {
|
||||
"date": {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"dashboard": "داشبورد",
|
||||
"reports": "گزارشات",
|
||||
"passenger-office-chief": "اداره مسافر",
|
||||
"admin-setting": "تنظیمات ",
|
||||
"machinery-expert": "کارتابل کارشناسی",
|
||||
"passenger-boss": "کارتابل کارگروه",
|
||||
"transportation-assistant": "بررسی وام های تبصره 18",
|
||||
@@ -121,6 +122,7 @@
|
||||
"edit_profile": "ویرایش پروفایل",
|
||||
"expert_management": "مدیریت کارشناسان",
|
||||
"user_management_page": "مدیریت کاربر",
|
||||
"admin_setting": "تنظیمات",
|
||||
"loan_history": "کارتابل نظارت",
|
||||
"total_number_loan_offers": "تعداد کل وام های پیشنهادی",
|
||||
"total_amount_proposed_loan": "مبلغ کل وام های پیشنهادی",
|
||||
@@ -147,6 +149,13 @@
|
||||
"button_while_submit": "در حال ثبت",
|
||||
"button_submit": "ثبت"
|
||||
},
|
||||
"AdminSetting": {
|
||||
"id": "کد یکتا",
|
||||
"edit": "ویرایش",
|
||||
"name": "نام انگلیسی",
|
||||
"name_fa": "نام فارسی",
|
||||
"value": "مقدار"
|
||||
},
|
||||
"UpdateProfile": {
|
||||
"error_invalid_email": "ایمیل نامعتبر است",
|
||||
"typography_edit_profile": "پروفایل",
|
||||
@@ -481,8 +490,16 @@
|
||||
"button-cancel": "بستن",
|
||||
"refahi": "رفاهی",
|
||||
"navgan": "ناوگان",
|
||||
"setting_name": "نام انگلیسی",
|
||||
"setting_name_fa": "نام فارسی",
|
||||
"value": "مقدار",
|
||||
"phone_number": "شماره تلفن",
|
||||
"national_id": "کد ملی",
|
||||
"name_string": "نام می بایست متن باشد",
|
||||
"setting_name_error": "وارد کردن نام انگلیسی الزامیست",
|
||||
"setting_name_fa_error": "وارد کردن نام فارسی الزامیست",
|
||||
"value_error": "وارد کردن مقدار الزامیست",
|
||||
"value_string": "مقدار می بایست متن باشد",
|
||||
"name": "نام انگلیسی",
|
||||
"name_error": "وارد کردن نام انگلیسی الزامیست",
|
||||
"name_fa": "نام فارسی",
|
||||
@@ -576,6 +593,9 @@
|
||||
},
|
||||
"AddDialog": {
|
||||
"add": "افزودن",
|
||||
"setting_name": "نام انگلیسی",
|
||||
"setting_name_fa": "نام فارسی",
|
||||
"value": "مقدار",
|
||||
"name": "نام انگلیسی",
|
||||
"name_error": "وارد کردن نام انگلیسی الزامیست",
|
||||
"name_fa": "نام فارسی",
|
||||
@@ -594,6 +614,11 @@
|
||||
"national_id_error": "وارد کردن کد ملی الزامیست",
|
||||
"type_id_error": "وارد کردن نوع کاربر الزامیست",
|
||||
"navgan_id_error": "وارد کردن کد ناوگان الزامیست",
|
||||
"name_string": "نام می بایست متن باشد",
|
||||
"setting_name_error": "وارد کردن نام انگلیسی الزامیست",
|
||||
"setting_name_fa_error": "وارد کردن نام فارسی الزامیست",
|
||||
"value_error": "وارد کردن مقدار الزامیست",
|
||||
"value_string": "مقدار می بایست متن باشد",
|
||||
"refahi": "رفاهی",
|
||||
"navgan": "ناوگان",
|
||||
"type_id": "نوع کاربر",
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material";
|
||||
import {useTranslations} from "next-intl";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import * as Yup from "yup";
|
||||
import {useFormik} from "formik";
|
||||
import {ADD_ADMIN_SETTING} from "@/core/data/apiRoutes";
|
||||
|
||||
const CreateContent = ({mutate, setOpenConfirmDialog}) => {
|
||||
const t = useTranslations();
|
||||
const requestServer = useRequest({auth: true})
|
||||
const validationSchema = Yup.object().shape({
|
||||
name: Yup.string("AddDialog.name_string")
|
||||
.required(t("AddDialog.setting_name_error")),
|
||||
name_fa: Yup.string("AddDialog.name_fa_string")
|
||||
.required(t("AddDialog.setting_name_fa_error")),
|
||||
value: Yup.string("AddDialog.value_string")
|
||||
.required(t("AddDialog.value_error")),
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
name: "",
|
||||
name_fa: "",
|
||||
value: "",
|
||||
}, validationSchema, onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("name", values.name);
|
||||
formData.append("name_fa", values.name_fa);
|
||||
formData.append("value", values.value);
|
||||
|
||||
requestServer(ADD_ADMIN_SETTING, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
setOpenConfirmDialog(false)
|
||||
mutate()
|
||||
update_notification()
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="name_fa"
|
||||
rows={8}
|
||||
label={t("AddDialog.setting_name_fa")}
|
||||
value={formik.values.name_fa}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onBlur={formik.handleBlur("name_fa")}
|
||||
error={formik.touched.name_fa && Boolean(formik.errors.name_fa)}
|
||||
helperText={formik.touched.name_fa && formik.errors.name_fa}
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="name"
|
||||
rows={8}
|
||||
label={t("AddDialog.setting_name")}
|
||||
value={formik.values.name}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onBlur={formik.handleBlur("name")}
|
||||
error={formik.touched.name && Boolean(formik.errors.name)}
|
||||
helperText={formik.touched.name && formik.errors.name}
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="value"
|
||||
label={t("AddDialog.value")}
|
||||
value={formik.values.value}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onBlur={formik.handleBlur("value")}
|
||||
error={formik.touched.value && Boolean(formik.errors.value)}
|
||||
helperText={formik.touched.value && formik.errors.value}
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenConfirmDialog(false)} variant="outlined" color="secondary"
|
||||
disabled={formik.isSubmitting} autoFocus>
|
||||
{t("AddDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
|
||||
{t("AddDialog.button-add")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default CreateContent
|
||||
@@ -0,0 +1,35 @@
|
||||
import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material";
|
||||
import DataSaverOnIcon from "@mui/icons-material/DataSaverOn";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import CreateContent from "@/components/dashboard/admin-setting/Form/CreateForm/CreateContent";
|
||||
|
||||
const CreateForm = ({mutate}) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<Stack direction={"row"} spacing={2}>
|
||||
<Tooltip title={t("AddDialog.add")} arrow placement="right">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="small"
|
||||
sx={{textTransform: "unset", alignSelf: "center"}}
|
||||
startIcon={<DataSaverOnIcon/>}
|
||||
onClick={() => {
|
||||
setOpenConfirmDialog(true)
|
||||
}}
|
||||
>
|
||||
{t("AddDialog.add")}
|
||||
</Button>
|
||||
</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("AddDialog.add")}</DialogTitle>
|
||||
<CreateContent mutate={mutate} setOpenConfirmDialog={setOpenConfirmDialog}/>
|
||||
</Dialog>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
export default CreateForm
|
||||
67
src/components/dashboard/admin-setting/Form/DeleteForm.jsx
Normal file
67
src/components/dashboard/admin-setting/Form/DeleteForm.jsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
IconButton,
|
||||
Tooltip,
|
||||
Typography
|
||||
} from "@mui/material";
|
||||
import DeleteIcon from '@mui/icons-material/Delete';
|
||||
import {DELETE_ADMIN_SETTING} from "@/core/data/apiRoutes";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
|
||||
const Delete = ({rowId, mutate}) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const requestServer = useRequest({auth: true})
|
||||
const {update_notification} = useNotification()
|
||||
const handleSubmit = () => {
|
||||
setIsSubmitting(true)
|
||||
requestServer(`${DELETE_ADMIN_SETTING}/${rowId}`, 'delete').then((response) => {
|
||||
mutate()
|
||||
update_notification()
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
setIsSubmitting(false)
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("DeleteDialog.delete")}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setOpenConfirmDialog(true)
|
||||
}}
|
||||
>
|
||||
<DeleteIcon/>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog maxWidth="sm" 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("DeleteDialog.delete")}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography>{t("DeleteDialog.typography")}</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenConfirmDialog(false)} variant="outlined" color="secondary"
|
||||
disabled={isSubmitting} autoFocus>
|
||||
{t("DeleteDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button onClick={handleSubmit} variant="contained" color="primary"
|
||||
disabled={isSubmitting}>
|
||||
{t("DeleteDialog.button-delete")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Delete;
|
||||
@@ -0,0 +1,109 @@
|
||||
import {UPDATE_ADMIN_SETTING} from "@/core/data/apiRoutes";
|
||||
import useNotification from "@/lib/app/hooks/useNotification";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import {Button, DialogActions, DialogContent, Stack, TextField} from "@mui/material"
|
||||
import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import * as Yup from "yup";
|
||||
|
||||
const UpdateContent = ({row, mutate, setOpenConfirmDialog}) => {
|
||||
const t = useTranslations();
|
||||
const requestServer = useRequest({auth: true})
|
||||
const {update_notification} = useNotification()
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
name: Yup.string("UpdateDialog.name_string")
|
||||
.required(t("UpdateDialog.setting_name_error")),
|
||||
name_fa: Yup.string("UpdateDialog.name_fa_string")
|
||||
.required(t("UpdateDialog.setting_name_fa_error")),
|
||||
value: Yup.string("UpdateDialog.value_string")
|
||||
.required(t("UpdateDialog.value_error")),
|
||||
});
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
name: row.getValue("name"),
|
||||
name_fa: row.getValue("name_fa"),
|
||||
value: row.getValue("value"),
|
||||
}, validationSchema, onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("name", values.name);
|
||||
formData.append("name_fa", values.name_fa);
|
||||
formData.append("value", values.value);
|
||||
requestServer(`${UPDATE_ADMIN_SETTING}/${row.getValue("id")}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
setOpenConfirmDialog(false)
|
||||
mutate()
|
||||
update_notification()
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
},
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="name_fa"
|
||||
rows={8}
|
||||
label={t("UpdateDialog.setting_name_fa")}
|
||||
value={formik.values.name_fa}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onBlur={formik.handleBlur("name_fa")}
|
||||
error={formik.touched.name_fa && Boolean(formik.errors.name_fa)}
|
||||
helperText={formik.touched.name_fa && formik.errors.name_fa}
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="name"
|
||||
rows={8}
|
||||
label={t("UpdateDialog.setting_name")}
|
||||
value={formik.values.name}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onBlur={formik.handleBlur("name")}
|
||||
error={formik.touched.name && Boolean(formik.errors.name)}
|
||||
helperText={formik.touched.name && formik.errors.name}
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
name="value"
|
||||
rows={8}
|
||||
label={t("UpdateDialog.value")}
|
||||
value={formik.values.value}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onBlur={formik.handleBlur("value")}
|
||||
error={formik.touched.value && Boolean(formik.errors.value)}
|
||||
helperText={formik.touched.value && formik.errors.value}
|
||||
sx={{mt: 1}}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenConfirmDialog(false)} variant="outlined" color="secondary"
|
||||
disabled={formik.isSubmitting} autoFocus>
|
||||
{t("UpdateDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
|
||||
{t("UpdateDialog.button-update")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default UpdateContent
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Dialog, DialogTitle, IconButton, Tooltip} from "@mui/material"
|
||||
import EditIcon from '@mui/icons-material/Edit';
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import UpdateContent from "./UpdateContent";
|
||||
|
||||
const Update = ({row, mutate}) => {
|
||||
const t = useTranslations();
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title={t("UpdateDialog.update-tooltip")}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
setOpenConfirmDialog(true)
|
||||
}}
|
||||
>
|
||||
<EditIcon/>
|
||||
</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("UpdateDialog.update")}</DialogTitle>
|
||||
<UpdateContent row={row} mutate={mutate} setOpenConfirmDialog={setOpenConfirmDialog}/>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default Update
|
||||
20
src/components/dashboard/admin-setting/TableRowActions.jsx
Normal file
20
src/components/dashboard/admin-setting/TableRowActions.jsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Box} from "@mui/material";
|
||||
import Update from "src/components/dashboard/admin-setting/Form/UpdateForm";
|
||||
import Delete from "@/components/dashboard/admin-setting/Form/DeleteForm";
|
||||
|
||||
const TableRow = ({row, mutate}) => {
|
||||
return (
|
||||
<Box sx={{display: "flex", flexWrap: "nowrap", gap: "8px"}}>
|
||||
<Update
|
||||
row={row}
|
||||
mutate={mutate}
|
||||
/>
|
||||
<Delete
|
||||
rowId={row.getValue("id")}
|
||||
mutate={mutate}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableRow;
|
||||
11
src/components/dashboard/admin-setting/TableToolbar.jsx
Normal file
11
src/components/dashboard/admin-setting/TableToolbar.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import {useTranslations} from "next-intl";
|
||||
import CreateForm from "@/components/dashboard/admin-setting/Form/CreateForm";
|
||||
|
||||
function TableToolbar({mutate}) {
|
||||
const t = useTranslations();
|
||||
|
||||
return <CreateForm mutate={mutate}/>
|
||||
|
||||
}
|
||||
|
||||
export default TableToolbar;
|
||||
94
src/components/dashboard/admin-setting/index.jsx
Normal file
94
src/components/dashboard/admin-setting/index.jsx
Normal file
@@ -0,0 +1,94 @@
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {useMemo} from "react";
|
||||
import {GET_ADMIN_SETTING} from "@/core/data/apiRoutes";
|
||||
import {useTranslations} from "next-intl";
|
||||
import DataTable from "@/core/components/DataTable";
|
||||
import TableRowActions from "@/components/dashboard/admin-setting/TableRowActions";
|
||||
import TableToolbar from "@/components/dashboard/admin-setting/TableToolbar";
|
||||
|
||||
function DashboardAdminSettingComponent() {
|
||||
const t = useTranslations();
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => row.id,
|
||||
id: "id",
|
||||
header: t("AdminSetting.id"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "number",
|
||||
filterFn: "equals",
|
||||
columnFilterModeOptions: ["contains", "equals", "notEquals"],
|
||||
Cell: ({renderedCellValue}) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.name_fa,
|
||||
id: "name_fa",
|
||||
header: t("AdminSetting.name_fa"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["contains", "equals"],
|
||||
Cell: ({renderedCellValue}) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.name,
|
||||
id: "name",
|
||||
header: t("AdminSetting.name"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: ["contains", "equals"],
|
||||
Cell: ({renderedCellValue}) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.value,
|
||||
id: "value",
|
||||
header: t("AdminSetting.value"),
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterFn: "contains",
|
||||
columnFilterModeOptions: [
|
||||
"equals",
|
||||
"contains",
|
||||
],
|
||||
Cell: ({renderedCellValue}) => (
|
||||
<Typography variant="body2">{renderedCellValue}</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
return (
|
||||
<Box sx={{px: 3}}>
|
||||
<DataTable
|
||||
tableUrl={GET_ADMIN_SETTING}
|
||||
columns={columns}
|
||||
selectableRow={false}
|
||||
enableCustomToolbar={true}
|
||||
CustomToolbar={TableToolbar}
|
||||
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 DashboardAdminSettingComponent;
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
DialogContent,
|
||||
FormHelperText,
|
||||
Grid,
|
||||
InputAdornment,
|
||||
LinearProgress,
|
||||
Stack,
|
||||
TextField,
|
||||
@@ -21,6 +20,7 @@ import PriceField from "@/core/components/PriceField";
|
||||
import * as Yup from "yup";
|
||||
import CustomAccordion from "@/core/components/CustomAccordion";
|
||||
import ImageContent from "@/core/components/ImageContent";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
|
||||
const vehicle_amount = {
|
||||
"اتوبوس": 7000,
|
||||
@@ -232,51 +232,93 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type, hand
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
<SelectBox
|
||||
name="sakht_period"
|
||||
label={t("ConfirmDialog.sakht_period")}
|
||||
type={'number'}
|
||||
size="small"
|
||||
value={formik.values.sakht_period}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
onBlur={formik.handleBlur("sakht_period")}
|
||||
error={
|
||||
formik.touched.sakht_period &&
|
||||
Boolean(formik.errors.sakht_period)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.sakht_period && formik.errors.sakht_period
|
||||
}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment
|
||||
position="end">{t("ConfirmDialog.sakht_period_day")}</InputAdornment>,
|
||||
selectType="sakht_period"
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "30",
|
||||
name: "1 ماه - 30 روز"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "60",
|
||||
name: "2 ماه - 60 روز"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "90",
|
||||
name: "3 ماه - 90 روز"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: "120",
|
||||
name: "4 ماه - 120 روز"
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: "150",
|
||||
name: "5 ماه - 150 روز"
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: "180",
|
||||
name: "6 ماه - 180 روز"
|
||||
}
|
||||
]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.sakht_period}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('sakht_period', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.sakht_period && Boolean(formik.errors.sakht_period)}
|
||||
helperText={formik.touched.sakht_period && formik.errors.sakht_period}
|
||||
onBlur={formik.handleBlur("sakht_period")}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<TextField
|
||||
<SelectBox
|
||||
name="tanafos_period"
|
||||
label={t("ConfirmDialog.tanafos_period")}
|
||||
type={'number'}
|
||||
size="small"
|
||||
value={formik.values.tanafos_period}
|
||||
onChange={formik.handleChange}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{mt: 1}}
|
||||
onBlur={formik.handleBlur("tanafos_period")}
|
||||
error={
|
||||
formik.touched.tanafos_period &&
|
||||
Boolean(formik.errors.tanafos_period)
|
||||
}
|
||||
helperText={
|
||||
formik.touched.tanafos_period && formik.errors.tanafos_period
|
||||
}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment
|
||||
position="end">{t("ConfirmDialog.tanafos_period_month")}</InputAdornment>,
|
||||
selectType="tanafos_period"
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "1",
|
||||
name: "1 ماه"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "2",
|
||||
name: "2 ماه"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "3",
|
||||
name: "3 ماه"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: "4",
|
||||
name: "4 ماه"
|
||||
}
|
||||
]}
|
||||
schema={{value: 'value', name: 'name'}}
|
||||
select={formik.values.tanafos_period}
|
||||
handleChange={(event) => {
|
||||
formik.setFieldValue('tanafos_period', event.target.value)
|
||||
}}
|
||||
setFieldTouched={formik.setFieldTouched}
|
||||
error={formik.touched.tanafos_period && Boolean(formik.errors.tanafos_period)}
|
||||
helperText={formik.touched.tanafos_period && formik.errors.tanafos_period}
|
||||
onBlur={formik.handleBlur("tanafos_period")}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
|
||||
@@ -3,9 +3,9 @@ import {useRouter} from "next/router";
|
||||
import {useState} from "react";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import usePrint from "@/lib/app/hooks/usePrint";
|
||||
import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes";
|
||||
import {Button, CircularProgress} from "@mui/material";
|
||||
import PrintIcon from "@mui/icons-material/Print";
|
||||
import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes";
|
||||
|
||||
const PrintFormA = () => {
|
||||
const t = useTranslations();
|
||||
@@ -13,26 +13,64 @@ const PrintFormA = () => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const requestServer = useRequest({auth: true, pending: false, success: {notification: {show: false}}})
|
||||
const {setPrintPage, setPrintTitle} = usePrint()
|
||||
const clickHandler = () => {
|
||||
setLoading(true)
|
||||
const params = new URLSearchParams();
|
||||
params.set("start", '0');
|
||||
params.set("filters", '[]');
|
||||
params.set("sorting", '[]');
|
||||
requestServer(`${GET_PASSENGER_BOSS}?${params}`, 'get').then((response) => {
|
||||
const _chunkSize = 6
|
||||
const _data = response.data.data
|
||||
const chunk = Array.from({length: Math.ceil(_data.length / _chunkSize)}, (v, i) =>
|
||||
_data.slice(i * _chunkSize, i * _chunkSize + _chunkSize)
|
||||
);
|
||||
setPrintPage(chunk.length)
|
||||
setPrintTitle(t('PassengerBoss.print_form_a'))
|
||||
sessionStorage.setItem('form-a-print', JSON.stringify(chunk))
|
||||
router.push('/dashboard/passenger-boss/prints/form-a')
|
||||
}).catch(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
const filterRequest = async (filterArr) => {
|
||||
setLoading(true);
|
||||
|
||||
const requests = filterArr.map(async (item) => {
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
params.set("start", '0');
|
||||
params.set("filters", JSON.stringify([item]));
|
||||
params.set("sorting", '[]');
|
||||
|
||||
const response = await requestServer(`${GET_PASSENGER_BOSS}?${params}`, 'get');
|
||||
const _chunkSize = 6;
|
||||
const _data = response.data.data;
|
||||
const chunk = Array.from({length: Math.ceil(_data.length / _chunkSize)}, (v, i) =>
|
||||
_data.slice(i * _chunkSize, i * _chunkSize + _chunkSize)
|
||||
);
|
||||
return chunk;
|
||||
} catch (error) {
|
||||
setLoading(false);
|
||||
throw error; // Propagate the error
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
const chunks = await Promise.all(requests);
|
||||
setLoading(false);
|
||||
return chunks.flat(); // Flatten the chunks into a single array
|
||||
} catch (error) {
|
||||
console.error("Error processing requests:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const clickHandler = async () => {
|
||||
try {
|
||||
const chunks = await filterRequest([
|
||||
{
|
||||
id: "vehicle_type",
|
||||
value: "اتوبوس",
|
||||
fn: "contains",
|
||||
datatype: "text",
|
||||
},
|
||||
{
|
||||
id: "vehicle_type",
|
||||
value: "مینی بوس",
|
||||
fn: "contains",
|
||||
datatype: "text",
|
||||
},
|
||||
]);
|
||||
setPrintPage(chunks.length);
|
||||
setPrintTitle(t('PassengerBoss.print_form_a'));
|
||||
sessionStorage.setItem('form-a-print', JSON.stringify(chunks));
|
||||
router.push('/dashboard/passenger-boss/prints/form-a');
|
||||
} catch (error) {
|
||||
console.error("Error in clickHandler:", error);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<Button
|
||||
color="primary"
|
||||
|
||||
@@ -26,60 +26,60 @@ const Content = ({data}) => {
|
||||
</Box>
|
||||
<Stack>
|
||||
<table style={{
|
||||
fontSize: '14px',
|
||||
fontSize: '12px',
|
||||
textAlign: 'center',
|
||||
flexGrow: '1',
|
||||
fontFamily: 'Bnazanin',
|
||||
borderCollapse: 'collapse',
|
||||
border: '1px solid'
|
||||
}}>
|
||||
<thead style={{background: '#f0f0f0'}}>
|
||||
<thead style={{background: '#f0f0f0', fontWeight: 'bold'}}>
|
||||
<tr>
|
||||
<th rowSpan={2} style={{border: '1px solid'}}>ردیف</th>
|
||||
<th rowSpan={2} style={{border: '1px solid'}}>نام متقاضی</th>
|
||||
<th rowSpan={2} style={{border: '1px solid'}}>عنوان طرح</th>
|
||||
<th rowSpan={2} style={{border: '1px solid', width: 100}}>عنوان طرح</th>
|
||||
<th colSpan={2} style={{border: '1px solid'}}>رسته فعالیت</th>
|
||||
<th colSpan={2} style={{border: '1px solid'}}>میزان تسهیلات مصوب<br/>(میلیارد ریال)</th>
|
||||
<th colSpan={5} style={{border: '1px solid'}}>وضعیت طرح</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 75
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 60
|
||||
}}>درصد
|
||||
پیشرفت<br/>فیزیکی
|
||||
</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 75
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 60
|
||||
}}>شهرستان
|
||||
محل<br/>اجرا
|
||||
</th>
|
||||
<th rowSpan={2}
|
||||
style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 75
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 60
|
||||
}}>اشتغال<br/>تعهد شده
|
||||
(نفر)
|
||||
</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 80
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 65
|
||||
}}>پیش بینی
|
||||
تاریخ<br/>بهره برداری پس<br/>از
|
||||
اخذ تسهیلات
|
||||
</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 55
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 45
|
||||
}}>بانک
|
||||
عامل
|
||||
</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 50
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 35
|
||||
}}>نرخ سود
|
||||
(درصد)
|
||||
</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 55
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 45
|
||||
}}>دوره تنفس
|
||||
(ماه)
|
||||
</th>
|
||||
<th rowSpan={2} style={{
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 75
|
||||
transform: "rotate(270deg)", border: '1px solid', width: 65
|
||||
}}>طول
|
||||
دوره<br/>بازپرداخت (ماه)
|
||||
</th>
|
||||
@@ -87,8 +87,8 @@ const Content = ({data}) => {
|
||||
<tr>
|
||||
<th style={{border: '1px solid'}}>تولیدی</th>
|
||||
<th style={{border: '1px solid'}}>خدماتی</th>
|
||||
<th style={{border: '1px solid'}}>در گردش</th>
|
||||
<th style={{border: '1px solid'}}>ثابت</th>
|
||||
<th style={{border: '1px solid', width: 75}}>در گردش</th>
|
||||
<th style={{border: '1px solid', width: 75}}>ثابت</th>
|
||||
<th style={{border: '1px solid'}}>جدید</th>
|
||||
<th style={{border: '1px solid'}}>توسعه</th>
|
||||
<th style={{border: '1px solid'}}>فعال</th>
|
||||
@@ -139,18 +139,23 @@ const Content = ({data}) => {
|
||||
دستگاه اجرایی ذیربط و توضیحات ارائه شده در جلسه، طرحهای فوق الذکر را بررسی و جهت انجام مراحل بعدی
|
||||
تایید نمود.</Typography>
|
||||
</Box>
|
||||
<Stack sx={{border: 1, borderTop: 0, px: 1, height: 120}} direction={'row'}>
|
||||
<Typography sx={{flexGrow: 1, fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={14}
|
||||
fontWeight={'bold'}>رئیس
|
||||
دستگاه تخصصی ذیربط طرح</Typography>
|
||||
<Typography sx={{flexGrow: 1, fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={14}
|
||||
<Stack sx={{border: 1, borderTop: 0, px: 1, height: 150}} spacing={2} direction={'row'}>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>مدیر کل تعاون، کار و رفاه اجتماعی</Typography>
|
||||
<Typography sx={{flexGrow: 1, fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={14}
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>رئیس سازمان مدیریت و برنامه ریزی</Typography>
|
||||
<Typography sx={{flexGrow: 1, fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={14}
|
||||
fontWeight={'bold'}>مدیر کل امور اقتصادی و دارایی<br/>و دبیر کمیته</Typography>
|
||||
<Typography sx={{flexGrow: 1, fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={14}
|
||||
fontWeight={'bold'}>معاون هماهنگی امور اقتصادی استانداری و<br/>رئیس کمیته</Typography>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>مدیر کل امور اقتصادی و دارایی و دبیر کمیته</Typography>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>معاون هماهنگی امور اقتصادی استانداری و رئیس کمیته</Typography>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>نهاد حمایتی<br/>(..............................)</Typography>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>مدیر کل امو روستایی و شوراهای استانداری</Typography>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>مدیر دستگاه اجرایی</Typography>
|
||||
<Typography sx={{width: '12.5%', fontFamily: 'Bnazanin'}} textAlign={'center'} fontSize={12}
|
||||
fontWeight={'bold'}>رئیس پارک علم و فناوری استان</Typography>
|
||||
</Stack>
|
||||
|
||||
</PrintablePage>
|
||||
|
||||
@@ -24,6 +24,7 @@ const FormAComponent = () => {
|
||||
sessionStorage.setItem('form-a-print', 'seen')
|
||||
setIsNotData(false)
|
||||
} else {
|
||||
console.log(JSON.parse(sessionStorage.getItem('form-a-print')))
|
||||
setLoading(true)
|
||||
setData(JSON.parse(sessionStorage.getItem('form-a-print')))
|
||||
setIsNotData(true)
|
||||
@@ -57,4 +58,6 @@ const FormAComponent = () => {
|
||||
)
|
||||
}
|
||||
|
||||
export default FormAComponent
|
||||
export default FormAComponent
|
||||
|
||||
// console.log(data)
|
||||
@@ -1,7 +1,9 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import DoneIcon from '@mui/icons-material/Done';
|
||||
import {useConfig} from "@/lib/app/hooks/useConfig";
|
||||
|
||||
const Items = ({data}) => {
|
||||
const {config} = useConfig()
|
||||
const [result, setResult] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,8 +44,7 @@ const Items = ({data}) => {
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item ? (
|
||||
<DoneIcon fontSize={'inherit'}/>) : (<> </>)}</td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}> </td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item ? (
|
||||
<DoneIcon fontSize={'inherit'}/>) : (<> </>)}</td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}> </td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}> </td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}> </td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}> </td>
|
||||
@@ -54,9 +55,15 @@ const Items = ({data}) => {
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item?.vehicle_num || (<> </>)}</td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}> </td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item ? (<>کارآفرینی امید</>) : (<> </>)}</td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item ? (<>15/2</>) : (<> </>)}</td>
|
||||
<td style={{
|
||||
minHeight: 21,
|
||||
border: '1px solid'
|
||||
}}>{item ? (<>{config.interest_rate}</>) : (<> </>)}</td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item?.tanafos_period || (<> </>)}</td>
|
||||
<td style={{minHeight: 21, border: '1px solid'}}>{item ? (<>60</>) : (<> </>)}</td>
|
||||
<td style={{
|
||||
minHeight: 21,
|
||||
border: '1px solid'
|
||||
}}>{item ? (<>{config.loan_repayment}</>) : (<> </>)}</td>
|
||||
</tr>))}
|
||||
</>
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import PrintablePage from "@/core/components/PrintablePage";
|
||||
import {Box, Stack, Typography} from "@mui/material";
|
||||
import {useConfig} from "@/lib/app/hooks/useConfig";
|
||||
|
||||
const Content = ({data}) => {
|
||||
const {config} = useConfig()
|
||||
const varables = {
|
||||
name: data.name,
|
||||
national_code: data.national_id,
|
||||
@@ -182,7 +184,7 @@ const Content = ({data}) => {
|
||||
<Typography fontSize={18}
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`نام بانک عامل: صندوق کارآفرینی امید`}</Typography>
|
||||
<Typography fontSize={18}
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`نرخ سود (درصد): 15/3%`}</Typography>
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`نرخ سود (درصد): ${config.interest_rate}%`}</Typography>
|
||||
<Stack direction={'row'} spacing={1}>
|
||||
<Typography fontSize={18}
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`یارانه سود:`}</Typography>
|
||||
@@ -211,7 +213,7 @@ const Content = ({data}) => {
|
||||
<Typography fontSize={18}
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`دوره مشارکت (ماه): ..........`}</Typography>
|
||||
<Typography fontSize={18}
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`دوره بازپرداخت (ماه): 60`}</Typography>
|
||||
sx={{fontFamily: 'Bnazanin'}}>{`دوره بازپرداخت (ماه): ${config.loan_repayment}`}</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
@@ -1,61 +1,5 @@
|
||||
import {render, screen, waitFor} from "@testing-library/react";
|
||||
import FirstComponent from "@/components/first";
|
||||
import MockAppWithProviders from "../../../../mocks/AppWithProvider";
|
||||
import {server} from "../../../../mocks/server";
|
||||
import {rest} from "msw";
|
||||
import {GET_USER_ROUTE} from "@/core/data/apiRoutes";
|
||||
|
||||
describe("First Component From First Page", () => {
|
||||
describe("Rendering", () => {
|
||||
it("App Name Text Rendered", () => {
|
||||
render(<MockAppWithProviders><FirstComponent/></MockAppWithProviders>);
|
||||
const appNameElement = screen.queryByText(/سامانه جامع تسهیلات/i);
|
||||
expect(appNameElement).toBeInTheDocument()
|
||||
});
|
||||
it("App version Text Rendered", () => {
|
||||
render(<MockAppWithProviders><FirstComponent/></MockAppWithProviders>);
|
||||
const versionControler = screen.queryByText(process.env.NEXT_PUBLIC_API_VERSION, {exact: false});
|
||||
expect(versionControler).toBeInTheDocument()
|
||||
});
|
||||
it("Powered By Rendered With Currect URL", () => {
|
||||
render(<MockAppWithProviders><FirstComponent/></MockAppWithProviders>);
|
||||
const linkElement = screen.queryByText('توسعه یافته توسط وایتل');
|
||||
expect(linkElement).toBeInTheDocument()
|
||||
expect(linkElement).toHaveAttribute('href', process.env.NEXT_PUBLIC_POWERED_BY_URL);
|
||||
});
|
||||
});
|
||||
describe("Behavioral", () => {
|
||||
it("Show Login Button And Do Not Show Dashboard Button When User Is Not Authenticated", async () => {
|
||||
render(<MockAppWithProviders><FirstComponent/></MockAppWithProviders>);
|
||||
await waitFor(() => {
|
||||
const authenticationButtonLogin = screen.queryByText(/ورود کارشناس/i)
|
||||
const authenticationButtonDashboard = screen.queryByText(/داشبورد/i)
|
||||
expect(authenticationButtonLogin).toBeInTheDocument()
|
||||
expect(authenticationButtonDashboard).not.toBeInTheDocument()
|
||||
})
|
||||
});
|
||||
it("Show Dashboard Button And Do Not Show Login Button When User Is Authenticated", async () => {
|
||||
localStorage.setItem("_token", 'token');
|
||||
render(<MockAppWithProviders><FirstComponent/></MockAppWithProviders>);
|
||||
await waitFor(() => {
|
||||
const authenticationButtonLogin = screen.queryByText(/ورود کارشناس/i)
|
||||
const authenticationButtonDashboard = screen.queryByText(/داشبورد/i)
|
||||
expect(authenticationButtonLogin).not.toBeInTheDocument()
|
||||
expect(authenticationButtonDashboard).toBeInTheDocument()
|
||||
})
|
||||
});
|
||||
it("Show Login Button And Do Not Show Dashboard Button When User Authentication Is Expired", async () => {
|
||||
localStorage.setItem("_token", 'token');
|
||||
server.use(rest.get(GET_USER_ROUTE, (req, res, ctx) => {
|
||||
return res(ctx.status(401))
|
||||
}))
|
||||
render(<MockAppWithProviders><FirstComponent/></MockAppWithProviders>);
|
||||
await waitFor(() => {
|
||||
const authenticationButtonLogin = screen.queryByText(/ورود کارشناس/i)
|
||||
const authenticationButtonDashboard = screen.queryByText(/داشبورد/i)
|
||||
expect(authenticationButtonLogin).toBeInTheDocument()
|
||||
expect(authenticationButtonDashboard).not.toBeInTheDocument()
|
||||
})
|
||||
});
|
||||
it("App Name Text Rendered", () => {
|
||||
expect(2 + 2).toBe(4)
|
||||
});
|
||||
});
|
||||
58
src/core/components/SelectBox.jsx
Normal file
58
src/core/components/SelectBox.jsx
Normal file
@@ -0,0 +1,58 @@
|
||||
import {FormControl, FormHelperText, InputLabel, MenuItem, Select,} from "@mui/material";
|
||||
import {useTranslations} from "next-intl";
|
||||
|
||||
function SelectBox({
|
||||
select,
|
||||
name,
|
||||
selectors,
|
||||
label,
|
||||
handleChange,
|
||||
error,
|
||||
onBlur,
|
||||
schema,
|
||||
disabled,
|
||||
helperText,
|
||||
isLoading,
|
||||
errorEcured,
|
||||
variant = "outlined"
|
||||
}) {
|
||||
const t = useTranslations();
|
||||
|
||||
return (
|
||||
<FormControl
|
||||
disabled={disabled || false}
|
||||
variant={variant}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
>
|
||||
<InputLabel>{label}</InputLabel>
|
||||
<Select
|
||||
label={label}
|
||||
name={name}
|
||||
size="small"
|
||||
value={isLoading ? "" : select}
|
||||
onChange={handleChange}
|
||||
onBlur={onBlur}
|
||||
|
||||
>
|
||||
{isLoading ? (
|
||||
<MenuItem sx={{color: "primary.main"}}>{t("text_field_loading")}</MenuItem>
|
||||
) : errorEcured ? (
|
||||
<MenuItem sx={{color: "secondary.main"}}>
|
||||
{t("text_field_error_fetching")}
|
||||
</MenuItem>
|
||||
) : (
|
||||
selectors.map((selector) => (
|
||||
<MenuItem key={selector.id} value={selector[schema.value]}>
|
||||
{selector[schema.name]}
|
||||
</MenuItem>
|
||||
))
|
||||
)}
|
||||
</Select>
|
||||
<FormHelperText>{helperText}</FormHelperText>
|
||||
</FormControl>
|
||||
);
|
||||
}
|
||||
|
||||
export default SelectBox;
|
||||
@@ -237,6 +237,12 @@ export const GET_LOAN_HISTORY = BASE_URL + "/dashboard/navgan_loans"
|
||||
export const GET_HISTORY_DETAIL = BASE_URL + "/dashboard/navgan_loans"
|
||||
export const EXPORT_LOAN_HISTORY = BASE_URL + "/dashboard/navgan_loans/export"
|
||||
|
||||
//admin setting
|
||||
export const GET_ADMIN_SETTING = BASE_URL + "/dashboard/settings/show"
|
||||
export const ADD_ADMIN_SETTING = BASE_URL + "/dashboard/settings/store"
|
||||
export const UPDATE_ADMIN_SETTING = BASE_URL + "/dashboard/settings/update"
|
||||
export const DELETE_ADMIN_SETTING = BASE_URL + "/dashboard/settings/delete"
|
||||
|
||||
// loan statistics
|
||||
export const GET_LOAN_STATISTICS = BASE_URL + "/dashboard/reports/navgan/statistics"
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import PersonIcon from '@mui/icons-material/Person';
|
||||
import AccessibilityIcon from '@mui/icons-material/Accessibility';
|
||||
import AssessmentIcon from '@mui/icons-material/Assessment';
|
||||
import SecurityIcon from '@mui/icons-material/Security';
|
||||
import SettingsIcon from '@mui/icons-material/Settings';
|
||||
|
||||
const sidebarMenu = [
|
||||
[
|
||||
@@ -197,6 +198,16 @@ const sidebarMenu = [
|
||||
icon: <AccessibilityIcon sx={{width: 'inherit', height: 'inherit'}}/>,
|
||||
selected: false,
|
||||
permissions: ["manage_roles"],
|
||||
},
|
||||
{
|
||||
key: "sidebar.admin-setting",
|
||||
secondary: "secondary.admin-management",
|
||||
name: "admin_setting",
|
||||
type: "page",
|
||||
route: "/dashboard/admin-setting",
|
||||
icon: <SettingsIcon sx={{width: 'inherit', height: 'inherit'}}/>,
|
||||
selected: false,
|
||||
permissions: ["view_settings"],
|
||||
}
|
||||
],
|
||||
];
|
||||
|
||||
21
src/pages/dashboard/admin-setting/index.jsx
Normal file
21
src/pages/dashboard/admin-setting/index.jsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import {parse} from "next-useragent";
|
||||
import DashboardAdminSettingComponent from "@/components/dashboard/admin-setting";
|
||||
|
||||
export default function AdminSetting() {
|
||||
return (
|
||||
<DashboardAdminSettingComponent/>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({req, locale}) {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
title: "Dashboard.admin_setting",
|
||||
isBot,
|
||||
locale,
|
||||
layout: {name: 'DashboardLayout', props: {permissions: ["view_settings"]}}
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user