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:
Nils-Johan Gynther
2026-04-16 18:18:27 +02:00
parent 3f6d32ae44
commit d5b360fd62
19 changed files with 74 additions and 751 deletions
+1 -17
View File
@@ -3,6 +3,7 @@
import { useState, useTransition } from 'react';
import { updateInventoryItem } from './actions';
import type { InventoryItem } from '../../features/inventory/types';
import { UNIT_OPTIONS } from '../../lib/units';
type Props = {
item: InventoryItem;
@@ -35,23 +36,6 @@ function parseQuantityInput(input: string, defaultUnit: string) {
return { quantity: value, unit: defaultUnit };
}
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: 'port', label: 'port (portioner)' },
{ value: 'efter smak', label: 'Efter smak' },
{ value: 'förp', label: 'förp (förpackning)' },
{ value: 'klyfta', label: 'klyfta' },
];
const LOCATION_OPTIONS = [
{ value: '', label: 'Välj plats' },
{ value: 'Kyl', label: 'Kyl' },
+1 -17
View File
@@ -3,6 +3,7 @@
import { useState } from 'react';
import { createInventoryItem } from './actions';
import type { Product } from '../../features/inventory/types';
import { UNIT_OPTIONS } from '../../lib/units';
type Props = {
products: Product[];
@@ -13,23 +14,6 @@ export default function InventoryForm({ products }: Props) {
const [error, setError] = useState<string | null>(null);
const [isOpen, setIsOpen] = useState(false);
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: 'port', label: 'port (portioner)' },
{ value: 'efter smak', label: 'Efter smak' },
{ value: 'förp', label: 'förp (förpackning)' },
{ value: 'klyfta', label: 'klyfta' },
];
const LOCATION_OPTIONS = [
{ value: '', label: 'Välj plats' },
{ value: 'Kyl', label: 'Kyl' },