change config file structure
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
"@mui/icons-material": "^5.11.16",
|
||||
"@mui/lab": "^5.0.0-alpha.152",
|
||||
"@mui/material": "^5.12.0",
|
||||
"@witel/webapp-builder": "^1.2.3",
|
||||
"@mui/x-date-pickers": "^6.18.5",
|
||||
"@witel/webapp-builder": "^1.2.4",
|
||||
"axios": "^1.4.0",
|
||||
"colord": "^2.9.3",
|
||||
"date-fns-jalali": "^2.13.0-0",
|
||||
|
||||
@@ -1,37 +1,41 @@
|
||||
{
|
||||
"middlewares": {},
|
||||
"time_lines": {
|
||||
"navgan_first_page": [
|
||||
{
|
||||
"date": {
|
||||
"from": "1402/09/01",
|
||||
"to": "1402/09/10"
|
||||
},
|
||||
"label": {
|
||||
"primary": "ثبت نام متقاضی",
|
||||
"secondary": "ثبت نام متقاضیان واجد شرایط"
|
||||
}
|
||||
"deadlines": {
|
||||
"register": {
|
||||
"date": {
|
||||
"from": "1402/09/01",
|
||||
"to": "1402/09/10"
|
||||
},
|
||||
{
|
||||
"date": {
|
||||
"from": "1402/09/15",
|
||||
"to": "1402/11/10"
|
||||
},
|
||||
"label": {
|
||||
"primary": "صحت سنجی متقاضیان",
|
||||
"secondary": "بررسی و کارشناسی درخواست ها"
|
||||
}
|
||||
"messages": {
|
||||
"before": "ثبت نام هنوز شروع نشده",
|
||||
"after": "زمان ثبت نام به اتمام رسید"
|
||||
},
|
||||
{
|
||||
"date": {
|
||||
"from": "1402/11/10",
|
||||
"to": "1402/12/20"
|
||||
},
|
||||
"label": {
|
||||
"primary": "ارجاع به بانک",
|
||||
"secondary": "فرآیند معرفی ضامن و پرداخت"
|
||||
}
|
||||
"timeline_label": {
|
||||
"primary": "ثبت نام متقاضی",
|
||||
"secondary": "ثبت نام متقاضیان واجد شرایط"
|
||||
}
|
||||
]
|
||||
},
|
||||
"validation": {
|
||||
"date": {
|
||||
"from": "1402/09/15",
|
||||
"to": "1402/11/10"
|
||||
},
|
||||
"messages": {},
|
||||
"timeline_label": {
|
||||
"primary": "صحت سنجی متقاضیان",
|
||||
"secondary": "بررسی و کارشناسی درخواست ها"
|
||||
}
|
||||
},
|
||||
"done": {
|
||||
"date": {
|
||||
"from": "1402/11/10",
|
||||
"to": "1402/12/20"
|
||||
},
|
||||
"messages": {},
|
||||
"timeline_label": {
|
||||
"primary": "ارجاع به بانک",
|
||||
"secondary": "فرآیند معرفی ضامن و پرداخت"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,16 @@ const TimeLineDetails = () => {
|
||||
const {config} = useConfig()
|
||||
const [timeLineList, setTimeLineList] = useState([])
|
||||
|
||||
const deadlines = Object.keys(config.deadlines).map(key => ({
|
||||
type: key,
|
||||
...config.deadlines[key]
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
let tempArr = []
|
||||
for (const timeLine of config.time_lines.navgan_first_page) {
|
||||
for (const timeLine of deadlines) {
|
||||
let temp = {}
|
||||
temp['label'] = timeLine.label
|
||||
temp['label'] = timeLine.timeline_label
|
||||
temp['date'] = moment(timeLine.date.from, 'jYYYY/jMM/jDD').locale('fa').format('jD jMMMM')
|
||||
const fromDate = moment(timeLine.date.from, 'jYYYY/jMM/jDD')
|
||||
const toDate = moment(timeLine.date.to, 'jYYYY/jMM/jDD')
|
||||
|
||||
41
src/middlewares/Deadline.jsx
Normal file
41
src/middlewares/Deadline.jsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import {CenterLayout, FullPageLayout, useConfig} from "@witel/webapp-builder";
|
||||
import moment from "jalali-moment";
|
||||
import SvgMaintenance from "@/core/components/svgs/SvgMaintenance";
|
||||
import {Typography} from "@mui/material";
|
||||
|
||||
const DeadlineMiddleware = ({children, type = '', withMessage = false}) => {
|
||||
const {config} = useConfig()
|
||||
const middleware = config.deadlines[type]
|
||||
|
||||
if (!middleware) return children
|
||||
|
||||
const fromDate = moment(middleware.date.from, 'jYYYY/jMM/jDD')
|
||||
const toDate = moment(middleware.date.to, 'jYYYY/jMM/jDD')
|
||||
const today = moment()
|
||||
|
||||
if (today.isBetween(fromDate, toDate, null, '[]')) {
|
||||
return children
|
||||
} else if (today.isAfter(toDate, null)) {
|
||||
if (!withMessage) return
|
||||
return (
|
||||
<FullPageLayout>
|
||||
<CenterLayout spacing={3}>
|
||||
<SvgMaintenance height={200} width={200}/>
|
||||
<Typography>{middleware.messages.after || ''}</Typography>
|
||||
</CenterLayout>
|
||||
</FullPageLayout>
|
||||
)
|
||||
} else if (today.isBefore(fromDate, null)) {
|
||||
if (!withMessage) return
|
||||
return (
|
||||
<FullPageLayout>
|
||||
<CenterLayout spacing={3}>
|
||||
<SvgMaintenance height={200} width={200}/>
|
||||
<Typography>{middleware.messages.before || ''}</Typography>
|
||||
</CenterLayout>
|
||||
</FullPageLayout>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default DeadlineMiddleware
|
||||
@@ -1,9 +1,12 @@
|
||||
import LoanRequestComponent from "@/components/dashboard/navgan/add-request-loan";
|
||||
import {globalServerProps} from "@/core/utils/globalServerProps";
|
||||
import DeadlineMiddleware from "@/middlewares/Deadline";
|
||||
|
||||
export default function AddLoanRequest() {
|
||||
return (
|
||||
<LoanRequestComponent/>
|
||||
<DeadlineMiddleware type={'register'} withMessage={true}>
|
||||
<LoanRequestComponent/>
|
||||
</DeadlineMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user