diff --git a/frontend/app/contexts/simulator-context.tsx b/frontend/app/contexts/simulator-context.tsx index c748d698..a4177584 100644 --- a/frontend/app/contexts/simulator-context.tsx +++ b/frontend/app/contexts/simulator-context.tsx @@ -7,7 +7,10 @@ import { useState, } from "react"; import type { Coordinate } from "~/apiClient/apiSchemas"; -import { getSimulateChair, getSimulateChairFromToken } from "~/utils/get-initial-data"; +import { + getSimulateChair, + getSimulateChairFromToken, +} from "~/utils/get-initial-data"; import { apiBaseURL } from "~/apiClient/APIBaseURL"; import { @@ -184,19 +187,17 @@ export const useClientChairNotification = (id?: string) => { return responseClientAppRequest; }; - - export const SimulatorProvider = ({ children }: { children: ReactNode }) => { - const [token, setToken] = useState() + const [token, setToken] = useState(); const simulateChairData = useMemo(() => { - return token ? getSimulateChairFromToken(token) : getSimulateChair() + return token ? getSimulateChairFromToken(token) : getSimulateChair(); }, [token]); useEffect(() => { - const token = getCookieValue(document.cookie, "chair_session") + const token = getCookieValue(document.cookie, "chair_session"); if (token) { - setToken(token) + setToken(token); return; } // TODO: tokenがなければUI上で選択させるようにする diff --git a/frontend/app/contexts/user-context.tsx b/frontend/app/contexts/user-context.tsx index eb789db7..8da7b609 100644 --- a/frontend/app/contexts/user-context.tsx +++ b/frontend/app/contexts/user-context.tsx @@ -14,7 +14,7 @@ import { } from "~/apiClient/apiComponents"; import type { Coordinate, RideStatus } from "~/apiClient/apiSchemas"; import { isClientApiError, type ClientAppRide } from "~/types"; -import { getCookieValue } from "~/utils/cookie-value"; +import { getCookieValue } from "~/utils/get-cookie-value"; import { getUserAccessToken, getUserId, diff --git a/frontend/app/types.ts b/frontend/app/types.ts index 210d84aa..36b759ae 100644 --- a/frontend/app/types.ts +++ b/frontend/app/types.ts @@ -56,7 +56,7 @@ export type SimulatorChair = { name: string; model: string; token: string; - setToken: React.Dispatch> + setToken: React.Dispatch>; coordinateState: { coordinate?: Coordinate; setter: (coordinate: Coordinate) => void; diff --git a/frontend/app/utils/get-initial-data.ts b/frontend/app/utils/get-initial-data.ts index 74adcb13..9eb06a2b 100644 --- a/frontend/app/utils/get-initial-data.ts +++ b/frontend/app/utils/get-initial-data.ts @@ -28,6 +28,8 @@ export const getSimulateChair = (index?: number): InitialChair | undefined => { : initialData?.simulatorChairs[0]; }; -export const getSimulateChairFromToken = (token: string): InitialChair | undefined => { - return initialData?.simulatorChairs.find(c => c.token === token); +export const getSimulateChairFromToken = ( + token: string, +): InitialChair | undefined => { + return initialData?.simulatorChairs.find((c) => c.token === token); };