Skip to content

Commit

Permalink
fixup eslint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
drewvolz committed Sep 7, 2024
1 parent 5e52ae0 commit 1bb773d
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 56 deletions.
18 changes: 10 additions & 8 deletions source/views/sis/course-search/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,29 @@ export function useCourseData(
let {data: terms = []} = useAvailableTerms()
let filteredTerms = terms.filter((t) => selectedTerms.includes(t.term))

let query = (
let createQueryOptions = (
term: TermType,
levels: Array<number> = [],
gereqs: Array<string> = [],
levelsList: Array<number> = [],
gereqsList: Array<string> = [],
): UseQueryOptions<
CourseType[],
unknown,
CourseType[],
ReturnType<(typeof keys)['courses']>
> => ({
queryKey: keys.courses(term, levels, gereqs),
queryFn: ({queryKey: [_group, _courses, term, levels, gereqs], signal}) =>
coursesForTerm(term, levels, gereqs, {signal}),
queryKey: keys.courses(term, levelsList, gereqsList),
queryFn: ({
queryKey: [_group, _courses, termKey, levelsKey, gereqsKey],
signal,
}) => coursesForTerm(termKey, levelsKey, gereqsKey, {signal}),
staleTime: ONE_HOUR,
enabled: terms.length > 0,
})

return useQueries({
queries: filteredTerms.length
? filteredTerms.map((term) => query(term, levels, gereqs))
: terms.map((term) => query(term, levels, gereqs)),
? filteredTerms.map((term) => createQueryOptions(term, levels, gereqs))
: terms.map((term) => createQueryOptions(term, levels, gereqs)),
})
}

Expand Down
21 changes: 13 additions & 8 deletions source/views/sis/course-search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const NavigationOptions: NativeStackNavigationOptions = {
title: 'Course Catalog',
}

const RightButton: React.FC<{onPress: () => void}> = ({onPress}) => (
<SearchButton onPress={onPress} title="Browse" />
)

export const CourseSearchView = (): JSX.Element => {
let navigation = useNavigation()

Expand All @@ -36,15 +40,16 @@ export const CourseSearchView = (): JSX.Element => {
let [typedQuery, setTypedQuery] = React.useState('')

React.useLayoutEffect(() => {
const getRightButton = () => (
<RightButton
onPress={() =>
navigation.navigate('CourseSearchResults', {initialQuery: ''})
}
/>
)

navigation.setOptions({
headerRight: () => (
<SearchButton
onPress={() =>
navigation.navigate('CourseSearchResults', {initialQuery: ''})
}
title="Browse"
/>
),
headerRight: getRightButton,
headerSearchBarOptions: {
barTintColor: c.quaternarySystemFill,
onChangeText: (event: ChangeTextEvent) => {
Expand Down
5 changes: 4 additions & 1 deletion source/views/sis/student-work/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export function useStudentWorkPostings(): UseQueryResult<
select: (data) => {
let sorted = orderBy(data, sorters, ordered)
let grouped = groupBy(sorted, (j) => j.type)
return Object.entries(grouped).map(([title, data]) => ({title, data}))
return Object.entries(grouped).map(([title, groupedData]) => ({
title,
data: groupedData,
}))
},
})
}
2 changes: 1 addition & 1 deletion source/views/stoprint/print-release.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const PrintJobReleaseView = (): JSX.Element => {

let {data: heldJobs = []} = useHeldJobs(printer?.printerName)
let jobId = job.id.toString()
let heldJob = heldJobs.find((heldJob) => heldJob.id.startsWith(jobId))
let heldJob = heldJobs.find((item) => item.id.startsWith(jobId))

const returnToJobsView = React.useCallback(() => {
navigation.navigate('PrintJobs')
Expand Down
4 changes: 2 additions & 2 deletions source/views/streaming/streams/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export const StreamListView = (): JSX.Element => {
}

let categories = [...new Set(allCategories)].sort()
let filterCategories = categories.map((c) => {
return {title: c}
let filterCategories = categories.map((category) => {
return {title: category}
})

let streamFilters: ListType<StreamType>[] = [
Expand Down
19 changes: 11 additions & 8 deletions source/views/streaming/streams/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ export const keys = {
export function useStreams(
date: Moment = moment.tz(timezone()),
): UseQueryResult<StreamType[], unknown> {
let dateFrom = date.format('YYYY-MM-DD')
let dateTo = date.clone().add(2, 'month').format('YYYY-MM-DD')
const dateFromFormatted = date.format('YYYY-MM-DD')
const dateToFormatted = date.clone().add(2, 'month').format('YYYY-MM-DD')

let searchParams = {
const searchParams = {
sort: 'ascending',
dateFrom,
dateTo,
dateFrom: dateFromFormatted,
dateTo: dateToFormatted,
} as const

return useQuery({
queryKey: keys.all(searchParams),
queryFn: async ({queryKey: [_group, {sort, dateFrom, dateTo}], signal}) => {
let response = await client
queryFn: async ({
queryKey: [_group, {sort, dateFrom: queryDateFrom, dateTo: queryDateTo}],
signal,
}) => {
const response = await client
.get('streams/upcoming', {
signal,
searchParams: {sort, dateFrom, dateTo},
searchParams: {sort, dateFrom: queryDateFrom, dateTo: queryDateTo},
})
.json()
return response as StreamType[]
Expand Down
14 changes: 7 additions & 7 deletions source/views/student-orgs/detail-android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ let StudentOrgsDetailView = (): JSX.Element => {

{contacts.length ? (
<Card header="Contact" style={styles.card}>
{contacts.map((c, i) => (
{contacts.map((contact, i) => (
<Text
key={i}
onPress={() => sendEmail({to: [c.email], subject: orgName})}
onPress={() => sendEmail({to: [contact.email], subject: orgName})}
selectable={true}
style={styles.cardBody}
>
{c.title ? c.title + ': ' : ''}
{showNameOrEmail(c)}
{contact.title ? contact.title + ': ' : ''}
{showNameOrEmail(contact)}
</Text>
))}
</Card>
Expand All @@ -124,14 +124,14 @@ let StudentOrgsDetailView = (): JSX.Element => {
header={advisors.length === 1 ? 'Advisor' : 'Advisors'}
style={styles.card}
>
{advisors.map((c, i) => (
{advisors.map((contact, i) => (
<Text
key={i}
onPress={() => sendEmail({to: [c.email], subject: orgName})}
onPress={() => sendEmail({to: [contact.email], subject: orgName})}
selectable={true}
style={styles.cardBody}
>
{c.name} ({c.email})
{contact.name} ({contact.email})
</Text>
))}
</Card>
Expand Down
20 changes: 12 additions & 8 deletions source/views/student-orgs/detail-ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,32 @@ let StudentOrgsDetailView = (): JSX.Element => {

{contacts.length ? (
<Section header="CONTACT">
{contacts.map((c, i) => (
{contacts.map((contact, i) => (
<Cell
key={i}
accessory="DisclosureIndicator"
cellStyle={c.title ? 'Subtitle' : 'Basic'}
detail={c.title}
onPress={() => sendEmail({to: [c.email], subject: orgName})}
title={showNameOrEmail(c)}
cellStyle={contact.title ? 'Subtitle' : 'Basic'}
detail={contact.title}
onPress={() =>
sendEmail({to: [contact.email], subject: orgName})
}
title={showNameOrEmail(contact)}
/>
))}
</Section>
) : null}

{advisors.length ? (
<Section header={advisors.length === 1 ? 'ADVISOR' : 'ADVISORS'}>
{advisors.map((c, i) => (
{advisors.map((contact, i) => (
<Cell
key={i}
accessory="DisclosureIndicator"
cellStyle="Basic"
onPress={() => sendEmail({to: [c.email], subject: orgName})}
title={c.name}
onPress={() =>
sendEmail({to: [contact.email], subject: orgName})
}
title={contact.name}
/>
))}
</Section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ function buildBusSchedules(now: moment.Moment): BusSchedule {
return processBusSchedule(now)(schedules)
}

test('returns the bus times index for the given time', () => {
test('returns the bus times index for the first index', () => {
let now = time('1:00pm')
let input = buildBusSchedules(now)
let actual = getCurrentBusIteration(input, now)
expect(actual.status).toBe('running')
expect(actual.index).toBe(0)
})

test('returns the bus times index for the given time', () => {
test('returns the bus times index for the second index', () => {
let now = time('2:05pm')
let input = buildBusSchedules(now)
let actual = getCurrentBusIteration(input, now)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const CENTRAL_TZ = 'America/Chicago'

const baseTime = moment('2019-12-18T18:39:45').tz(CENTRAL_TZ)

export const time = (time: string): moment.Moment => {
export const time = (timeToFormat: string): moment.Moment => {
return moment
.tz(time, 'h:mma', true, CENTRAL_TZ)
.tz(timeToFormat, 'h:mma', true, CENTRAL_TZ)
.year(baseTime.year())
.month(baseTime.month())
.date(baseTime.date())
}

export const dayAndTime = (time: string): moment.Moment => {
let parsed = moment.tz(time, 'dd h:mma', true, CENTRAL_TZ)
export const dayAndTime = (timeToFormat: string): moment.Moment => {
let parsed = moment.tz(timeToFormat, 'dd h:mma', true, CENTRAL_TZ)

let dayOfWeek = parsed.day()

Expand Down
4 changes: 2 additions & 2 deletions source/views/transportation/bus/lib/get-schedule-for-now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export function getScheduleForNow(
// now.day returns 0-6, Sunday to Saturday
let thisWeekday = allDaysOfWeek[now.day()]

let schedule = schedules.find((schedule) =>
schedule.days.includes(thisWeekday),
let schedule = schedules.find((instance) =>
instance.days.includes(thisWeekday),
)

if (!schedule) {
Expand Down
15 changes: 10 additions & 5 deletions source/views/transportation/bus/line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,19 @@ export function BusLine(props: Props): JSX.Element {
let [status, setStatus] = useState<BusStateEnum>('none')

useEffect(() => {
let {schedule, subtitle, currentBusIteration, status} = deriveFromProps({
let {
schedule: scheduleForToday,
subtitle: scheduleSubtitle,
currentBusIteration: busIteration,
status: currentStatus,
} = deriveFromProps({
line,
now,
})
setSchedule(schedule)
setSubtitle(subtitle)
setStatus(status)
setCurrentBusIteration(currentBusIteration)
setSchedule(scheduleForToday)
setSubtitle(scheduleSubtitle)
setStatus(currentStatus)
setCurrentBusIteration(busIteration)
}, [line, now])

let INFO_EL = (
Expand Down

0 comments on commit 1bb773d

Please sign in to comment.