From aeac1ca3636dde6a63f68eed7d7194ac7aef8025 Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 Date: Wed, 23 Aug 2023 20:02:35 +0530 Subject: [PATCH 1/2] added banner to close IAH registrations --- package.json | 1 + .../fractalVerification/TabScreens.jsx | 55 ++++++++++++++++++- yarn.lock | 7 +++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ea6d33..a890d84 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "ethers": "^6.6.7", "jsonp": "^0.2.1", "moment": "^2.29.4", + "moment-timezone": "^0.5.43", "near-api-js": "^2.1.4", "react": "^18.2.0", "react-confetti": "^6.1.0", diff --git a/src/components/fractalVerification/TabScreens.jsx b/src/components/fractalVerification/TabScreens.jsx index 4152777..8ca0c3d 100644 --- a/src/components/fractalVerification/TabScreens.jsx +++ b/src/components/fractalVerification/TabScreens.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, Fragment } from 'react'; import { CircleSpinner } from 'react-spinners-kit'; import { wallet } from '../..'; import { @@ -21,6 +21,8 @@ import { ImageSrc, OneE21, ReducerNames } from '../../utils/constants'; import { setActivePageIndex } from '../../redux/reducer/commonReducer'; import { Link } from '../common/Link'; import { fpPromise } from '../../utils/fingerprint'; +import { Dialog, Transition } from '@headlessui/react'; +import moment from 'moment-timezone'; const DEFAULT_ERROR_MESSAGE = 'Something went wrong, please try again.'; @@ -276,8 +278,59 @@ export const ScanFace = () => { } }, [responseData?.token]); + const electionStartDate = moment + .unix(process.env.REACT_APP_ELECTION_START_DATE) + .local(); + const electionEndDate = moment + .unix(process.env.REACT_APP_ELECTION_END_DATE) + .local(); + + const formatString = 'MMMM D, HH:mm:ss [UTC]'; // Format string + return (
+ {moment().isBetween(electionStartDate, electionEndDate) && ( + + {}}> + +
+ + +
+
+ + +
+

+ I-AM-HUMAN Voter Registration is paused during the NDC + Election between{' '} + {moment(electionStartDate).format(formatString)} and{' '} + {moment(electionEndDate).format(formatString)}. +

+
+
+
+
+
+
+
+ )}
diff --git a/yarn.lock b/yarn.lock index 891f4ec..266e5de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11738,6 +11738,13 @@ mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "^1.2.6" +moment-timezone@^0.5.43: + version "0.5.43" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.43.tgz#3dd7f3d0c67f78c23cd1906b9b2137a09b3c4790" + integrity sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ== + dependencies: + moment "^2.29.4" + moment@^2.29.4: version "2.29.4" resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" From 8e461b63f148e9cedacde972ace139aa793ac043 Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 Date: Tue, 29 Aug 2023 20:14:14 +0530 Subject: [PATCH 2/2] added elections date --- src/components/common/ProgressTracker.jsx | 26 +++++++++++++---- .../fractalVerification/TabScreens.jsx | 28 ++++++++++++------- src/utils/constants.js | 5 ++++ 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/components/common/ProgressTracker.jsx b/src/components/common/ProgressTracker.jsx index 9b36119..946e396 100644 --- a/src/components/common/ProgressTracker.jsx +++ b/src/components/common/ProgressTracker.jsx @@ -3,7 +3,12 @@ import { wallet } from '../..'; import { getConfig } from '../../utils/config'; import { formatNumberWithComma } from '../../utils/utilityFunctions'; import { useSelector } from 'react-redux'; -import { Links, ReducerNames } from '../../utils/constants'; +import { + IAHShutDownEndTime, + IAHShutDownStartTime, + Links, + ReducerNames, +} from '../../utils/constants'; import moment from 'moment-timezone'; const ProgressTracker = () => { @@ -11,6 +16,7 @@ const ProgressTracker = () => { const [humansRegistered, setHumansRegistered] = useState(0); const { showTracker } = useSelector((state) => state[ReducerNames.PROGRESS]); const { fvToken } = useSelector((state) => state[ReducerNames.SBT]); + const [electionStarted, setElectionStarted] = useState(false); const fetchHumansRegistered = async () => { try { @@ -57,8 +63,6 @@ const ProgressTracker = () => { const ReadableNumber = formatNumberWithComma(ProgressMeterMax); - const futureDateUtc = moment.unix(1693612799); // September 1 @ 23:59:59 - // Get the user's local timezone const userTimezone = moment.tz.guess(); const [countdown, setCountdown] = useState({ @@ -70,7 +74,10 @@ const ProgressTracker = () => { function updateCountdown() { const nowLocal = moment(); // Get the current local time - const futureDateLocal = futureDateUtc.clone().tz(userTimezone); + const timestamp = electionStarted + ? IAHShutDownEndTime + : IAHShutDownStartTime; + const futureDateLocal = timestamp.clone().tz(userTimezone); // Calculate the time remaining const countdownDuration = moment.duration(futureDateLocal.diff(nowLocal)); @@ -84,6 +91,10 @@ const ProgressTracker = () => { } useEffect(() => { + const isElectionStarted = moment().isSameOrAfter( + IAHShutDownStartTime.clone().tz(userTimezone) + ); + setElectionStarted(isElectionStarted); updateCountdown(); const interval = setInterval(updateCountdown, 1000); @@ -160,7 +171,12 @@ const ProgressTracker = () => { style={{ backgroundColor: '#F29BC0' }} className="p-2 text-white font-semibold flex gap-x-8 justify-center items-center" > -

