Skip to content

Commit

Permalink
fix: 🐛 Fixes lunch rendering (#341)
Browse files Browse the repository at this point in the history
* fix: 🐛 Fixes lunch rendering

* empty check
  • Loading branch information
viktorlarsson authored Apr 28, 2021
1 parent 2369367 commit 6c75d9d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/app/components/week.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react'
import moment from 'moment'
import { StyleSheet, View } from 'react-native'
import { useMenu, useTimetable } from '@skolplattformen/api-hooks'
import { TimetableEntry, Child } from '@skolplattformen/embedded-api'
import { TimetableEntry, Child, MenuItem } from '@skolplattformen/embedded-api'
import { LanguageService } from '../services/languageService'
import { translate } from '../utils/translation'

Expand All @@ -25,7 +25,7 @@ interface LessonListProps {

interface DayProps {
weekDay: string
lunch?: string
lunch?: MenuItem
lessons: TimetableEntry[]
}

Expand Down Expand Up @@ -65,7 +65,7 @@ export const Day = ({ weekDay, lunch, lessons }: DayProps) =>
{translate('schedule.lunch', { defaultValue: 'Lunch' })}
</Text>
<Text category="c2" style={styles.lunch}>
{lunch}
{lunch?.description}
</Text>
<Text category="c1" style={styles.endTime}>
{translate('schedule.end', { defaultValue: 'Slutar' })}
Expand Down Expand Up @@ -125,15 +125,11 @@ export const Week = ({ child }: WeekProps) => {
style={styles.pager}
onSelect={(index) => setSelectedIndex(index)}
>
{days.map((weekDay) => (
{days.map((weekDay, index) => (
<Day
key={weekDay}
weekDay={weekDay}
lunch={menu
.filter((m) => m.title.toLowerCase().includes(weekDay))
.pop()
?.description.split('<br/>')
.join('\n')}
lunch={menu[index] || {}}
lessons={lessons
.filter((lesson) => days[lesson.dayOfWeek - 1] === weekDay)
.sort((a, b) => a.dateStart.localeCompare(b.dateStart))}
Expand Down

0 comments on commit 6c75d9d

Please sign in to comment.