Skip to content

Commit

Permalink
Removed Elections counter (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 authored Sep 25, 2023
1 parent d83862e commit f99c521
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 161 deletions.
84 changes: 1 addition & 83 deletions src/components/common/ProgressTracker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ import { wallet } from '../..';
import { getConfig } from '../../utils/config';
import { formatNumberWithComma } from '../../utils/utilityFunctions';
import { useSelector } from 'react-redux';
import {
ElectionsStartTime,
IAHShutDownEndTime,
IAHShutDownStartTime,
Links,
ReducerNames,
} from '../../utils/constants';
import moment from 'moment-timezone';
import { Links, ReducerNames } from '../../utils/constants';

const ProgressTracker = () => {
const ProgressMeterMax = process.env.REACT_APP_PROGRESS_METER_MAX ?? 3000;
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 {
Expand Down Expand Up @@ -64,56 +56,6 @@ const ProgressTracker = () => {

const ReadableNumber = formatNumberWithComma(ProgressMeterMax);

// Get the user's local timezone
const userTimezone = moment.tz.guess();
const [countdown, setCountdown] = useState({
days: 0,
hours: 0,
minutes: 0,
seconds: 0,
});

function updateCountdown() {
const nowLocal = moment(); // Get the current local time
const timestamp = electionStarted
? IAHShutDownStartTime
: IAHShutDownEndTime;
const futureDateLocal = timestamp.clone().tz(userTimezone);

// Calculate the time remaining
const countdownDuration = moment.duration(futureDateLocal.diff(nowLocal));

setCountdown({
days: countdownDuration.days(),
hours: countdownDuration.hours(),
minutes: countdownDuration.minutes(),
seconds: countdownDuration.seconds(),
});
}

useEffect(() => {
const isElectionStarted = moment().isSameOrAfter(
ElectionsStartTime.clone().tz(userTimezone)
);
setElectionStarted(isElectionStarted);
updateCountdown();

const interval = setInterval(updateCountdown, 1000);

return () => clearInterval(interval);
}, []);

const NumberContainer = ({ number, text }) => {
return (
<span className="flex gap-x-0.5 items-end">
<p style={{ color: '#FDE047' }} className="text-3xl">
{number}
</p>
<p className="text-xl font-normal">{text}</p>
</span>
);
};

if (showTracker) {
return (
<div className="text-center text-md">
Expand Down Expand Up @@ -169,30 +111,6 @@ const ProgressTracker = () => {
)}
</div>
</>
{/* to not show any countdown from 1 sept to 7 sept */}
{!electionStarted &&
countdown.days <= 0 &&
countdown.hours <= 0 &&
countdown.minutes <= 0 &&
countdown.seconds <= 0 ? null : (
<div
style={{ backgroundColor: '#F29BC0' }}
className="p-2 text-white font-semibold flex gap-x-8 justify-center items-center"
>
<p>
{electionStarted
? 'TIME REMAINING IN CURRENT ELECTION'
: 'VOTER REGISTRATION END'}
S
</p>
<p className="text-lg flex gap-x-3 items-end">
<NumberContainer number={countdown.days} text="D" />
<NumberContainer number={countdown.hours} text="H" />
<NumberContainer number={countdown.minutes} text="M" />
<NumberContainer number={countdown.seconds} text="S" />
</p>
</div>
)}
</div>
);
} else return null;
Expand Down
63 changes: 1 addition & 62 deletions src/components/fractalVerification/TabScreens.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@ import { SuccesVerification } from './SuccessPage';
import { useSelector, useDispatch } from 'react-redux';
import { verifyUser } from '../../services/api';
import { updateResponse } from '../../redux/reducer/oracleReducer';
import {
IAHShutDownEndTime,
IAHShutDownStartTime,
ImageSrc,
OneE21,
ReducerNames,
} from '../../utils/constants';
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.';

Expand Down Expand Up @@ -284,61 +276,8 @@ export const ScanFace = () => {
}
}, [responseData?.token]);

const userTimezone = moment.tz.guess();
const electionEndDate = IAHShutDownEndTime;
const electionStartDate = IAHShutDownStartTime;

const formatString = 'MMMM D, HH:mm:ss [UTC]'; // Format string

return (
<div className="w-full">
{/* compare using the local dates */}
{moment().isBetween(
electionStartDate.clone().tz(userTimezone),
electionEndDate.clone().tz(userTimezone)
) && (
<Transition.Root show={true} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={() => {}}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-gray-500 bg-opacity-40 transition-opacity" />
</Transition.Child>

<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg">
<div className="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4 flex flex-col gap-4">
<p>
I-AM-HUMAN Voter Registration is paused during the NDC
Election between{' '}
{moment(electionStartDate).utc().format(formatString)}{' '}
and {moment(electionEndDate).utc().format(formatString)}
.
</p>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
)}
<div className="flex items-center justify-center w-20 h-20 rounded-full border-2 border-purple-400">
<div className="flex items-center justify-center w-full h-full rounded-full border-2 border-purple-500 bg-purple-200 shadow-[inset_0_0px_4px_#FFFFFF] shadow-purple-400">
<FaceSVG styles="w-12 h-12 fill-purple-400 stroke-themeColor" />
Expand Down
20 changes: 8 additions & 12 deletions src/pages/Activate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,15 @@ const ActivatePage = () => {
<div className="grid grid-cols-1 gap-2 md:gap-5 md:grid-cols-2 lg:grid-cols-3 my-10 md:my-16">
<ImageTextBlock
imageSrc={ImageSrc.NDCLogo}
isAvailable={true}
onClick={() => window.open(Links.ELECTIONS, '_blank')}
title="NEAR General Election"
description="The NDC is launching the inaugural ecosystem wide General Election to enable decentralized governance on-chain. #Vote in the September 8th General Election and mint your “I Voted” reputation Soul Bound Token!"
buttonText="Vote Now"
buttonText="Closed"
/>
<ImageTextBlock
imageSrc={ImageSrc.NDCLogo}
isAvailable={true}
title="NDC Nomination"
description="Are you a dedicated OG member of the NEAR community? Nominate yourself for a seat in the NDC General Election. Realize your vision to grow the NEAR ecosystem. Verified humans, comment and upvote on your favorite candidates."
onClick={() =>
window.open(
'https://near.org/nomination.ndctools.near/widget/NDC.Nomination.Page',
'_blank'
)
}
buttonText="Participate Now"
buttonText="Closed"
/>
<ImageTextBlock
imageSrc={ImageSrc.NDCPoll}
Expand Down Expand Up @@ -83,7 +74,6 @@ const ActivatePage = () => {
)
}
/>

<ImageTextBlock
imageSrc={ImageSrc.NDCKudos}
onClick={() => window.open(Links.KUDOS_WIDGET, '_blank')}
Expand All @@ -102,6 +92,12 @@ const ActivatePage = () => {
}
buttonText="See you IRL"
/>
<ImageTextBlock
imageSrc={ImageSrc.Astra}
title="Astra++"
description="Astra++ is a comprehensive suite of DAO tooling that makes possible for any DAO to easily self-manage and grow its membership, and filling a void left by AstroDAO."
buttonText="Coming Soon"
/>
<ImageTextBlock
imageSrc={ImageSrc.CommunityFund}
title="NDC CommunityFund"
Expand Down
6 changes: 2 additions & 4 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export const ImageSrc = {
'https://bafkreicvwvjtybib7nodjus5ynomjasp3xskz2et5tkrx6k7t3h7dsq2za.ipfs.nftstorage.link/',
ELECTION_ICON:
'https://bafkreidrd4ci3p23e7zttaq5ukpzeddyzvfdm37x3xomju3rgeq77f2dba.ipfs.nftstorage.link/',
Astra:
'https://bafkreig2uojfxnf4bto6wuzaylec7wjmo4lznv6nz42fpas2bb4wuueehe.ipfs.nftstorage.link/',
};

export const Links = {
Expand All @@ -128,7 +130,3 @@ 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
export const ElectionsStartTime = moment.unix(1694131200); // September 8 @ 00:00:00

0 comments on commit f99c521

Please sign in to comment.