Add traslations

This commit is contained in:
Urtzi Alfaro
2025-12-25 18:35:37 +01:00
parent 82567b8701
commit b95b86ee2c
18 changed files with 516 additions and 52 deletions

View File

@@ -8,6 +8,7 @@ import {
IngredientCreate,
IngredientUpdate,
IngredientResponse,
BulkIngredientResponse,
StockCreate,
StockUpdate,
StockResponse,
@@ -239,7 +240,7 @@ export const useCreateIngredient = (
options?: UseMutationOptions<IngredientResponse, ApiError, { tenantId: string; ingredientData: IngredientCreate }>
) => {
const queryClient = useQueryClient();
return useMutation<IngredientResponse, ApiError, { tenantId: string; ingredientData: IngredientCreate }>({
mutationFn: ({ tenantId, ingredientData }) => inventoryService.createIngredient(tenantId, ingredientData),
onSuccess: (data, { tenantId }) => {
@@ -253,6 +254,22 @@ export const useCreateIngredient = (
});
};
export const useBulkCreateIngredients = (
options?: UseMutationOptions<BulkIngredientResponse, ApiError, { tenantId: string; ingredients: IngredientCreate[] }>
) => {
const queryClient = useQueryClient();
return useMutation<BulkIngredientResponse, ApiError, { tenantId: string; ingredients: IngredientCreate[] }>({
mutationFn: ({ tenantId, ingredients }) => inventoryService.bulkCreateIngredients(tenantId, ingredients),
onSuccess: (data, { tenantId }) => {
// Invalidate all ingredient lists to refetch
queryClient.invalidateQueries({ queryKey: inventoryKeys.ingredients.lists() });
queryClient.invalidateQueries({ queryKey: inventoryKeys.ingredients.byCategory(tenantId) });
},
...options,
});
};
export const useUpdateIngredient = (
options?: UseMutationOptions<
IngredientResponse,

View File

@@ -21,6 +21,7 @@ import {
IngredientUpdate,
IngredientResponse,
IngredientFilter,
BulkIngredientResponse,
// Stock
StockCreate,
StockUpdate,
@@ -72,6 +73,16 @@ export class InventoryService {
);
}
async bulkCreateIngredients(
tenantId: string,
ingredients: IngredientCreate[]
): Promise<BulkIngredientResponse> {
return apiClient.post<BulkIngredientResponse>(
`${this.baseUrl}/${tenantId}/inventory/ingredients/bulk`,
{ ingredients }
);
}
async getIngredient(tenantId: string, ingredientId: string): Promise<IngredientResponse> {
return apiClient.get<IngredientResponse>(
`${this.baseUrl}/${tenantId}/inventory/ingredients/${ingredientId}`

View File

@@ -177,6 +177,28 @@ export interface IngredientResponse {
needs_reorder?: boolean | null;
}
// ===== BULK INGREDIENT SCHEMAS =====
// Mirror: BulkIngredientCreate, BulkIngredientResult, BulkIngredientResponse from inventory.py
export interface BulkIngredientCreate {
ingredients: IngredientCreate[];
}
export interface BulkIngredientResult {
index: number;
success: boolean;
ingredient: IngredientResponse | null;
error: string | null;
}
export interface BulkIngredientResponse {
total_requested: number;
total_created: number;
total_failed: number;
results: BulkIngredientResult[];
transaction_id: string;
}
// ===== STOCK SCHEMAS =====
// Mirror: StockCreate from inventory.py:140