diff --git a/web/src/components/Auth/EmailPassword/EmailPasswordSignupForm.tsx b/web/src/components/Auth/EmailPassword/EmailPasswordSignupForm.tsx index 290afea50..630b75122 100644 --- a/web/src/components/Auth/EmailPassword/EmailPasswordSignupForm.tsx +++ b/web/src/components/Auth/EmailPassword/EmailPasswordSignupForm.tsx @@ -1,5 +1,6 @@ import { CircularProgress } from "@mui/material"; import { useState } from "react"; +import { useDispatch } from "react-redux"; import CustomButton from "../../common/CustomButton/index.tsx"; import { Toast } from "../../Toast.tsx"; import { useNavigate } from "react-router-dom"; @@ -10,9 +11,12 @@ import { import CustomInput from "../../Inputs/CustomInput.tsx"; import { InputTypes } from "../../../types/inputs/inputTypes.ts"; import ShowPasswordIcon from "./ShowPasswordIcon.tsx"; +import { setCommonKey } from "../../../store/features/common/commonSlice.ts"; function EmailPasswordSignupForm() { const navigate = useNavigate(); + const dispatch = useDispatch(); + const [error, setError] = useState(""); const [btnLoading, setBtnLoading] = useState(false); const [triggerSignup, { isLoading }] = useSignupMutation(); @@ -36,6 +40,15 @@ function EmailPasswordSignupForm() { navigate("/login"); } + function deleteLastLogin() { + localStorage.removeItem("last_login") + + dispatch(setCommonKey({ + key: "productUpdateStatus", + value : false } + )); + } + const getError = (err) => { const errObj = err?.data; if (errObj && Object.keys(errObj).length !== 0) { @@ -66,6 +79,7 @@ function EmailPasswordSignupForm() { setPassword(""); setFirstName(""); setLastName(""); + deleteLastLogin(); redirectToLoginAfterSignup(); } catch (err) { diff --git a/web/src/components/Modals/RecieveUpdatesModal/index.tsx b/web/src/components/Modals/RecieveUpdatesModal/index.tsx index a4b4e76b2..84093c512 100644 --- a/web/src/components/Modals/RecieveUpdatesModal/index.tsx +++ b/web/src/components/Modals/RecieveUpdatesModal/index.tsx @@ -1,20 +1,24 @@ import React, { useEffect } from "react"; +import { useDispatch } from "react-redux"; import Overlay from "../../Overlay/index.tsx"; import { CloseRounded } from "@mui/icons-material"; import CustomButton from "../../common/CustomButton/index.tsx"; import posthog from "posthog-js"; +import { setCommonKey } from "../../../store/features/common/commonSlice.ts"; const RecieveUpdatesModal = ({ isOpen, close }) => { - const handleYes = () => { - posthog.capture("POST_LOGIN_SUBSCRIPTION_UPDATE_INTERACTED", { - subscription_requested: true, - }); - close(); - }; + const dispatch = useDispatch(); + + const handleProductUpdateSignup = (signupStatus: boolean) => { + dispatch( + setCommonKey({ + key: "productUpdateStatus", + value: true, + }), + ); - const handleNo = () => { posthog.capture("POST_LOGIN_SUBSCRIPTION_UPDATE_INTERACTED", { - subscription_requested: false, + subscription_requested: signupStatus, }); close(); }; @@ -27,10 +31,14 @@ const RecieveUpdatesModal = ({ isOpen, close }) => { return (
- -
+ { + handleProductUpdateSignup(false); + }} + visible={isOpen}> +
handleProductUpdateSignup(false)} className="absolute top-0 right-0 m-2 cursor-pointer">
@@ -41,11 +49,13 @@ const RecieveUpdatesModal = ({ isOpen, close }) => {
handleProductUpdateSignup(true)} className="!bg-violet-500 !text-white hover:!text-violet-500 hover:!bg-transparent"> Yes Please! - No thanks + handleProductUpdateSignup(false)}> + No thanks +
diff --git a/web/src/components/RequireAuth.tsx b/web/src/components/RequireAuth.tsx index da4e8105f..3ce391523 100644 --- a/web/src/components/RequireAuth.tsx +++ b/web/src/components/RequireAuth.tsx @@ -4,6 +4,7 @@ import { selectAccessToken, selectLastLogin, } from "../store/features/auth/authSlice.ts"; +import { commonKeySelector } from "../store/features/common/selectors/commonKeySelector.ts"; import FakeLoading from "./common/Loading/FakeLoading.tsx"; import RecieveUpdatesModal from "./Modals/RecieveUpdatesModal/index.tsx"; import useToggle from "../hooks/common/useToggle.js"; @@ -11,6 +12,7 @@ import useToggle from "../hooks/common/useToggle.js"; const RequireAuth = () => { const accessToken = useSelector(selectAccessToken); const lastLogin = useSelector(selectLastLogin); + const commonKey = useSelector(commonKeySelector) const location = useLocation(); const { isOpen, toggle } = useToggle(true); @@ -28,9 +30,7 @@ const RequireAuth = () => { )} - {/* {!lastLogin && ( - - )} */} + {!lastLogin && !commonKey.productUpdateStatus && } ); }; diff --git a/web/src/store/features/common/initialState.ts b/web/src/store/features/common/initialState.ts index 3d94edeb9..399a6283f 100644 --- a/web/src/store/features/common/initialState.ts +++ b/web/src/store/features/common/initialState.ts @@ -3,6 +3,7 @@ export type InitialStateType = { connectorOptions?: any[]; supportedTaskTypes?: any[]; interpreterTypes?: any[]; + productUpdateStatus?: any; }; export const initialState: InitialStateType = { @@ -10,4 +11,5 @@ export const initialState: InitialStateType = { connectorOptions: [], supportedTaskTypes: [], interpreterTypes: [], + productUpdateStatus: false, };