Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
noahlitvin committed Jan 20, 2025
1 parent 704713d commit cdab700
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/app/src/lib/components/ConnectWalletModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { useConnectModal } from '@rainbow-me/rainbowkit';
import { Loader2 } from 'lucide-react';
import { useState, useEffect } from 'react';
Expand Down Expand Up @@ -27,18 +29,26 @@ export default function ConnectWalletModal({
const { openConnectModal } = useConnectModal();
const { isConnected } = useAccount();
const [permitted, setPermitted] = useState<boolean | null>(null);
const [hasPermittedCookie, setHasPermittedCookie] = useState(false);

const { signMessage } = useSignMessage({
mutation: {
onSuccess: () => {
document.cookie = 'permitted=true; path=/; max-age=31536000'; // 1 year expiry
if (typeof document !== 'undefined') {
document.cookie = 'permitted=true; path=/; max-age=31536000'; // 1 year expiry
}
onOpenChange(false);
},
},
});

const hasPermittedCookie = document.cookie
.split(';')
.some((item) => item.trim().startsWith('permitted=true'));
useEffect(() => {
// Check for cookie only on client side
const cookieCheck = document.cookie
.split(';')
.some((item) => item.trim().startsWith('permitted=true'));
setHasPermittedCookie(cookieCheck);
}, []);

useEffect(() => {
if (open) {
Expand Down

0 comments on commit cdab700

Please sign in to comment.