diff --git a/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx b/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx index 780fb29..76b2bc1 100644 --- a/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx +++ b/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx @@ -76,6 +76,8 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { ), }); + const amount = form.watch("amount"); + const handleSubmit = (data: FormProps) => { console.log(data); if (onNext) { @@ -89,15 +91,13 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { } }; - const canCalcTax = useMemo(() => { - return !adjustData; - }, [adjustData]); - - const calcTax = () => { - if (!canCalcTax) return; - const amount = Number(form.getValues("amount")); - if (!amount) return; - form.setValue("tax_amount", String(calcInnerTax(amount))); + const setTax = () => { + const tax = String(calcInnerTax(Number(amount))); + if (tax) { + form.setValue("tax_amount", tax); + } else { + form.setValue("tax_amount", ""); + } }; const adjustDataAPI = useAPICall({ @@ -153,6 +153,10 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { form.setValue("memo", ""); }; + useEffect(() => { + setTax(); + }, [amount]); + const element = ( @@ -202,7 +206,7 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { - + - {canCalcTax && ( - - )} - +