diff --git a/package.json b/package.json index 18812a0..35ba316 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/public/config.json.example b/public/config.json.example index abeeda5..bf732fa 100644 --- a/public/config.json.example +++ b/public/config.json.example @@ -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": "فرآیند معرفی ضامن و پرداخت" + } + } } } \ No newline at end of file diff --git a/src/components/first/LoanDescription/TimeLineDetails.jsx b/src/components/first/LoanDescription/TimeLineDetails.jsx index feae261..ec274bf 100644 --- a/src/components/first/LoanDescription/TimeLineDetails.jsx +++ b/src/components/first/LoanDescription/TimeLineDetails.jsx @@ -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') diff --git a/src/middlewares/Deadline.jsx b/src/middlewares/Deadline.jsx new file mode 100644 index 0000000..796ee54 --- /dev/null +++ b/src/middlewares/Deadline.jsx @@ -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 ( + + + + {middleware.messages.after || ''} + + + ) + } else if (today.isBefore(fromDate, null)) { + if (!withMessage) return + return ( + + + + {middleware.messages.before || ''} + + + ) + } +} + +export default DeadlineMiddleware \ No newline at end of file diff --git a/src/pages/dashboard/navgan/add-request-loan/index.jsx b/src/pages/dashboard/navgan/add-request-loan/index.jsx index 7706783..71bcaf0 100644 --- a/src/pages/dashboard/navgan/add-request-loan/index.jsx +++ b/src/pages/dashboard/navgan/add-request-loan/index.jsx @@ -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 ( - + + + ); }