add topping WIP

This commit is contained in:
pakintada@gmail.com 2024-02-02 17:07:49 +07:00
parent cabfcdee15
commit 16e0e4f9d8
11 changed files with 460 additions and 26 deletions

View file

@ -34,15 +34,15 @@ export class LayoutComponent implements OnInit, OnDestroy {
icon_url: 'assets/icons/recipes.svg',
link: '/' + this.current_department + '/recipes',
},
{
name: 'Log',
icon_url: 'assets/icons/logs.svg',
link: '/' + this.current_department + '/log',
},
{
name: 'Materials',
icon_url: '',
link: '/' + this.current_department + '/materials',
},
{
name: 'Toppings',
icon_url: '',
link: '/' + this.current_department + '/toppings'
}
];
date = new Date();

View file

@ -113,7 +113,7 @@ export interface ToppingGroup {
groupID: string;
idDefault: string;
idInGroup: string;
inUse: string;
inUse: boolean;
name: string;
otherName: string;
}

View file

@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, count } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Topping, ToppingSet } from '../models/recipe.model';
import { Topping, ToppingGroup, ToppingList, ToppingSet } from '../models/recipe.model';
import { RecipeService } from './recipe.service';
import { getCountryMapSwitcher } from 'src/app/shared/helpers/recipe';
@ -10,13 +10,19 @@ import { getCountryMapSwitcher } from 'src/app/shared/helpers/recipe';
providedIn: 'root',
})
export class ToppingService {
constructor(private _httpClient: HttpClient, private _recipeService: RecipeService) {}
constructor(
private _httpClient: HttpClient,
private _recipeService: RecipeService
) {}
async getToppings(country: string, filename: string): Promise<Observable<Topping>> {
console.log("getToppings", country);
async getToppings(
country: string,
filename: string
): Promise<Observable<Topping>> {
console.log('getToppings', country);
let asyncCountry = await this._recipeService.getCurrentCountry();
country = getCountryMapSwitcher(asyncCountry);
console.log("getToppingsPreFetch", country, asyncCountry);
console.log('getToppingsPreFetch', country, asyncCountry);
return this._httpClient.get<Topping>(
`${environment.api}/recipes/${country}/${filename}/toppings`,
{
@ -24,16 +30,20 @@ export class ToppingService {
country: country,
filename: filename,
},
withCredentials: true
withCredentials: true,
}
);
}
async getToppingsOfRecipe(country: string, filename: string, productCode: string): Promise<Observable<ToppingSet[]>> {
console.log("getToppingsOfRecipe", country);
async getToppingsOfRecipe(
country: string,
filename: string,
productCode: string
): Promise<Observable<ToppingSet[]>> {
console.log('getToppingsOfRecipe', country);
let asyncCountry = await this._recipeService.getCurrentCountry();
country = country || asyncCountry;
console.log("getToppingsOfRecipePreFetch", country, asyncCountry);
console.log('getToppingsOfRecipePreFetch', country, asyncCountry);
return this._httpClient.get<ToppingSet[]>(
`${environment.api}/recipes/${country}/${filename}/${productCode}/toppings`,
{
@ -41,8 +51,49 @@ export class ToppingService {
country: country,
filename: filename,
},
withCredentials: true
withCredentials: true,
}
);
}
async getToppingGroups(
country: string,
filename: string
): Promise<Observable<ToppingGroup[]>> {
console.log('fetching topping group');
let asyncCountry = await this._recipeService.getCurrentCountry();
country = getCountryMapSwitcher(asyncCountry);
return this._httpClient.get<ToppingGroup[]>(
`${environment.api}/toppings/groups/${country}/${filename}`,
{
params:{
country: country,
filename: filename
},
withCredentials: true,
}
);
}
async getToppingLists(
country: string,
filename: string
): Promise<Observable<ToppingList[]>> {
console.log('fetching topping list');
let asyncCountry = await this._recipeService.getCurrentCountry();
country = getCountryMapSwitcher(asyncCountry);
return this._httpClient.get<ToppingList[]>(
`${environment.api}/toppings/lists/${country}/${filename}`,
{
params:{
country: country,
filename: filename
},
withCredentials: true,
}
);
}
}