fixed fucking bug
This commit is contained in:
@@ -3,13 +3,14 @@ import process from "next/dist/build/webpack/loaders/resolve-url-loader/lib/post
|
|||||||
|
|
||||||
export const globalServerProps = async ({req, locale}) => {
|
export const globalServerProps = async ({req, locale}) => {
|
||||||
const {isBot} = parse(req.headers["user-agent"]);
|
const {isBot} = parse(req.headers["user-agent"]);
|
||||||
|
|
||||||
const responseConfig = await fetch(process.env.NEXT_PUBLIC_CONFIG_APP_URL);
|
const responseConfig = await fetch(`${process.env.NEXT_PUBLIC_CONFIG_APP_URL}?_=${Math.random()}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
config: await responseConfig.json(),
|
config: await responseConfig.json(),
|
||||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||||
isBot,
|
isBot,
|
||||||
locale,
|
locale,
|
||||||
|
today: new Date().getTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ import moment from "jalali-moment";
|
|||||||
import SvgMaintenance from "@/core/components/svgs/SvgMaintenance";
|
import SvgMaintenance from "@/core/components/svgs/SvgMaintenance";
|
||||||
import {Typography} from "@mui/material";
|
import {Typography} from "@mui/material";
|
||||||
|
|
||||||
const DeadlineMiddleware = ({children, type = '', withMessage = false}) => {
|
const DeadlineMiddleware = ({children, type = '', withMessage = false, serverToday}) => {
|
||||||
const {config} = useConfig()
|
const {config} = useConfig()
|
||||||
const middleware = config.deadlines[type]
|
const middleware = config.deadlines[type]
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ const DeadlineMiddleware = ({children, type = '', withMessage = false}) => {
|
|||||||
|
|
||||||
const fromDate = moment(middleware.date.from, 'jYYYY/jMM/jDD')
|
const fromDate = moment(middleware.date.from, 'jYYYY/jMM/jDD')
|
||||||
const toDate = moment(middleware.date.to, 'jYYYY/jMM/jDD')
|
const toDate = moment(middleware.date.to, 'jYYYY/jMM/jDD')
|
||||||
const today = moment()
|
const today = moment(serverToday)
|
||||||
|
|
||||||
if (today.isBetween(fromDate, toDate, null, '[]')) {
|
if (today.isBetween(fromDate, toDate, null, '[]')) {
|
||||||
return children
|
return children
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import LoanRequestComponent from "@/components/dashboard/navgan/add-request-loan
|
|||||||
import {globalServerProps} from "@/core/utils/globalServerProps";
|
import {globalServerProps} from "@/core/utils/globalServerProps";
|
||||||
import DeadlineMiddleware from "@/middlewares/Deadline";
|
import DeadlineMiddleware from "@/middlewares/Deadline";
|
||||||
|
|
||||||
export default function AddLoanRequest() {
|
export default function AddLoanRequest(props) {
|
||||||
return (<DeadlineMiddleware type={'register'} withMessage={true}>
|
return (<DeadlineMiddleware serverToday={props.today} type={'register'} withMessage={true}>
|
||||||
<LoanRequestComponent/>
|
<LoanRequestComponent/>
|
||||||
</DeadlineMiddleware>);
|
</DeadlineMiddleware>);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user