Skip to content

Commit

Permalink
feat: UI fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaoloRollo committed Mar 17, 2024
1 parent 4563e71 commit 0465a1d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion components/shared/security-check-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import {
useAuthenticate,
useFluidkeyClient,
useGenerateKeys,
useResetClient,
} from "@sefu/react-sdk";
import { Lock } from "lucide-react";
import { redirect, usePathname, useRouter } from "next/navigation";
import { ReactNode, useEffect, useState } from "react";
import { useWalletClient } from "wagmi";
import { useDisconnect, useWalletClient } from "wagmi";

function SecurityCheckModal({
isOpen,
Expand All @@ -26,9 +28,21 @@ function SecurityCheckModal({
onOpenChange: () => void;
}) {
const [loading, setLoading] = useState<boolean>(false);
const pathname = usePathname();
const { user } = useDynamicContext();
const { authenticate } = useAuthenticate();
const { data: walletClient } = useWalletClient();
const { generateKeys } = useGenerateKeys();
const { disconnect } = useDisconnect();
const { reset } = useResetClient();
const router = useRouter();

const resetClient = () => {
onOpenChange();
reset();
disconnect();
router.push("/");
};

const generateKeysAndAuthenticate = async () => {
setLoading(true);
Expand All @@ -44,6 +58,12 @@ function SecurityCheckModal({
}
};

useEffect(() => {
if (!user && pathname !== "/") {
redirect("/");
}
}, [user, pathname]);

return (
<Modal
backdrop={"blur"}
Expand All @@ -66,6 +86,14 @@ function SecurityCheckModal({
</p>
</ModalBody>
<ModalFooter className="w-full">
<Button
color="danger"
onPress={() => resetClient()}
className="font-semibold w-full"
variant="ghost"
>
Logout
</Button>
<Button
color="primary"
onPress={() => generateKeysAndAuthenticate()}
Expand Down

0 comments on commit 0465a1d

Please sign in to comment.