"fix-auto-open-guests-for-restaurant"

This commit is contained in:
deploy
2026-04-29 14:59:57 +02:00
parent d6b62f5596
commit 8b125d4ecf
+9 -1
View File
@@ -2,7 +2,7 @@
* Page "Nouvelle facture" * Page "Nouvelle facture"
* Flux complet : capture → recadrage → OCR → formulaire → invités → envoi * 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 { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import api from '../api/client'; import api from '../api/client';
@@ -68,6 +68,14 @@ export default function NewInvoice() {
queryFn: () => api.get('/categories').then((r) => r.data), 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 ─────────────────────────────────── // ── Mutation upload image ───────────────────────────────────
const uploadMutation = useMutation({ const uploadMutation = useMutation({
mutationFn: async (dataUrl: string) => { mutationFn: async (dataUrl: string) => {