change config file structure

This commit is contained in:
AmirHossein Mahmoodi
2023-12-20 11:50:15 +03:30
parent 920120f52a
commit 983ef9a9af
5 changed files with 87 additions and 34 deletions

View File

@@ -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')

View 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

View File

@@ -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>
);
}