Persist subscriber ID in local storage #26

Merged
nabarun merged 4 commits from deep-stack/testnet-onboarding-app:sk-persist-subscriber-id into main 2024-08-09 06:24:30 +00:00
2 changed files with 8 additions and 6 deletions
Showing only changes of commit 1792d135d8 - Show all commits

View File

@ -33,13 +33,14 @@ const SignWithNitroKey = () => {
const [cosmosAddress, setCosmosAddress] = useState(""); const [cosmosAddress, setCosmosAddress] = useState("");
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const subscriberIdHash = localStorage.getItem(SUBSCRIBER_ID_HASH_KEY); const subscriberIdHash = localStorage.getItem(SUBSCRIBER_ID_HASH_KEY);
if(!subscriberIdHash){ useEffect(() => {
setIsLoading(false); if (!subscriberIdHash) {
enqueueSnackbar("Subscriber ID not found. Please verify your email and try again", { variant: "error" }); setIsLoading(false);
} enqueueSnackbar("Subscriber ID not found. Please verify your email and try again", { variant: "error" });
}
}, [subscriberIdHash]);
const message = useMemo(() => { const message = useMemo(() => {
return { return {
@ -148,7 +149,7 @@ const SignWithNitroKey = () => {
<LoadingButton <LoadingButton
variant="contained" variant="contained"
onClick={signEth} onClick={signEth}
disabled={!Boolean(ethAddress)} disabled={!Boolean(ethAddress) || !subscriberIdHash}
sx={{ marginTop: 2 }} sx={{ marginTop: 2 }}
loading={isLoading} loading={isLoading}
> >

View File

@ -4,6 +4,7 @@ import { jwtDecode } from "jwt-decode";
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { Box, colors, Typography } from '@mui/material'; import { Box, colors, Typography } from '@mui/material';
import { SUBSCRIBER_ID_HASH_KEY } from '../constants'; import { SUBSCRIBER_ID_HASH_KEY } from '../constants';
interface JwtPayload { interface JwtPayload {