Skip to content

Commit

Permalink
Merge pull request #98 from COS301-SE-2023/main-page-full-stack
Browse files Browse the repository at this point in the history
Main page full stack
  • Loading branch information
theodorleroux authored Jul 31, 2023
2 parents d4bc235 + 52f8776 commit 9ec4a39
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
42 changes: 23 additions & 19 deletions frontend/src/app/components/daily-meals/daily-meals.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<ion-item>
<div class="card-container">
<div class="label-container">
<ion-label>{{ dayData.mealDate }}</ion-label>
<ion-item *ngIf="dayData">
<!-- Rest of the code -->
<ion-label>{{ dayData?.mealDate }}</ion-label>
</ion-item>

<span class="line"></span>
</div>

Expand All @@ -12,11 +16,11 @@
<div ion-no-padding style="padding-inline-end:0px !important;">
<ion-card-header>
<ion-card-subtitle>Breakfast</ion-card-subtitle>
<ion-card-title>{{ dayData.breakfast.name }}</ion-card-title>
<ion-card-title>{{ dayData?.breakfast?.name }}</ion-card-title>
</ion-card-header>

<ion-card-content>
{{ dayData.breakfast.description }}
{{ dayData?.breakfast?.description }}
</ion-card-content>


Expand All @@ -33,7 +37,7 @@
<ng-template>
<ion-header>
<ion-toolbar>
<ion-title>{{ dayData.breakfast.name }}</ion-title>
<ion-title>{{ dayData?.breakfast?.name }}</ion-title>
<ion-buttons slot="end">
<ion-button (click)="setOpen(false, null)">Close</ion-button>
</ion-buttons>
Expand All @@ -46,9 +50,9 @@
/>
</ion-avatar>
<ion-content class="ion-padding">
<p>{{ dayData.breakfast.ingredients }}</p>
<p>{{ dayData.breakfast.instructions }}</p>
<p>{{ dayData.breakfast.cookingTime }}</p>
<p>{{ dayData?.breakfast?.ingredients }}</p>
<p>{{ dayData?.breakfast?.instructions }}</p>
<p>{{ dayData?.breakfast?.cookingTime }}</p>
</ion-content>
</ng-template>
</ion-modal>
Expand All @@ -71,11 +75,11 @@
<div ion-no-padding style="padding-inline-end:0px !important;">
<ion-card-header>
<ion-card-subtitle>Lunch</ion-card-subtitle>
<ion-card-title>{{ dayData.lunch.name }}</ion-card-title>
<ion-card-title>{{ dayData?.lunch?.name }}</ion-card-title>
</ion-card-header>

<ion-card-content>
{{ dayData.lunch.description }}
{{ dayData?.lunch?.description }}
</ion-card-content>


Expand All @@ -94,7 +98,7 @@
<ng-template>
<ion-header>
<ion-toolbar>
<ion-title>{{ dayData.lunch.name }}</ion-title>
<ion-title>{{ dayData?.lunch?.name }}</ion-title>
<ion-buttons slot="end">
<ion-button (click)="setOpen(false, null)">Close</ion-button>
</ion-buttons>
Expand All @@ -107,9 +111,9 @@
/>
</ion-avatar>
<ion-content class="ion-padding">
<p>{{ dayData.lunch.ingredients }}</p>
<p>{{ dayData.lunch.instructions }}</p>
<p>{{ dayData.lunch.cookingTime }}</p>
<p>{{ dayData?.lunch?.ingredients }}</p>
<p>{{ dayData?.lunch?.instructions }}</p>
<p>{{ dayData?.lunch?.cookingTime }}</p>
</ion-content>
</ng-template>
</ion-modal>
Expand All @@ -131,11 +135,11 @@
<div ion-no-padding style="padding-inline-end:0px !important;">
<ion-card-header>
<ion-card-subtitle>Dinner</ion-card-subtitle>
<ion-card-title>{{ dayData.dinner.name }}</ion-card-title>
<ion-card-title>{{ dayData?.dinner?.name }}</ion-card-title>
</ion-card-header>

<ion-card-content>
{{ dayData.dinner.description }}
{{ dayData?.dinner?.description }}
</ion-card-content>


Expand All @@ -154,7 +158,7 @@
<ng-template>
<ion-header>
<ion-toolbar>
<ion-title>{{ dayData.dinner.name }}</ion-title>
<ion-title>{{ dayData?.dinner?.name }}</ion-title>
<ion-buttons slot="end">
<ion-button (click)="setOpen(false, null)">Close</ion-button>
</ion-buttons>
Expand All @@ -167,9 +171,9 @@
/>
</ion-avatar>
<ion-content class="ion-padding">
<p>{{ dayData.dinner.ingredients }}</p>
<p>{{ dayData.dinner.instructions }}</p>
<p>{{ dayData.dinner.cookingTime }}</p>
<p>{{ dayData?.dinner?.ingredients }}</p>
<p>{{ dayData?.dinner?.instructions }}</p>
<p>{{ dayData?.dinner?.cookingTime }}</p>
</ion-content>
</ng-template>
</ion-modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class DailyMealsComponent implements OnInit {
breakfast: string = "breakfast";
lunch: string = "lunch";
dinner: string = "dinner";

mealDate: string | undefined;
@Input() todayData!: MealI[];
@Input() dayData!: DaysMealsI;
item: DaysMealsI | undefined;
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/models/daysMeals.model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MealI } from "./meal.model";

export interface DaysMealsI {
breakfast:MealI;
lunch:MealI;
dinner:MealI;
mealDate:string | "Monday";
breakfast:MealI | undefined;
lunch:MealI | undefined ;
dinner:MealI | undefined;
mealDate:string | undefined;
}
2 changes: 1 addition & 1 deletion frontend/src/app/pages/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class HomePage implements OnInit{
if (Array.isArray(data)) {
const mealsWithDate = data.map((item) => ({
...item,
date: this.getDayOfWeek(index),
mealDate: this.getDayOfWeek(index),
}));
this.daysMeals.push(...mealsWithDate);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MealGenerationService {
"breakfast": daysMeal.breakfast,
"lunch": daysMeal.lunch,
"dinner": daysMeal.dinner,
"mealDate": daysMeal.mealDate.toUpperCase(),
"mealDate": daysMeal?.mealDate?.toUpperCase(),
"meal": meal
});
}
Expand Down

0 comments on commit 9ec4a39

Please sign in to comment.