Disable nitro key sign button if subscribe ID does not exist

This commit is contained in:
Shreerang Kale 2024-08-09 11:39:49 +05:30
parent e7581932f8
commit 1792d135d8
2 changed files with 8 additions and 6 deletions

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 {