VOTER REGISTRATION ENDS

+

+ {electionStarted + ? 'TIME REMAINING IN CURRENT ELECTION' + : 'VOTER REGISTRATION END'} + S +

diff --git a/src/components/fractalVerification/TabScreens.jsx b/src/components/fractalVerification/TabScreens.jsx index 8ca0c3d..ba96a8b 100644 --- a/src/components/fractalVerification/TabScreens.jsx +++ b/src/components/fractalVerification/TabScreens.jsx @@ -17,7 +17,13 @@ import { SuccesVerification } from './SuccessPage'; import { useSelector, useDispatch } from 'react-redux'; import { verifyUser } from '../../services/api'; import { updateResponse } from '../../redux/reducer/oracleReducer'; -import { ImageSrc, OneE21, ReducerNames } from '../../utils/constants'; +import { + IAHShutDownEndTime, + IAHShutDownStartTime, + ImageSrc, + OneE21, + ReducerNames, +} from '../../utils/constants'; import { setActivePageIndex } from '../../redux/reducer/commonReducer'; import { Link } from '../common/Link'; import { fpPromise } from '../../utils/fingerprint'; @@ -278,18 +284,19 @@ export const ScanFace = () => { } }, [responseData?.token]); - const electionStartDate = moment - .unix(process.env.REACT_APP_ELECTION_START_DATE) - .local(); - const electionEndDate = moment - .unix(process.env.REACT_APP_ELECTION_END_DATE) - .local(); + const userTimezone = moment.tz.guess(); + const electionEndDate = IAHShutDownEndTime; + const electionStartDate = IAHShutDownStartTime; const formatString = 'MMMM D, HH:mm:ss [UTC]'; // Format string return (

- {moment().isBetween(electionStartDate, electionEndDate) && ( + {/* compare using the local dates */} + {moment().isBetween( + electionStartDate.clone().tz(userTimezone), + electionEndDate.clone().tz(userTimezone) + ) && ( {}}> {

I-AM-HUMAN Voter Registration is paused during the NDC Election between{' '} - {moment(electionStartDate).format(formatString)} and{' '} - {moment(electionEndDate).format(formatString)}. + {moment(electionStartDate).utc().format(formatString)}{' '} + and {moment(electionEndDate).utc().format(formatString)} + .

diff --git a/src/utils/constants.js b/src/utils/constants.js index f2e9807..428457f 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -1,3 +1,5 @@ +import moment from 'moment-timezone'; + // OneE18 is an amount of 1 microNEAR export const OneE18 = 1_000_000_000_000_000_000n; // OneE21 is an amount of 1 miliNEAR @@ -122,3 +124,6 @@ export const AccountFlag = { Blacklisted: 'Blacklisted', Verified: 'Verified', }; + +export const IAHShutDownStartTime = moment.unix(1693612799); // September 1 @ 23:59:59 +export const IAHShutDownEndTime = moment.unix(1695427199); // September 22 @ 23:59:59