diff --git a/frontend/app/routes/client/userProvider.tsx b/frontend/app/routes/client/userProvider.tsx index 2a33a5dd..455d12b7 100644 --- a/frontend/app/routes/client/userProvider.tsx +++ b/frontend/app/routes/client/userProvider.tsx @@ -12,7 +12,7 @@ const userContext = createContext>({}); export const UserProvider = ({ children }: { children: ReactNode }) => { const [searchParams] = useSearchParams(); - const accessToken = searchParams.get("access_token") ?? undefined; + const accessToken = searchParams.get("user_access_token") ?? undefined; if (accessToken === undefined) { return; } diff --git a/frontend/app/routes/driver/driverProvider.tsx b/frontend/app/routes/driver/driverProvider.tsx new file mode 100644 index 00000000..6e17abcc --- /dev/null +++ b/frontend/app/routes/driver/driverProvider.tsx @@ -0,0 +1,35 @@ +import { useSearchParams } from "@remix-run/react"; +import { ReactNode, createContext, useContext } from "react"; + +export type AccessToken = string; + +type Driver = { + id: string; + name: string; + accessToken: AccessToken; +}; +const driverContext = createContext>({}); + +export const DriverProvider = ({ children }: { children: ReactNode }) => { + const [searchParams] = useSearchParams(); + const accessToken = searchParams.get("driver_access_token") ?? undefined; + if (accessToken === undefined) { + return; + } + /** + * TODO: ログイン情報取得処理 + */ + const fetchedValue: Driver = { + id: "fetched-id", + name: "fetched-name", + accessToken, + }; + + return ( + + {children} + + ); +}; + +export const useDriver = () => useContext(driverContext); diff --git a/frontend/app/routes/driver/route.tsx b/frontend/app/routes/driver/route.tsx index bed2db39..39e20a15 100644 --- a/frontend/app/routes/driver/route.tsx +++ b/frontend/app/routes/driver/route.tsx @@ -2,6 +2,7 @@ import type { MetaFunction } from "@remix-run/node"; import { Outlet } from "@remix-run/react"; import { FooterNavigation } from "~/components/FooterNavigation"; import { CircleIcon } from "~/components/icon/circle"; +import { DriverProvider } from "./driverProvider"; export const meta: MetaFunction = () => { return [{ title: "ISUCON14" }, { name: "description", content: "isucon14" }]; @@ -11,7 +12,9 @@ export default function DriverLayout() { return (
- + + +