Skip to content

Commit

Permalink
fix: refactor MealDay component to streamline styles and improve rend…
Browse files Browse the repository at this point in the history
…ering logic
  • Loading branch information
Robert27 committed Dec 19, 2024
1 parent c0f1632 commit 1eaf3a9
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/components/Food/MealDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export const MealDay = ({
day: Food
index: number
}): React.JSX.Element => {
const { styles } = useStyles(stylesheet)

/**
* Filters an array of meals by restaurant name.
* @param meals - An array of meals.
Expand Down Expand Up @@ -159,8 +161,6 @@ export const MealDay = ({
restaurantName: string
meals: Meal[]
groupedMeals: Record<string, Meal[]>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
styles: any
}

/**
Expand All @@ -174,13 +174,11 @@ export const MealDay = ({
restaurantName,
meals,
groupedMeals,
styles,
}: RestaurantProps): React.JSX.Element | null => {
if (meals.length > 0) {
return (
<View>
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access*/}
<Text style={styles.dayRestaurantTitles}>
<Text style={styles.dayRestaurantTitle}>
{restaurantName}
</Text>
<MealGroup group={groupedMeals} />
Expand All @@ -190,7 +188,6 @@ export const MealDay = ({
return null
}
const { t } = useTranslation('food')
const { styles } = useStyles(stylesheet)
return isEmpty ? (
<>
<View style={styles.emptyContainer}>
Expand All @@ -203,25 +200,21 @@ export const MealDay = ({
restaurantName: 'Mensa Ingolstadt',
meals: ingolstadtMensa,
groupedMeals: ingolstadtMensaGrouped,
styles,
})}
{renderRestaurantView({
restaurantName: 'Theke Neuburg',
meals: neuburgMensa,
groupedMeals: neuburgMensaGrouped,
styles,
})}
{renderRestaurantView({
restaurantName: 'Reimanns',
meals: reimanns,
groupedMeals: reimannsGrouped,
styles,
})}
{renderRestaurantView({
restaurantName: 'Canisius Konvikt',
meals: canisius,
groupedMeals: canisiusGrouped,
styles,
})}
</View>
)
Expand All @@ -241,7 +234,6 @@ const stylesheet = createStyleSheet((theme) => ({
fontSize: 15,
fontWeight: '500',
},
// eslint-disable-next-line react-native-unistyles/no-unused-styles
dayRestaurantTitle: {
color: theme.colors.text,
fontSize: 18,
Expand Down

0 comments on commit 1eaf3a9

Please sign in to comment.