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
11 changed files with 27 additions and 26 deletions
Showing only changes of commit e7581932f8 - Show all commits

View File

@ -12,6 +12,7 @@
}
},
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }]
"indent": ["error", 2, { "SwitchCase": 1 }],
"semi": ["error", "always"]
}
}

View File

@ -4,7 +4,7 @@ import { Link, useLocation } from 'react-router-dom';
import { AppBar, Toolbar, Avatar, Box, IconButton } from '@mui/material';
const Header: React.FC = () => {
const location = useLocation()
const location = useLocation();
return (
<AppBar position="static" color="inherit">

View File

@ -14,16 +14,16 @@ const SelectRoleCard = ({ handleAccept, handleRoleChange }: { handleAccept: () =
const [checked, setChecked] = useState(false);
const [isHidden, setIsHidden] = useState(false);
const [isDialogOpen, setisDialogOpen] = useState(false)
const [isDialogOpen, setisDialogOpen] = useState(false);
const handleCheckboxChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setChecked(event.target.checked);
};
const handleContinue = () => {
handleAccept()
setIsHidden(true)
}
handleAccept();
setIsHidden(true);
};
const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setSelectedRole(event.target.value as Role);

View File

@ -4,7 +4,7 @@ import { Document, Page, pdfjs } from 'react-pdf';
import { Typography } from '@mui/material';
// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#copy-worker-to-public-directory
pdfjs.GlobalWorkerOptions.workerSrc = process.env.PUBLIC_URL + '/pdf.worker.min.mjs'
pdfjs.GlobalWorkerOptions.workerSrc = process.env.PUBLIC_URL + '/pdf.worker.min.mjs';
const TermsAndConditionsBox = ({height}: {height: string}) => {
const [numPages, setNumPages] = useState<number>();

View File

@ -1,8 +1,8 @@
import React from 'react'
import React from 'react';
import { Box, Typography } from '@mui/material'
import { Box, Typography } from '@mui/material';
import { REDIRECT_EMAIL_MSG } from '../constants'
import { REDIRECT_EMAIL_MSG } from '../constants';
const Email = () => {
return (
@ -27,7 +27,7 @@ const Email = () => {
{REDIRECT_EMAIL_MSG}
</Typography>
</Box>
)
}
);
};
export default Email
export default Email;

View File

@ -25,7 +25,7 @@ const OnboardingSuccess = () => {
const location = useLocation();
const { cosmosAddress } = location.state as {
cosmosAddress?: string
}
};
const [participant, setParticipant] = useState<Participant>();
const [token, setToken] = useState<string>('');

View File

@ -37,7 +37,7 @@ const SignWithNitroKey = () => {
const subscriberIdHash = localStorage.getItem(SUBSCRIBER_ID_HASH_KEY);
if(!subscriberIdHash){
setIsLoading(false)
setIsLoading(false);
enqueueSnackbar("Subscriber ID not found. Please verify your email and try again", { variant: "error" });
}
@ -51,7 +51,7 @@ const SignWithNitroKey = () => {
const signEth = async () => {
if (session && signClient) {
try {
setIsLoading(true)
setIsLoading(true);
const jsonMessage = canonicalStringify(message);
const hexMsg = utf8ToHex(jsonMessage, true);
const receivedEthSig: string = await signClient!.request({
@ -62,7 +62,7 @@ const SignWithNitroKey = () => {
params: [hexMsg, ethAddress],
},
});
setIsLoading(false)
setIsLoading(false);
setEthSignature(ethSignature);
if (ENABLE_KYC) {
@ -84,7 +84,7 @@ const SignWithNitroKey = () => {
}
} catch (error) {
console.log("err in signing ", error);
setIsLoading(false)
setIsLoading(false);
enqueueSnackbar("Error signing message", { variant: "error" });
}
}

View File

@ -25,14 +25,14 @@ const Thanks: React.FC = () => {
try {
if(!token){
throw new Error("Invalid JWT Token")
throw new Error("Invalid JWT Token");
}
const decoded = jwtDecode(token) as JwtPayload;
const currentTime = Math.floor(Date.now() / 1000);
if (!decoded.subscriber_id) {
throw new Error("Subscriber ID not found")
throw new Error("Subscriber ID not found");
}
if (decoded.exp < currentTime) {

View File

@ -52,7 +52,7 @@ const UserVerification = () => {
cosmosAddress,
receivedEthSig,
kycIdHash
}})
}});
}
}, [applicationSubmitted, kycId, navigate, cosmosAddress, message, receivedEthSig]);

View File

@ -1,4 +1,4 @@
import React from 'react'
import React from 'react';
const VerifyEmail = () => {
return (
@ -18,7 +18,7 @@ const VerifyEmail = () => {
}}
></iframe>
</div>
)
}
);
};
export default VerifyEmail
export default VerifyEmail;

View File

@ -29,5 +29,5 @@ export const getAccessTokenExpirationHandler = (userId: string) => {
return async () => {
const newToken = await fetchAccessToken(userId);
return newToken;
}
};
};