Skip to content

Commit

Permalink
refactor(Exceptions Schedule): fix flow types
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-cline committed Nov 21, 2023
1 parent 8125f09 commit 396e972
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/editor/components/timetable/CalendarSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Select from 'react-select'

import * as activeActions from '../../actions/active'
import {entityIsNew} from '../../util/objects'
import type {Pattern, GtfsRoute, Feed, ServiceCalendar, ScheduleException, Trip, TripCounts} from '../../../types'
import type {Pattern, GtfsRoute, Feed, ServiceCalendar, ScheduleExceptionCalendar, Trip, TripCounts} from '../../../types'

type CalendarOption = {
calendar: ServiceCalendar,
Expand All @@ -20,10 +20,10 @@ type CalendarOption = {
}

type Props = {
activeCalendar: ?ServiceCalendar,
activeCalendar: ?ServiceCalendar | ?ScheduleExceptionCalendar,
activePattern: Pattern,
calendars: Array<ServiceCalendar>,
exceptionBasedCalendars: Array<ScheduleException>,
exceptionBasedCalendars: ?Array<ScheduleExceptionCalendar>,
feedSource: Feed,
route: GtfsRoute,
setActiveEntity: typeof activeActions.setActiveEntity,
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/util/timetable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function parseTime (timeString: string) {
}

// Helper function to find and return the active calendar, be it traditional or exception-based.
export function getActiveCalendar (calendars: Array<ServiceCalendar>, exceptionBasedCalendars: Array<ScheduleExceptionCalendar>, activeScheduleId: string) {
export function getActiveCalendar (calendars: Array<ServiceCalendar>, exceptionBasedCalendars: Array<ScheduleExceptionCalendar>, activeScheduleId: string): ?ServiceCalendar | ?ScheduleExceptionCalendar {
const activeCalendarFilter = c => c.service_id === activeScheduleId
return calendars.find(activeCalendarFilter) || exceptionBasedCalendars.find(activeCalendarFilter)
}
Expand Down
1 change: 1 addition & 0 deletions lib/editor/util/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export function validate (
const calendars: Array<ServiceCalendar> = clone(getTableById(tableData, 'calendar'))

// Check if service ID exists elsewhere
// $FlowFixMe: Array#some confuses flow it seems.
if (entity.custom_schedule && calendars.some(c => c.service_id === entity.custom_schedule)) {
const reason = messages('conflictingServiceId')
valErrors.push(validationIssue(reason, messages('customServiceId')))
Expand Down

0 comments on commit 396e972

Please sign in to comment.