fix delay material fetching

This commit is contained in:
pakintada@gmail.com 2024-01-18 16:59:06 +07:00
parent db131d10c0
commit 4ece2cf30c
13 changed files with 220 additions and 143 deletions

View file

@ -94,11 +94,11 @@ export class RecipeDetailsComponent implements OnInit {
toppingSet: ToppingSet[] | null = null;
submenus: Recipe01[] | null = null;
ngOnInit() {
async ngOnInit() {
this.productCode = this._route.snapshot.params['productCode'];
this.recipeDetail$ = this._recipeService
.getRecipeDetail(this.productCode)
this.recipeDetail$ = (await this._recipeService
.getRecipeDetail(this.productCode))
.pipe(first());
this.recipeDetail$.subscribe((detail) => {
@ -109,7 +109,7 @@ export class RecipeDetailsComponent implements OnInit {
this.recipeOriginalDetail = { ...this.recipeDetailForm.getRawValue() };
});
this._recipeService.getSubMenus(this._recipeService.getCurrentCountry(this.department), this._recipeService.getCurrentFile(), this.productCode).subscribe((data) => {
this._recipeService.getSubMenus(await this._recipeService.getCurrentCountry(this.department), this._recipeService.getCurrentFile(), this.productCode).subscribe((data) => {
console.log('Submenus', data);
this.submenus = data;
});
@ -143,7 +143,7 @@ export class RecipeDetailsComponent implements OnInit {
confirmSave = {
title: 'The changes detected!',
message: 'Do you want to save changes?',
confirmCallBack: () => {
confirmCallBack: async () => {
console.log('confirm save');
// get username
@ -177,7 +177,7 @@ export class RecipeDetailsComponent implements OnInit {
// TODO: update value in targeted recipe
console.log('to_send', to_send);
this._recipeService.editChanges(
this._recipeService.getCurrentCountry(this.department),
await this._recipeService.getCurrentCountry(this.department),
this._recipeService.getCurrentFile(),
{
...to_send,