Skip to content

Commit

Permalink
UI update
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed Aug 21, 2024
1 parent aea04ce commit 4099933
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/route-eta/TimeTableButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const TimeTableButton = ({ routeId }: { routeId: string }) => {
startIcon={<ScheduleIcon />}
onClick={() => setIsOpen(true)}
>
{t("時間表")}
{t("車程")}
</Button>
<TimetableDrawer
routeId={routeId}
Expand Down
6 changes: 3 additions & 3 deletions src/components/route-eta/TimetableDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface TimetableDrawerProps {

const TimetableDrawer = ({ routeId, open, onClose }: TimetableDrawerProps) => {
const { t } = useTranslation();
const [tab, setTab] = useState<"schedule" | "jt">("schedule");
const [tab, setTab] = useState<"schedule" | "jt">("jt");

const modalProps = useMemo(() => {
return {
Expand All @@ -33,11 +33,11 @@ const TimetableDrawer = ({ routeId, open, onClose }: TimetableDrawerProps) => {
anchor="right"
>
<Tabs value={tab} onChange={(_, v) => setTab(v)} sx={tabbarSx}>
<Tab value="schedule" label={t("時間表")} />
<Tab label={t("車程")} value="jt" />
<Tab value="schedule" label={t("時間表")} />
</Tabs>
{tab === "schedule" && <TimeTable routeId={routeId} />}
{tab === "jt" && <JourneyTimePanel routeId={routeId} />}
{tab === "schedule" && <TimeTable routeId={routeId} />}
</Drawer>
);
};
Expand Down
22 changes: 15 additions & 7 deletions src/components/route-eta/timetableDrawer/JourneyTimePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,21 @@ const JourneyTimePanel = ({ routeId }: JourneyTimePanelProps) => {
stopList,
batchSize: Math.max(Math.ceil((state.endSeq - state.startSeq) / 3), 6),
signal: abortController.current.signal,
}).then((jt) => {
setState((prev) => ({
...prev,
jt: Math.round(jt),
isLoading: false,
}));
});
})
.then((jt) => {
setState((prev) => ({
...prev,
jt: Math.round(jt),
isLoading: false,
}));
})
.catch((e) => {
console.error(e);
setState((prev) => ({
...prev,
isLoading: false,
}));
});
}, [route, state.endSeq, state.startSeq, stopList]);

const stops = useMemo(() => {
Expand Down

0 comments on commit 4099933

Please sign in to comment.