mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 15:08:22 +02:00
feat: add CustomerOrderForm component with automated product lookup and supplier matching
This commit is contained in:
1 parent
22897ede48
commit
95a5a2facc
1 file changed
+3
@@ -161,6 +161,8 @@ export function CustomerOrderForm({
|
|||||||
const [articleNotFound, setArticleNotFound] = useState(false);
|
const [articleNotFound, setArticleNotFound] = useState(false);
|
||||||
// Flag pour éviter que le remplissage auto de productReference ne redéclenche une recherche
|
// Flag pour éviter que le remplissage auto de productReference ne redéclenche une recherche
|
||||||
const autoFilledRef = useRef(false);
|
const autoFilledRef = useRef(false);
|
||||||
|
// En mode édition, ignorer les watchers au premier rendu (valeurs déjà remplies)
|
||||||
|
const initialEditSkipRef = useRef(!!order);
|
||||||
const lookupDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const lookupDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
const gencodeValue = form.watch("gencode");
|
const gencodeValue = form.watch("gencode");
|
||||||
const referenceValue = form.watch("productReference");
|
const referenceValue = form.watch("productReference");
|
||||||
@@ -210,6 +212,7 @@ export function CustomerOrderForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (initialEditSkipRef.current) { initialEditSkipRef.current = false; return; }
|
||||||
if (!gencodeValue || gencodeValue.length < 8) { setArticleNotFound(false); return; }
|
if (!gencodeValue || gencodeValue.length < 8) { setArticleNotFound(false); return; }
|
||||||
if (lookupDebounceRef.current) clearTimeout(lookupDebounceRef.current);
|
if (lookupDebounceRef.current) clearTimeout(lookupDebounceRef.current);
|
||||||
lookupDebounceRef.current = setTimeout(() => {
|
lookupDebounceRef.current = setTimeout(() => {
|
||||||
|
|||||||
Reference in new issue
Block a user