From 69a8244815dde60ad8417299f32d19717e13a579 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Mon, 21 Aug 2023 16:00:27 +0900 Subject: [PATCH] =?UTF-8?q?HT=20=E6=B6=88=E8=B2=BB=E7=A8=8E=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E3=81=AEUI=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 計算ボタン削除 リアルタイムで元の金額から計算するように対応 --- .../hooks/useInputReceiptStep.tsx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) 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 && ( - - )} - +