From 6c75d9d1191fa4c6b8f92fe526e4c1f85915bddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sarstr=C3=B6m?= Date: Wed, 28 Apr 2021 21:22:40 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixes=20lunch=20rendering?= =?UTF-8?q?=20(#341)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 Fixes lunch rendering * empty check --- packages/app/components/week.component.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/app/components/week.component.tsx b/packages/app/components/week.component.tsx index a69500fad..3ae92693e 100644 --- a/packages/app/components/week.component.tsx +++ b/packages/app/components/week.component.tsx @@ -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' @@ -25,7 +25,7 @@ interface LessonListProps { interface DayProps { weekDay: string - lunch?: string + lunch?: MenuItem lessons: TimetableEntry[] } @@ -65,7 +65,7 @@ export const Day = ({ weekDay, lunch, lessons }: DayProps) => {translate('schedule.lunch', { defaultValue: 'Lunch' })} - {lunch} + {lunch?.description} {translate('schedule.end', { defaultValue: 'Slutar' })} @@ -125,15 +125,11 @@ export const Week = ({ child }: WeekProps) => { style={styles.pager} onSelect={(index) => setSelectedIndex(index)} > - {days.map((weekDay) => ( + {days.map((weekDay, index) => ( m.title.toLowerCase().includes(weekDay)) - .pop() - ?.description.split('
') - .join('\n')} + lunch={menu[index] || {}} lessons={lessons .filter((lesson) => days[lesson.dayOfWeek - 1] === weekDay) .sort((a, b) => a.dateStart.localeCompare(b.dateStart))}