information banner from api with date range
This commit is contained in:
+29
-1
@@ -4,7 +4,7 @@ import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { setCookie } from "nookies";
|
||||
import { connect } from "react-redux";
|
||||
import { getToken, hashString } from "../actions";
|
||||
import { getNotice, getToken, hashString } from "../actions";
|
||||
import {
|
||||
getGGToken,
|
||||
getPortalLogin,
|
||||
@@ -16,6 +16,7 @@ import Footer from "../components/footer";
|
||||
import Header from "../components/header";
|
||||
import Main from "../components/main";
|
||||
import ServiceBanner from "../components/servicebanner";
|
||||
import NoticeBanner from "../components/noticebanner";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
@@ -36,6 +37,7 @@ const Home = (props) => {
|
||||
loggedInUserEmail,
|
||||
ggLocale,
|
||||
hasLoginCode,
|
||||
noticeContent,
|
||||
} = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
@@ -78,6 +80,26 @@ const Home = (props) => {
|
||||
}))
|
||||
: console.log("no value in user id");
|
||||
|
||||
var noticeDateFrom = new Date(
|
||||
noticeContent.value[0].dateFrom.split("/")[2],
|
||||
noticeContent.value[0].dateFrom.split("/")[1] - 1,
|
||||
noticeContent.value[0].dateFrom.split("/")[0]
|
||||
);
|
||||
|
||||
var noticeDateTo = new Date(
|
||||
noticeContent.value[0].dateTo.split("/")[2],
|
||||
noticeContent.value[0].dateTo.split("/")[1] - 1,
|
||||
noticeContent.value[0].dateTo.split("/")[0]
|
||||
);
|
||||
|
||||
var today = new Date();
|
||||
var day = today.getDate();
|
||||
var month = today.getMonth();
|
||||
var year = today.getFullYear();
|
||||
|
||||
today = new Date(year, month, day);
|
||||
const displayNotice = today >= noticeDateFrom && today <= noticeDateTo;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
@@ -147,6 +169,9 @@ const Home = (props) => {
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{displayNotice && (
|
||||
<NoticeBanner noticeContent={noticeContent} />
|
||||
)}
|
||||
<ServiceBanner />
|
||||
<Main
|
||||
ggLocale={ggLocale}
|
||||
@@ -192,6 +217,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
// store.dispatch(getGovGatewayConfig(providerConfig));
|
||||
|
||||
const noticeContent = await getNotice();
|
||||
|
||||
let ggToken = {};
|
||||
let ggUserInfo = {};
|
||||
let portalUserObj = {};
|
||||
@@ -241,6 +268,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
loggedInUserId: portalUserObj,
|
||||
loggedInUserEmail: loginEmailStr,
|
||||
hasLoginCode: hasLoginCode,
|
||||
noticeContent: noticeContent,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user