From 5ec36e591cbb76b1442f808365d3a757d2ed682d Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Tue, 29 Oct 2024 15:31:26 +0530 Subject: [PATCH 1/2] feat(web): email-updateable-at-info --- .../FormContactDetails/index.tsx | 24 ++++++++++-- .../Header/navbar/Menu/Settings/index.tsx | 2 +- web/src/utils/atlas/fetchUser.ts | 12 +++--- web/src/utils/date.ts | 37 +++++++++++++++++++ 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx b/web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx index 3f339fb78..032b6631d 100644 --- a/web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx +++ b/web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx @@ -14,6 +14,9 @@ import { ISettings } from "../../../../index"; import EmailVerificationInfo from "./EmailVerificationInfo"; import FormContact from "./FormContact"; +import { isUndefined } from "src/utils"; +import InfoCard from "components/InfoCard"; +import { timeLeftUntil } from "utils/date"; const FormContainer = styled.form` width: 100%; @@ -33,7 +36,13 @@ const ButtonContainer = styled.div` const FormContactContainer = styled.div` display: flex; flex-direction: column; +`; + +const StyledInfoCard = styled(InfoCard)` + width: fit-content; + font-size: 14px; margin-bottom: 8px; + word-wrap: break-word; `; const FormContactDetails: React.FC = ({ toggleIsSettingsOpen }) => { @@ -44,6 +53,10 @@ const FormContactDetails: React.FC = ({ toggleIsSettingsOpen }) => { const isEditingEmail = user?.email !== emailInput; + const isEmailUpdateable = user?.email + ? !isUndefined(user?.emailUpdateableAt) && new Date(user.emailUpdateableAt).getTime() < new Date().getTime() + : true; + useEffect(() => { if (!user || !userExists) return; @@ -53,11 +66,12 @@ const FormContactDetails: React.FC = ({ toggleIsSettingsOpen }) => { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!address) { - throw new Error("Missing address"); + return; } // if user exists then update email if (userExists) { + if (!isEmailUpdateable) return; const data = { newEmail: emailInput, }; @@ -108,11 +122,15 @@ const FormContactDetails: React.FC = ({ toggleIsSettingsOpen }) => { isEditing={isEditingEmail} /> - + {!isEmailUpdateable ? ( + + ) : null}