Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
imamiya-masaki committed Dec 4, 2024
1 parent bc011b7 commit c32ada7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
15 changes: 8 additions & 7 deletions frontend/app/contexts/simulator-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -184,19 +187,17 @@ export const useClientChairNotification = (id?: string) => {
return responseClientAppRequest;
};



export const SimulatorProvider = ({ children }: { children: ReactNode }) => {
const [token, setToken] = useState<string>()
const [token, setToken] = useState<string>();

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上で選択させるようにする
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/contexts/user-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export type SimulatorChair = {
name: string;
model: string;
token: string;
setToken: React.Dispatch<React.SetStateAction<string | undefined>>
setToken: React.Dispatch<React.SetStateAction<string | undefined>>;
coordinateState: {
coordinate?: Coordinate;
setter: (coordinate: Coordinate) => void;
Expand Down
6 changes: 4 additions & 2 deletions frontend/app/utils/get-initial-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit c32ada7

Please sign in to comment.