2023-10-06 15:33:10 +07:00
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { MaterialCode, MaterialSetting } from '../models/recipe.model';
|
|
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
|
|
|
export class MaterialService {
|
|
|
|
|
constructor(private _httpClient: HttpClient) {}
|
|
|
|
|
|
|
|
|
|
getMaterialCodes(
|
|
|
|
|
matIds?: number[],
|
2023-10-24 18:01:52 +07:00
|
|
|
country?: string,
|
|
|
|
|
filename?: string
|
2023-10-06 15:33:10 +07:00
|
|
|
): Observable<MaterialCode[]> {
|
|
|
|
|
return this._httpClient.get<MaterialCode[]>(
|
|
|
|
|
`${environment.api}/materials/code`,
|
|
|
|
|
{
|
|
|
|
|
params: {
|
2023-10-24 18:01:52 +07:00
|
|
|
country: country || '',
|
|
|
|
|
filename: filename || '',
|
2023-10-06 15:33:10 +07:00
|
|
|
mat_ids: matIds?.join(',') || '',
|
|
|
|
|
},
|
|
|
|
|
withCredentials: true,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getMaterialSettingById(
|
|
|
|
|
id: number,
|
2023-10-24 18:01:52 +07:00
|
|
|
country?: string,
|
|
|
|
|
filename?: string
|
2023-10-06 15:33:10 +07:00
|
|
|
): Observable<MaterialSetting> {
|
|
|
|
|
return this._httpClient.get<MaterialSetting>(
|
|
|
|
|
`${environment.api}/materials/setting/${id}`,
|
|
|
|
|
{
|
|
|
|
|
params: {
|
2023-10-24 18:01:52 +07:00
|
|
|
country: country || '',
|
|
|
|
|
filename: filename || '',
|
2023-10-06 15:33:10 +07:00
|
|
|
},
|
|
|
|
|
withCredentials: true,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|