diff --git a/src/components/Form.tsx b/src/components/Form.tsx index f09919f..af69760 100644 --- a/src/components/Form.tsx +++ b/src/components/Form.tsx @@ -187,7 +187,7 @@ export default function Form({ vdp }: Props) { } })} - + setError(false)} /> { +const TradeInfo = ({ errors, isSubmitting }: TradeInfoProps) => { const [payload, setPayload] = useState({}) const { lenders, lenderCats, isTrade, setTrade } = usePayoffLenders() const { watchTradeInVin } = useTradeQuery(setPayload) @@ -23,6 +24,7 @@ const TradeInfo = ({ errors }: TradeInfoProps) => { lenders, payload, setPayload, + isSubmitting, }) const customer = useCustomer((s) => s.customer) const methods = useFormContext() diff --git a/src/hooks/usePayoffQuery.tsx b/src/hooks/usePayoffQuery.tsx index 0a9f626..83a4397 100644 --- a/src/hooks/usePayoffQuery.tsx +++ b/src/hooks/usePayoffQuery.tsx @@ -11,11 +11,13 @@ const usePayoffQuery = ({ lenders, payload, setPayload, + isSubmitting, }: { watchTradeInVin: string lenders: Record[] payload: any setPayload: Dispatch + isSubmitting: boolean }) => { const [customer, setCustomer] = useCustomer((s) => [s.customer, s.setCustomer]) const { setValue, setFocus, watch } = useFormContext() @@ -56,6 +58,12 @@ const usePayoffQuery = ({ } }, [isLienOther, lenders, setFocus, setPayload, ssn, watchLienName, watchTradeInVin]) + useEffect(() => { + if(isSubmitting) { + setReady(false) + } + },[isReady, isSubmitting, setReady]) + useEffect(() => { if (isReady && isTrade && Object.keys(payload)?.length > 0) { const getPayoff = async () => {