Skip to content

Commit

Permalink
Merge pull request #88 from BusHanyang/fix/halt-unknown
Browse files Browse the repository at this point in the history
Hotfix for Halt schedules
  • Loading branch information
Taewan-P authored Sep 15, 2024
2 parents 5c82e98 + 96f97cf commit a328636
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
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

0 comments on commit a328636

Please sign in to comment.