Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
imamiya-masaki committed Dec 4, 2024
1 parent 4454f37 commit bc011b7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
Empty file.
1 change: 0 additions & 1 deletion frontend/app/contexts/simulator-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export const SimulatorProvider = ({ children }: { children: ReactNode }) => {
}, [token]);

useEffect(() => {

const token = getCookieValue(document.cookie, "chair_session")
if (token) {
setToken(token)
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/get-cookie-value";
import { getCookieValue } from "~/utils/cookie-value";

Check failure on line 17 in frontend/app/contexts/user-context.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module '~/utils/cookie-value'
import {
getUserAccessToken,
getUserId,
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
declare const __API_BASE_URL__: string;

declare const __INITIAL_OWNER_DATA__:
declare const __INITIAL_DATA__:
| {
owners: {
id: string;
Expand Down
10 changes: 5 additions & 5 deletions frontend/app/utils/get-initial-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ type InitialOwner = {
token: string;
};

const initialOwnerData = __INITIAL_OWNER_DATA__;
const initialData = __INITIAL_DATA__;

export const getOwners = (): InitialOwner[] => {
return (
initialOwnerData?.owners?.map((owner) => ({
initialData?.owners?.map((owner) => ({
...owner,
})) ?? []
);
};

export const getSimulateChair = (index?: number): InitialChair | undefined => {
return index
? initialOwnerData?.simulatorChairs[index]
: initialOwnerData?.simulatorChairs[0];
? initialData?.simulatorChairs[index]
: initialData?.simulatorChairs[0];
};

export const getSimulateChairFromToken = (token: string): InitialChair | undefined => {
return initialOwnerData?.simulatorChairs.find(c => c.token === token);
return initialData?.simulatorChairs.find(c => c.token === token);
};
2 changes: 1 addition & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const config = {
],
define: {
[alternativeURLExpression]: `"${process.env["API_BASE_URL"] ?? "."}"`,
__INITIAL_OWNER_DATA__: intialOwnerData,
__INITIAL_DATA__: intialOwnerData,
},
server: {
proxy: {
Expand Down

0 comments on commit bc011b7

Please sign in to comment.