From 8b125d4ecf06d292d7405314caa27428009efa2a Mon Sep 17 00:00:00 2001 From: deploy Date: Wed, 29 Apr 2026 14:59:57 +0200 Subject: [PATCH] "fix-auto-open-guests-for-restaurant" --- frontend/src/pages/NewInvoice.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/NewInvoice.tsx b/frontend/src/pages/NewInvoice.tsx index 46e8b33..ab4ae82 100644 --- a/frontend/src/pages/NewInvoice.tsx +++ b/frontend/src/pages/NewInvoice.tsx @@ -2,7 +2,7 @@ * Page "Nouvelle facture" * Flux complet : capture → recadrage → OCR → formulaire → invités → envoi */ -import { useState, lazy, Suspense, useRef } from 'react'; +import { useState, lazy, Suspense, useRef, useEffect } from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import toast from 'react-hot-toast'; import api from '../api/client'; @@ -68,6 +68,14 @@ export default function NewInvoice() { queryFn: () => api.get('/categories').then((r) => r.data), }); + // Auto-ouvrir la section invités quand la catégorie est "Restaurant" + useEffect(() => { + const selected = categories.find((c) => c.id === parseInt(categoryId)); + if (selected?.name?.toLowerCase().includes('restaurant')) { + setShowGuests(true); + } + }, [categoryId, categories]); + // ── Mutation upload image ─────────────────────────────────── const uploadMutation = useMutation({ mutationFn: async (dataUrl: string) => {