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

Hotfix for Halt schedules #88

Merged
merged 7 commits into from
Sep 15, 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
30 changes: 17 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,20 @@ const SegmentedControl = styled.div`
`}
`

const SegmentedControlWrapper = styled.div`
const SegmentedControlWrapper = styled.div<{
$realtimeMode: boolean
$touchPrompt: boolean
$tab: string
}>`
${tw`flex justify-center transition-[opacity,margin] delay-75`}
${({ $realtimeMode, $touchPrompt }) =>
!$realtimeMode && $touchPrompt
? tw`mt-7 hm:mt-[2.1rem] hsm:mt-7`
: undefined}
${({ $tab }) =>
$tab === 'subway' || $tab === 'jungang'
? tw`opacity-100 pointer-events-auto`
: tw`opacity-0 pointer-events-none`}
`

const StationButtonWrapper = styled.div`
Expand All @@ -135,10 +147,6 @@ const Title = styled.h1`
${tw`font-bold p-3 text-3xl hm:text-[1.625rem] static pt-6 pb-3`}
`

const BetaText = styled.span`
${tw`mx-1 italic font-light`}
`

const DARK_MODE_COLOR = '#27272a' //bg-zinc-800

function App() {
Expand Down Expand Up @@ -320,10 +328,9 @@ function App() {
</>
)}
<SegmentedControlWrapper
className={`
${!realtimeMode && touchPrompt ? 'mt-7 hm:mt-[2.1rem] hsm:mt-7' : ''}
${tab === 'subway' || tab === 'jungang' ? 'opacity-100 pointer-events-auto' : 'opacity-0 pointer-events-none'}
`}
$realtimeMode={realtimeMode}
$touchPrompt={touchPrompt}
$tab={tab}
>
<SegmentedControl>
<div>
Expand All @@ -350,10 +357,7 @@ function App() {
onChange={() => realtimeClicked('sub')}
checked={realtimeMode}
/>
<RadioLabel htmlFor="2">
{t('subw')}
<BetaText>(Beta)</BetaText>
</RadioLabel>
<RadioLabel htmlFor="2">{t('subw')}</RadioLabel>
</div>
</SegmentedControl>
</SegmentedControlWrapper>
Expand Down
12 changes: 12 additions & 0 deletions src/app/components/fulltime/FullTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
StopLocation,
Week,
} from '@/data'
import { seasonKeys } from '@/data/shuttle/season'
import { weekKeys } from '@/data/shuttle/week'
import { shuttleAPI } from '@/network'

import { useDarkMode } from '../useDarkMode'
Expand Down Expand Up @@ -315,6 +317,16 @@ const FullTime = () => {
setBackground()
})

useEffect(() => {
if (season === seasonKeys.HALT) {
setSeason(seasonKeys.SEMESTER)
}

if (week === weekKeys.UNKNOWN) {
setWeek(weekKeys.WEEK)
}
}, [season, week])

useEffect(() => {
if (timetable.status !== 'pending') {
setCountChip(0)
Expand Down
19 changes: 16 additions & 3 deletions src/app/components/shuttle/Shuttle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,12 @@ export const Shuttle = ({ location }: ShuttleStop) => {
const timetable = useQuery({
queryKey: ['shuttle', season, week, location],
queryFn: () => {
if (season === null || week === null) {
if (
season === null ||
week === null ||
season === seasonKeys.HALT ||
week === weekKeys.UNKNOWN
) {
return Array<SingleShuttleSchedule>()
}
return getTimetable(season, week, location)
Expand Down Expand Up @@ -392,13 +397,21 @@ export const Shuttle = ({ location }: ShuttleStop) => {

// Set week and season to localStorage
useEffect(() => {
if (season !== null) {
if (season !== null && season !== seasonKeys.HALT) {
window.localStorage.setItem('season', season)
}

if (week !== null) {
if (week !== null && week !== weekKeys.UNKNOWN) {
window.localStorage.setItem('week', week)
}

if (window.localStorage.getItem('season') === seasonKeys.HALT) {
window.localStorage.setItem('season', seasonKeys.SEMESTER)
}

if (window.localStorage.getItem('week') === weekKeys.UNKNOWN) {
window.localStorage.setItem('week', weekKeys.WEEK)
}
}, [season, week])

const handleActionStart = () => {
Expand Down