Skip to content

Commit

Permalink
fix recovery redirect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hqjang-pepper committed Nov 24, 2023
1 parent c319aca commit 8872176
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 7 additions & 10 deletions mpc-core-kit-web/mpc-react-playground/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
import { COREKIT_STATUS } from "@web3auth/mpc-core-kit";
import React, { useEffect } from "react";

// import { useNavigate } from "react-router-dom";
import Console from "../components/Console";
import Header from "../components/Header";
// import ShareDescriptionComponent from "../components/ShareDescription";
import Sidebar from "../components/Sidebar";
import { useMPCCoreKit } from "../services/mpcCoreKit";

function HomePage() {
const { coreKitStatus, provider, keyDetails } = useMPCCoreKit();
// const navigate = useNavigate();



const { coreKitStatus, keyDetails } = useMPCCoreKit();
useEffect(() => {
console.log("coreKitStatus", coreKitStatus);
if (coreKitStatus === COREKIT_STATUS.REQUIRED_SHARE) {
// navigate("/recover");
console.log("require more share");
// Redirect to "/recover" when REQUIRED_SHARE
window.location.href = "/recover";
}
}, []);
}, [coreKitStatus]);

return (
<main className="flex flex-col h-screen z-0">
<Header />
<div className="flex flex-1 overflow-hidden">
<Sidebar />
{provider ? (
{coreKitStatus === COREKIT_STATUS.LOGGED_IN ? (
<div className=" w-full h-full flex flex-1 flex-col bg-gray-50 items-center justify-flex-start overflow-scroll">
<h1 className="w-11/12 px-4 pt-16 sm:px-6 lg:px-8 text-2xl font-bold text-center sm:text-3xl">
Welcome to Web3Auth MPC Core Kit Playground
</h1>
<div className="py-16 w-11/12 ">

<button
className="w-full mt-10 mb-0 text-center justify-center items-center flex rounded-full px-6 py-3 text-white"
style={{ backgroundColor: "#0364ff" }}
Expand Down
6 changes: 5 additions & 1 deletion mpc-core-kit-web/mpc-react-playground/src/pages/Recover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function Recover() {
<h1 className="w-11/12 px-4 pt-16 sm:px-6 lg:px-8 text-2xl font-bold text-center sm:text-3xl">
Welcome to Web3Auth MPC Core Kit Playground
</h1>
<h3>
you might have been redirected to this page because you required more shares.
<br /> please enter your backup/ device factor key, or reset account [unrecoverable once reset, please use it with caution]
</h3>
<div className="py-16 w-11/12 ">
<Tabs tabData={TabData} />
{(() => {
Expand Down Expand Up @@ -154,7 +158,7 @@ function Recover() {
) : (
<div className=" w-full h-full flex flex-1 flex-col bg-gray-50 items-center justify-center overflow-scroll p-4">
<h1 className="text-2xl font-bold text-center sm:text-3xl">Welcome to Web3Auth MPC Core Kit Playground</h1>
<p className="max-w-md mx-auto mt-4 text-center text-gray-500">Please connect to Web3Auth to get started.</p>
<p className="max-w-md mx-auto mt-4 text-center text-gray-500">Finished recovering your Account. Enjoy your playground App!</p>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ export const MPCCoreKitProvider = ({ children }: IMPCCoreKitProps) => {
console.log("setting wallet provider");
setWalletProvider(coreKitInstance.provider);
}
uiConsole("recover with sms complete");
setCoreKitStatus(coreKitInstance.status);
} catch (error: unknown) {
console.error(error);
if ((error as any).ok === false) {
Expand Down

0 comments on commit 8872176

Please sign in to comment.