Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] feの細かいバグ修正 #705

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions frontend/app/components/hooks/use-emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const postEnroute = (rideId: string, coordinate: Coordinate) => {
pathParams: {
rideId,
},
}).catch((e) => console.error(e));
});
};

const postCarring = (rideId: string) => {
Expand All @@ -60,7 +60,7 @@ const postCarring = (rideId: string) => {
pathParams: {
rideId,
},
}).catch((e) => console.error(e));
});
};

const forcePickup = (pickup_coordinate: Coordinate) =>
Expand All @@ -78,7 +78,7 @@ const forceCarry = (pickup_coordinate: Coordinate, rideId: RideId) =>
} catch (error) {
console.error(error);
}
}, 10_000);
}, 30_000);

const forceArrive = (pickup_coordinate: Coordinate) =>
setTimeout(() => {
Expand Down Expand Up @@ -115,6 +115,16 @@ export const useEmulator = () => {
ride_id,
]);

useEffect(() => {
if (!pickup_coordinate || status !== "PICKUP") return;
setCoordinate?.(pickup_coordinate);
}, [status, pickup_coordinate, setCoordinate]);

useEffect(() => {
if (!destination_coordinate || status !== "ARRIVED") return;
setCoordinate?.(destination_coordinate);
}, [status, destination_coordinate, setCoordinate]);

useEffect(() => {
if (isAnotherSimulatorBeingUsed) return;
if (!(chair && data)) {
Expand All @@ -129,7 +139,6 @@ export const useEmulator = () => {
postEnroute(data.ride_id, chair.coordinate);
break;
case "PICKUP":
setCoordinate?.(data.pickup_coordinate);
postCarring(data.ride_id);
break;
case "ENROUTE":
Expand Down
7 changes: 4 additions & 3 deletions frontend/app/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const setStorage = (
storage: Storage,
): boolean => {
try {
const existing = JSON.parse(
localStorage.getItem(GroupId) || "{}",
) as Record<string, string>;
const existing = JSON.parse(storage.getItem(GroupId) || "{}") as Record<
string,
string
>;
storage.setItem(
GroupId,
JSON.stringify({ ...existing, [fieldId]: itemData }),
Expand Down