From ea5c6ef19717dc0eb6e1879cb48704064a263596 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 11 Jan 2025 10:01:34 +0700 Subject: update merchant --- src/lib/merchant/components/Dokumen.jsx | 64 +++++++++++++++++--------------- src/lib/merchant/components/Merchant.jsx | 4 +- 2 files changed, 37 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/lib/merchant/components/Dokumen.jsx b/src/lib/merchant/components/Dokumen.jsx index d9b53e82..a701a36d 100644 --- a/src/lib/merchant/components/Dokumen.jsx +++ b/src/lib/merchant/components/Dokumen.jsx @@ -24,7 +24,13 @@ import MobileView from '@/core/components/views/MobileView'; import DesktopView from '@/core/components/views/DesktopView'; import getFileBase64 from '@/core/utils/getFileBase64'; import odooApi from '~/libs/odooApi'; -const Dokumen = () => { +const Dokumen = ({ handleIsError }) => { + const isError = (value) => { + // Logika menentukan error + const result = value ? true : false; + handleIsError(result); // Panggil handleIsError dari Merchant + return result; + }; const { register, handleSubmit, @@ -76,6 +82,14 @@ const Dokumen = () => { const [isPkp, setIsPkp] = useState(false); const recaptchaRef = useRef(null); + const npwpRef = useRef(null); + const sppkpRef = useRef(null); + const kartuNamaRef = useRef(null); + const suratPernyataanRef = useRef(null); + const fotoKantorRef = useRef(null); + const dataProdukRef = useRef(null); + const pricelistRef = useRef(null); + const ktpDirutRef = useRef(null); const router = useRouter(); const auth = useAuth(); @@ -245,7 +259,12 @@ const Dokumen = () => { loadZip(); } }, [watchsubDistrict, subDistricts]); + const onSubmitHandler = async (values) => { + const options = { + behavior: 'smooth', + block: 'center', + }; const npwp = DeatailFile.npwp; const sppkp = DeatailFile.sppkp; const dokumenKtpDirut = DeatailFile.dokumenKtpDirut; @@ -263,6 +282,10 @@ const Dokumen = () => { return; } if (!dokumenKtpDirut && !isPkp) { + if (ktpDirutRef.current) { + ktpDirutRef.current.scrollIntoView(options); + console.log('MASUK SINI BANG'); + } toast.error('KTP Dirut/Direktur wajib di tambahkan'); return; } @@ -286,6 +309,9 @@ const Dokumen = () => { file_dataProduk: dataProduk ? dataProduk : '', file_pricelist: pricelist ? pricelist : '', }; + isError(true); + toast.dismiss(toastId); + toast.success('Berhasil menambahkan data'); // const formData = new FormData(); // formData.append('npwp', values.npwp[0]); // const create_leads = await createMerchantApi({ data }); @@ -383,7 +409,10 @@ const Dokumen = () => { Pastikan dokumen yang anda upload sudah benar -
+
-
+