Add frontend imporvements 2

This commit is contained in:
Urtzi Alfaro
2025-09-09 22:27:52 +02:00
parent 2a05048912
commit aff644d793
6 changed files with 32 additions and 30 deletions

View File

@@ -61,9 +61,9 @@ export const inventoryKeys = {
export const useIngredients = (
tenantId: string,
filter?: InventoryFilter,
options?: Omit<UseQueryOptions<PaginatedResponse<IngredientResponse>, ApiError>, 'queryKey' | 'queryFn'>
options?: Omit<UseQueryOptions<IngredientResponse[], ApiError>, 'queryKey' | 'queryFn'>
) => {
return useQuery<PaginatedResponse<IngredientResponse>, ApiError>({
return useQuery<IngredientResponse[], ApiError>({
queryKey: inventoryKeys.ingredients.list(tenantId, filter),
queryFn: () => inventoryService.getIngredients(tenantId, filter),
enabled: !!tenantId,

View File

@@ -36,7 +36,7 @@ export class InventoryService {
async getIngredients(
tenantId: string,
filter?: InventoryFilter
): Promise<PaginatedResponse<IngredientResponse>> {
): Promise<IngredientResponse[]> {
const queryParams = new URLSearchParams();
if (filter?.category) queryParams.append('category', filter.category);
@@ -60,7 +60,7 @@ export class InventoryService {
? `${this.baseUrl}/${tenantId}/ingredients?${queryParams.toString()}`
: `${this.baseUrl}/${tenantId}/ingredients`;
return apiClient.get<PaginatedResponse<IngredientResponse>>(url);
return apiClient.get<IngredientResponse[]>(url);
}
async updateIngredient(
@@ -218,8 +218,8 @@ export class InventoryService {
if (endDate) queryParams.append('end_date', endDate);
const url = queryParams.toString()
? `${this.baseUrl}/${tenantId}/dashboard/analytics?${queryParams.toString()}`
: `${this.baseUrl}/${tenantId}/dashboard/analytics`;
? `/tenants/${tenantId}/dashboard/analytics?${queryParams.toString()}`
: `/tenants/${tenantId}/dashboard/analytics`;
return apiClient.get(url);
}