feat: implement inventory and pantry management views with CRUD functionality and user-friendly interfaces
This commit is contained in:
@@ -7,9 +7,10 @@ import { UNIT_OPTIONS } from '../../lib/units';
|
||||
|
||||
type Props = {
|
||||
products: Product[];
|
||||
onCreated?: () => void;
|
||||
};
|
||||
|
||||
export default function InventoryForm({ products }: Props) {
|
||||
export default function InventoryForm({ products, onCreated }: Props) {
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
@@ -108,7 +109,8 @@ export default function InventoryForm({ products }: Props) {
|
||||
throw new Error(data?.error || 'Kunde inte spara');
|
||||
}
|
||||
form.reset();
|
||||
router.refresh();
|
||||
if (onCreated) onCreated();
|
||||
else router.refresh();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Okänt fel');
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user