commit
710f0b2c10
@ -1,5 +1,11 @@
|
||||
<div>
|
||||
<h1>Projet Recipe</h1>
|
||||
<br />
|
||||
<h2>Commandes en cours</h2>
|
||||
<ul>
|
||||
<li *ngFor="let recipe of currentOrders">
|
||||
{{ recipe.name }}
|
||||
</li>
|
||||
</ul>
|
||||
<p>Bienvenue sur Recipe</p>
|
||||
</div>
|
||||
|
@ -1,12 +1,22 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Recipe } from '../models/recipe';
|
||||
import { RecipeService } from '../services/recipe.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
standalone: true,
|
||||
imports: [],
|
||||
imports: [CommonModule],
|
||||
templateUrl: './home.component.html',
|
||||
styleUrl: './home.component.scss'
|
||||
})
|
||||
export class HomeComponent {
|
||||
export class HomeComponent implements OnInit {
|
||||
currentOrders: Recipe[] = [];
|
||||
|
||||
constructor(private recipeService: RecipeService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// Charger les commandes en cours depuis le service
|
||||
this.currentOrders = this.recipeService.getCurrentOrders();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<!--api
|
||||
<div>
|
||||
<h2>Add New Ingredient</h2>
|
||||
<form (ngSubmit)="addIngredient()">
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput [(ngModel)]="ingredient.name" name="name" required />
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" type="submit">
|
||||
Add Ingredient
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div>
|
||||
<h2>Add New Ingredient</h2>
|
||||
<form (ngSubmit)="addIngredient()">
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput [(ngModel)]="name" name="name" required />
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" type="submit">
|
||||
Add Ingredient
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
@ -0,0 +1,38 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { IngredientService } from '../services/ingredient.service';
|
||||
import { Ingredient } from '../models/ingredient';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ingredient-add',
|
||||
standalone: true,
|
||||
imports: [HttpClientModule, MatFormFieldModule, MatButtonModule, MatSelectModule, FormsModule],
|
||||
templateUrl: './ingredient-add.component.html',
|
||||
styleUrl: './ingredient-add.component.scss'
|
||||
})
|
||||
export class IngredientAddComponent {
|
||||
// version api
|
||||
// ingredient: Ingredient = new Ingredient(0, '');
|
||||
name: string = '';
|
||||
|
||||
constructor(private ingredientService: IngredientService, private router: Router) {}
|
||||
|
||||
addIngredient(): void {
|
||||
if (this.name.trim()) {
|
||||
this.ingredientService.addIngredient(this.name.trim());
|
||||
this.router.navigate(['/ingredients']);
|
||||
}
|
||||
}
|
||||
|
||||
// version api
|
||||
// addIngredient(): void {
|
||||
// this.ingredientService.addIngredient(this.ingredient).subscribe(() => {
|
||||
// this.router.navigate(['/ingredients']);
|
||||
// });
|
||||
// }
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<div *ngIf="ingredient">
|
||||
<h2>Edit Ingredient</h2>
|
||||
<form (ngSubmit)="save()">
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput [(ngModel)]="ingredient.name" name="name" required />
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
@ -0,0 +1,50 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Ingredient } from '../models/ingredient';
|
||||
import { IngredientService } from '../services/ingredient.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ingredient-edit',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatFormFieldModule, MatButtonModule, FormsModule],
|
||||
templateUrl: './ingredient-edit.component.html',
|
||||
styleUrls: ['./ingredient-edit.component.scss']
|
||||
})
|
||||
export class IngredientEditComponent implements OnInit {
|
||||
ingredient!: Ingredient;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private ingredientService: IngredientService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
const id = Number(this.route.snapshot.paramMap.get('id'));
|
||||
this.ingredient = this.ingredientService.getIngredient(id);
|
||||
}
|
||||
|
||||
save(): void {
|
||||
// Implement save logic here
|
||||
this.router.navigate(['/ingredients']);
|
||||
}
|
||||
|
||||
// version api
|
||||
// ngOnInit(): void {
|
||||
// const id = Number(this.route.snapshot.paramMap.get('id'));
|
||||
// this.ingredientService.getIngredient(id).subscribe((ingredient) => {
|
||||
// this.ingredient = ingredient;
|
||||
// });
|
||||
// }
|
||||
|
||||
// save(): void {
|
||||
// this.ingredientService.updateIngredient(this.ingredient.id, this.ingredient).subscribe(() => {
|
||||
// this.router.navigate(['/ingredients']);
|
||||
// });
|
||||
// }
|
||||
}
|
Loading…
Reference in new issue