Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions web/src/components/Auth/EmailPassword/EmailPasswordSignupForm.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -66,6 +79,7 @@ function EmailPasswordSignupForm() {
setPassword("");
setFirstName("");
setLastName("");
deleteLastLogin();

redirectToLoginAfterSignup();
} catch (err) {
Expand Down
36 changes: 23 additions & 13 deletions web/src/components/Modals/RecieveUpdatesModal/index.tsx
Original file line number Diff line number Diff line change
@@ -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();
};
Expand All @@ -27,10 +31,14 @@ const RecieveUpdatesModal = ({ isOpen, close }) => {

return (
<div className="z-50">
<Overlay close={close} visible={isOpen}>
<div className="relative bg-white py-6 px-4 rounded max-w-full w-[300px]">
<Overlay
close={() => {
handleProductUpdateSignup(false);
}}
visible={isOpen}>
<div className="relative bg-white py-8 px-4 rounded max-w-full w-[300px]">
<div
onClick={close}
onClick={() => handleProductUpdateSignup(false)}
className="absolute top-0 right-0 m-2 cursor-pointer">
<CloseRounded />
</div>
Expand All @@ -41,11 +49,13 @@ const RecieveUpdatesModal = ({ isOpen, close }) => {

<div className="flex items-center gap-2 mt-4">
<CustomButton
onClick={handleYes}
onClick={() => handleProductUpdateSignup(true)}
className="!bg-violet-500 !text-white hover:!text-violet-500 hover:!bg-transparent">
Yes Please!
</CustomButton>
<CustomButton onClick={handleNo}>No thanks</CustomButton>
<CustomButton onClick={() => handleProductUpdateSignup(false)}>
No thanks
</CustomButton>
</div>
</div>
</Overlay>
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/RequireAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ 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";

const RequireAuth = () => {
const accessToken = useSelector(selectAccessToken);
const lastLogin = useSelector(selectLastLogin);
const commonKey = useSelector(commonKeySelector)
const location = useLocation();
const { isOpen, toggle } = useToggle(true);

Expand All @@ -28,9 +30,7 @@ const RequireAuth = () => {
<Navigate to="/signup" state={{ from: location }} replace />
)}

{/* {!lastLogin && (
<RecieveUpdatesModal close={handleClose} isOpen={isOpen} />
)} */}
{!lastLogin && !commonKey.productUpdateStatus && <RecieveUpdatesModal close={toggle} isOpen={isOpen} />}
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions web/src/store/features/common/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ export type InitialStateType = {
connectorOptions?: any[];
supportedTaskTypes?: any[];
interpreterTypes?: any[];
productUpdateStatus?: any;
};

export const initialState: InitialStateType = {
connectorOptionsMap: {},
connectorOptions: [],
supportedTaskTypes: [],
interpreterTypes: [],
productUpdateStatus: false,
};