Add traslations
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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}`
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user