Skip to content

Commit

Permalink
fix: window undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Aug 6, 2024
1 parent 66702ff commit 492e9bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
4 changes: 0 additions & 4 deletions app/components/claimXTicket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ type ClaimXTicketProps = {
showClaimed?: boolean;
width?: number;
setHasClaimedX: (hasClaimedX: boolean) => void;
// setErrorMsg: (msg: string) => void;
// setShowErrorMsg: (show: boolean) => void;
};

const ClaimXTicket: FunctionComponent<ClaimXTicketProps> = ({
Expand All @@ -28,8 +26,6 @@ const ClaimXTicket: FunctionComponent<ClaimXTicketProps> = ({
showClaimed = true,
width = 200,
setHasClaimedX,
// setErrorMsg,
// setShowErrorMsg,
}) => {
const searchParams = useSearchParams();
const claimXStatus = searchParams.get("success");
Expand Down
30 changes: 7 additions & 23 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,7 @@ export default function Home() {
const [isLaunched, setIsLaunched] = useState(false);

// Claim X ticket
// const searchParams = useSearchParams();
// const claimXStatus = searchParams.get("success");
// const claimXError = searchParams.get("error_msg");
const [hasClaimedX, setHasClaimedX] = useState<boolean>(
getHasClaimedXTicket()
);
const [hasClaimedX, setHasClaimedX] = useState<boolean | undefined>();

// Claim 2FA ticket
const walletType = getWalletType(network, address);
Expand All @@ -145,6 +140,12 @@ export default function Home() {
setIsLaunched(Number(process.env.NEXT_PUBLIC_LAUNCH_TIME) < Date.now());
}, []);

useEffect(() => {
if (typeof window !== "undefined") {
setHasClaimedX(getHasClaimedXTicket());
}
}, []);

useEffect(() => {
if (network === NetworkType.STARKNET && starknetAccount) {
starknetIdNavigator
Expand Down Expand Up @@ -224,23 +225,6 @@ export default function Home() {
};
}, []);

// useEffect(() => {
// if (!claimXStatus) return;
// if (claimXStatus === "true") {
// if (!hasClaimedX) {
// storeHasClaimedXTicket();
// setHasClaimedX(true);
// }
// } else if (claimXStatus === "false" && claimXError) {
// // show error message
// if ((claimXError as string).includes("already claimed")) {
// setHasClaimedX(true);
// }
// setErrorMsg(claimXError);
// setShowErrorMsg(true);
// }
// }, [claimXStatus, claimXError]);

useEffect(() => {
if (network === NetworkType.EVM) {
setHasClaimed2FA(undefined);
Expand Down

0 comments on commit 492e9bd

Please sign in to comment.