diff --git a/packages/keychain/src/components/app.tsx b/packages/keychain/src/components/app.tsx index 781c72079..e8e112fd2 100644 --- a/packages/keychain/src/components/app.tsx +++ b/packages/keychain/src/components/app.tsx @@ -1,23 +1,22 @@ -import { Outlet, Route, Routes, Navigate } from "react-router-dom"; +import { Route, Routes } from "react-router-dom"; import { Home } from "./home"; +import { Authenticate } from "./authenticate"; +import { Session } from "./session"; +import { Failure } from "./failure"; +import { Success } from "./success"; +import { Pending } from "./pending"; +import { Slot } from "./slot"; export function App() { return ( } /> - }> - } /> - } - /> - } - /> - - Success} /> - Failure} /> + } /> + } /> + } /> + } /> + } /> + } /> Page not found} /> ); diff --git a/packages/keychain/src/pages/authenticate.tsx b/packages/keychain/src/components/authenticate.tsx similarity index 100% rename from packages/keychain/src/pages/authenticate.tsx rename to packages/keychain/src/components/authenticate.tsx diff --git a/packages/keychain/src/pages/failure.tsx b/packages/keychain/src/components/failure.tsx similarity index 95% rename from packages/keychain/src/pages/failure.tsx rename to packages/keychain/src/components/failure.tsx index e80702cfb..99999576f 100644 --- a/packages/keychain/src/pages/failure.tsx +++ b/packages/keychain/src/components/failure.tsx @@ -1,12 +1,10 @@ -"use client"; - import { Container } from "@/components/layout"; import { AlertIcon, ExternalIcon } from "@cartridge/ui"; import { Link as UILink, Text } from "@chakra-ui/react"; import { CARTRIDGE_DISCORD_LINK } from "@/const"; import { Link } from "react-router-dom"; -export default function Failure() { +export function Failure() { return ( { if (!Controller.fromStore(import.meta.env.VITE_ORIGIN!)) { - navigate("/slot/auth"); + navigate("/slot"); } }, [navigate]); diff --git a/packages/keychain/src/pages/slot/index.tsx b/packages/keychain/src/components/slot/index.tsx similarity index 62% rename from packages/keychain/src/pages/slot/index.tsx rename to packages/keychain/src/components/slot/index.tsx index 00f8f1635..2cea503ff 100644 --- a/packages/keychain/src/pages/slot/index.tsx +++ b/packages/keychain/src/components/slot/index.tsx @@ -1,11 +1,32 @@ +export { Consent } from "./consent"; + import { PageLoading } from "@/components/Loading"; import { CreateController } from "@/components/connect"; import { useMeQuery } from "@cartridge/utils/api/cartridge"; import { useController } from "@/hooks/controller"; import { useEffect } from "react"; -import { useNavigate, useSearchParams } from "react-router-dom"; +import { + Navigate, + useLocation, + useNavigate, + useSearchParams, +} from "react-router-dom"; + +export function Slot() { + const { pathname } = useLocation(); + switch (pathname) { + case "/slot/auth": + return ; + case "/slot/auth/success": + return ; + case "/slot/auth/failure": + return ; + default: + return ; + } +} -export function Auth() { +function Auth() { const navigate = useNavigate(); const [searchParams] = useSearchParams(); const { controller } = useController(); diff --git a/packages/keychain/src/pages/success.tsx b/packages/keychain/src/components/success.tsx similarity index 91% rename from packages/keychain/src/pages/success.tsx rename to packages/keychain/src/components/success.tsx index 7f4e77170..2b2a571b3 100644 --- a/packages/keychain/src/pages/success.tsx +++ b/packages/keychain/src/components/success.tsx @@ -1,10 +1,8 @@ -"use client"; - import { Container } from "@/components/layout"; import { SparklesDuoIcon } from "@cartridge/ui"; import { useSearchParams } from "react-router-dom"; -export default function Success() { +export function Success() { const [searchParams] = useSearchParams(); const title = searchParams.get("title"); const description = searchParams.get("description");