Refactor logging in IcaRecipeParser and QuickImportService to use NestJS Logger
- Updated IcaRecipeParser to replace console.log statements with Logger for better logging practices. - Enhanced QuickImportService with Logger for consistent logging and error handling. - Changed quantity validation in CreateRecipeIngredientDto and CreateRecipeDto to allow zero. - Removed CanonicalNameForm and NameForm components from the frontend. - Updated EditProductForm to use a select dropdown for categories instead of a text input. - Added validation for product name, canonical name, and category length in product update action. - Refactored unit options into a separate file for better reusability across components. - Removed unused API fetching functions and inventory types to clean up the codebase.
This commit is contained in:
@@ -43,27 +43,3 @@ export async function parseErrorResponse(response: Response): Promise<string> {
|
||||
|
||||
return defaultMessages[status] || `Fel (${status}). Försök igen senare.`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hämta data från API med bra felhantering
|
||||
*/
|
||||
export async function fetchWithErrorHandling(
|
||||
url: string,
|
||||
options?: RequestInit,
|
||||
): Promise<any> {
|
||||
try {
|
||||
const response = await fetch(url, options);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorMessage = await parseErrorResponse(response);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
throw err;
|
||||
}
|
||||
throw new Error('Ett okänt fel inträffade.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export const UNIT_OPTIONS = [
|
||||
{ value: '', label: 'Välj enhet' },
|
||||
{ value: 'g', label: 'g (gram)' },
|
||||
{ value: 'kg', label: 'kg (kilogram)' },
|
||||
{ value: 'hg', label: 'hg (hektogram)' },
|
||||
{ value: 'ml', label: 'ml (milliliter)' },
|
||||
{ value: 'dl', label: 'dl (deciliter)' },
|
||||
{ value: 'l', label: 'l (liter)' },
|
||||
{ value: 'st', label: 'st (styck)' },
|
||||
{ value: 'tsk', label: 'tsk (tesked)' },
|
||||
{ value: 'msk', label: 'msk (matsked)' },
|
||||
{ value: 'krm', label: 'krm (kryddmått)' },
|
||||
{ value: 'port', label: 'port (portioner)' },
|
||||
{ value: 'efter smak', label: 'Efter smak' },
|
||||
{ value: 'förp', label: 'förp (förpackning)' },
|
||||
{ value: 'klyfta', label: 'klyfta' },
|
||||
];
|
||||
Reference in New Issue
Block a user