From fd867a90e22fb2fc2fb16237165796ebe0cabab0 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 27 May 2025 08:29:22 +0700 Subject: off site merchant --- src/lib/merchant/api/createMerchantApi.js | 24 +- src/lib/merchant/api/getMerchantApi.js | 22 +- src/lib/merchant/api/getMerchantProgresApi.js | 16 +- src/lib/merchant/components/AccountSwitch.jsx | 112 +- src/lib/merchant/components/Dokumen.jsx | 2434 ++++++++--------- .../merchant/components/InformasiPerusahaan.jsx | 2722 ++++++++++---------- src/lib/merchant/components/InformasiVendor.jsx | 1496 +++++------ src/lib/merchant/components/Konfirmasi.jsx | 440 ++-- src/lib/merchant/components/Merchant.jsx | 274 +- src/lib/merchant/components/SyaratDagang.jsx | 1644 ++++++------ 10 files changed, 4592 insertions(+), 4592 deletions(-) diff --git a/src/lib/merchant/api/createMerchantApi.js b/src/lib/merchant/api/createMerchantApi.js index 4c4f96ba..878ab7c0 100644 --- a/src/lib/merchant/api/createMerchantApi.js +++ b/src/lib/merchant/api/createMerchantApi.js @@ -1,14 +1,14 @@ -import odooApi from '@/core/api/odooApi'; -import { getAuth } from '@/core/utils/auth'; +// import odooApi from '@/core/api/odooApi'; +// import { getAuth } from '@/core/utils/auth'; -const createMerchantApi = async ({ data }) => { - const auth = getAuth(); - const lead = await odooApi( - 'POST', - `/api/v1/merchant/${auth.partnerId}`, - data - ); - return lead; -}; +// const createMerchantApi = async ({ data }) => { +// const auth = getAuth(); +// const lead = await odooApi( +// 'POST', +// `/api/v1/merchant/${auth.partnerId}`, +// data +// ); +// return lead; +// }; -export default createMerchantApi; +// export default createMerchantApi; diff --git a/src/lib/merchant/api/getMerchantApi.js b/src/lib/merchant/api/getMerchantApi.js index a1a4f877..be27e947 100644 --- a/src/lib/merchant/api/getMerchantApi.js +++ b/src/lib/merchant/api/getMerchantApi.js @@ -1,13 +1,13 @@ -import odooApi from '@/core/api/odooApi'; -import { getAuth } from '@/core/utils/auth'; +// import odooApi from '@/core/api/odooApi'; +// import { getAuth } from '@/core/utils/auth'; -const createMerchantApi = async () => { - const auth = getAuth(); - const lead = await odooApi( - 'GET', - `/api/v1/detail-merchant/${auth.partnerId}` - ); - return lead; -}; +// const createMerchantApi = async () => { +// const auth = getAuth(); +// const lead = await odooApi( +// 'GET', +// `/api/v1/detail-merchant/${auth.partnerId}` +// ); +// return lead; +// }; -export default createMerchantApi; +// export default createMerchantApi; diff --git a/src/lib/merchant/api/getMerchantProgresApi.js b/src/lib/merchant/api/getMerchantProgresApi.js index d356ad78..3bec15fe 100644 --- a/src/lib/merchant/api/getMerchantProgresApi.js +++ b/src/lib/merchant/api/getMerchantProgresApi.js @@ -1,10 +1,10 @@ -import odooApi from '@/core/api/odooApi'; -import { getAuth } from '@/core/utils/auth'; +// import odooApi from '@/core/api/odooApi'; +// import { getAuth } from '@/core/utils/auth'; -const createMerchantApi = async () => { - const auth = getAuth(); - const lead = await odooApi('GET', `/api/v1/check-merchant/${auth.partnerId}`); - return lead; -}; +// const createMerchantApi = async () => { +// const auth = getAuth(); +// const lead = await odooApi('GET', `/api/v1/check-merchant/${auth.partnerId}`); +// return lead; +// }; -export default createMerchantApi; +// export default createMerchantApi; diff --git a/src/lib/merchant/components/AccountSwitch.jsx b/src/lib/merchant/components/AccountSwitch.jsx index b9bf34b1..abbdcc92 100644 --- a/src/lib/merchant/components/AccountSwitch.jsx +++ b/src/lib/merchant/components/AccountSwitch.jsx @@ -1,60 +1,60 @@ -import Link from 'next/link'; -import Image from '~/components/ui/image'; -import whatsappUrl from '@/core/utils/whatsappUrl'; -import { useEffect, useState } from 'react'; -import odooApi from '@/core/api/odooApi'; -import useDevice from '@/core/hooks/useDevice'; -import useAuth from '@/core/hooks/useAuth'; -import axios from 'axios'; -import { toast } from 'react-hot-toast'; -import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; +// import Link from 'next/link'; +// import Image from '~/components/ui/image'; +// import whatsappUrl from '@/core/utils/whatsappUrl'; +// import { useEffect, useState } from 'react'; +// import odooApi from '@/core/api/odooApi'; +// import useDevice from '@/core/hooks/useDevice'; +// import useAuth from '@/core/hooks/useAuth'; +// import axios from 'axios'; +// import { toast } from 'react-hot-toast'; +// import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; -const FinishTempo = ({ query }) => { - const [data, setData] = useState(); - const [transactionData, setTransactionData] = useState(); - const { isDesktop, isMobile } = useDevice(); - const auth = useAuth(); +// const FinishTempo = ({ query }) => { +// const [data, setData] = useState(); +// const [transactionData, setTransactionData] = useState(); +// const { isDesktop, isMobile } = useDevice(); +// const auth = useAuth(); - return ( -
-
-

- Form Merchant Kamu Gagal Dilakukan -

-
- Registrasi Tempo +// return ( +//
+//
+//

+// Form Merchant Kamu Gagal Dilakukan +//

+//
+// Registrasi Tempo -
- Terima kasih atas minat anda untuk mendaftar merchant, namun sayangnya - akun anda bukan merupakan akun bisnis. Segera ubah akun anda menjadi - Bisnis untuk menggunakan fitur ini -
- - Ubah Akun - - -
- ); -}; +//
+// Terima kasih atas minat anda untuk mendaftar merchant, namun sayangnya +// akun anda bukan merupakan akun bisnis. Segera ubah akun anda menjadi +// Bisnis untuk menggunakan fitur ini +//
+// +// Ubah Akun +// +// +//
+// ); +// }; -export default FinishTempo; +// export default FinishTempo; diff --git a/src/lib/merchant/components/Dokumen.jsx b/src/lib/merchant/components/Dokumen.jsx index c13353e5..42a9426b 100644 --- a/src/lib/merchant/components/Dokumen.jsx +++ b/src/lib/merchant/components/Dokumen.jsx @@ -1,1252 +1,1252 @@ -import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; -import cityApi from '@/lib/address/api/cityApi'; -import stateApi from '@/lib/address/api/stateApi.js'; -import districtApi from '@/lib/address/api/districtApi'; -import subDistrictApi from '@/lib/address/api/subDistrictApi'; -import { yupResolver } from '@hookform/resolvers/yup'; -import React, { - useEffect, - useRef, - useState, - forwardRef, - useImperativeHandle, -} from 'react'; -import ReCAPTCHA from 'react-google-recaptcha'; -import { Controller, useForm } from 'react-hook-form'; -import { toast } from 'react-hot-toast'; -import * as Yup from 'yup'; -import createMerchantApi from '../api/createMerchantApi'; -import getMerchantApi from '../api/getMerchantApi'; -import addressApi from '@/lib/address/api/addressApi'; -import PageContent from '@/lib/content/components/PageContent'; -import { useRouter } from 'next/router'; -import useAuth from '@/core/hooks/useAuth'; -import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react'; -import { EyeIcon } from '@heroicons/react/24/outline'; -import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; -import Image from 'next/image'; -import ImageBanner from '~/components/ui/image'; -import { ChevronRightIcon } from '@heroicons/react/24/outline'; -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 = forwardRef( - ({ handleIsError, isKonfirmasi, buttonSubmitClick }, ref) => { - const isError = (value) => { - // Logika menentukan error - const result = value ? true : false; - handleIsError(result); // Panggil handleIsError dari Merchant - return result; - }; - const { - register, - handleSubmit, - formState: { errors }, - control, - reset, - watch, - setValue, - getValues, - } = useForm({ - resolver: yupResolver(validationSchema), - defaultValues, - }); +// import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; +// import cityApi from '@/lib/address/api/cityApi'; +// import stateApi from '@/lib/address/api/stateApi.js'; +// import districtApi from '@/lib/address/api/districtApi'; +// import subDistrictApi from '@/lib/address/api/subDistrictApi'; +// import { yupResolver } from '@hookform/resolvers/yup'; +// import React, { +// useEffect, +// useRef, +// useState, +// forwardRef, +// useImperativeHandle, +// } from 'react'; +// import ReCAPTCHA from 'react-google-recaptcha'; +// import { Controller, useForm } from 'react-hook-form'; +// import { toast } from 'react-hot-toast'; +// import * as Yup from 'yup'; +// import createMerchantApi from '../api/createMerchantApi'; +// import getMerchantApi from '../api/getMerchantApi'; +// import addressApi from '@/lib/address/api/addressApi'; +// import PageContent from '@/lib/content/components/PageContent'; +// import { useRouter } from 'next/router'; +// import useAuth from '@/core/hooks/useAuth'; +// import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react'; +// import { EyeIcon } from '@heroicons/react/24/outline'; +// import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +// import Image from 'next/image'; +// import ImageBanner from '~/components/ui/image'; +// import { ChevronRightIcon } from '@heroicons/react/24/outline'; +// 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 = forwardRef( +// ({ handleIsError, isKonfirmasi, buttonSubmitClick }, ref) => { +// const isError = (value) => { +// // Logika menentukan error +// const result = value ? true : false; +// handleIsError(result); // Panggil handleIsError dari Merchant +// return result; +// }; +// const { +// register, +// handleSubmit, +// formState: { errors }, +// control, +// reset, +// watch, +// setValue, +// getValues, +// } = useForm({ +// resolver: yupResolver(validationSchema), +// defaultValues, +// }); - const list_unit = [ - { - value: 'Manufacturing', - label: 'Manufacturing', - }, - { - value: 'Hospitality', - label: 'Hospitality', - }, - { - value: 'Automotive', - label: 'Automotive', - }, - { - value: 'Retail', - label: 'Retail', - }, - { - value: 'Maining', - label: 'Maining', - }, - { - value: 'Lain - Lain', - label: 'Lain - Lain', - }, - ]; - const [fileNames, setFileNames] = useState({}); - const [DeatailFile, setDetailFile] = useState({}); - const [isExample, setIsExample] = useState(false); - const [isPkp, setIsPkp] = useState(false); +// const list_unit = [ +// { +// value: 'Manufacturing', +// label: 'Manufacturing', +// }, +// { +// value: 'Hospitality', +// label: 'Hospitality', +// }, +// { +// value: 'Automotive', +// label: 'Automotive', +// }, +// { +// value: 'Retail', +// label: 'Retail', +// }, +// { +// value: 'Maining', +// label: 'Maining', +// }, +// { +// value: 'Lain - Lain', +// label: 'Lain - Lain', +// }, +// ]; +// const [fileNames, setFileNames] = useState({}); +// const [DeatailFile, setDetailFile] = useState({}); +// const [isExample, setIsExample] = useState(false); +// const [isPkp, setIsPkp] = useState(false); - const npwpRef = useRef(null); - const sppkpRef = useRef(null); - const ktpDirutRef = useRef(null); - const kartuNamaRef = useRef(null); - const suratPernyataanRef = useRef(null); - const fotoKantorRef = useRef(null); - const dataProdukRef = useRef(null); - const pricelistRef = useRef(null); - const router = useRouter(); +// const npwpRef = useRef(null); +// const sppkpRef = useRef(null); +// const ktpDirutRef = useRef(null); +// const kartuNamaRef = useRef(null); +// const suratPernyataanRef = useRef(null); +// const fotoKantorRef = useRef(null); +// const dataProdukRef = useRef(null); +// const pricelistRef = useRef(null); +// const router = useRouter(); - const auth = useAuth(); - if (auth == false) { - router.push(`/login?next=${encodeURIComponent('/daftar-merchant')}`); - } - useEffect(() => { - const loadData = async () => { - try { - const data = await getMerchantApi(); - if (data) { - setFileNames((prev) => ({ - ...prev, - ['npwp']: data.fileNpwp ? data.fileNpwp.name : '', - ['sppkp']: data.fileSppkp ? data.fileSppkp.name : '', - ['dokumenKtpDirut']: data.fileDokumenKtpDirut - ? data.fileDokumenKtpDirut.name - : '', - ['kartuNama']: data.fileKartuNama ? data.fileKartuNama.name : '', - ['suratPernyataan']: data.fileSuratPernyataan - ? data.fileSuratPernyataan.name - : '', - ['fotoKantor']: data.fileFotoKantor - ? data.fileFotoKantor.name - : '', - ['dataProduk']: data.fileDataProduk - ? data.fileDataProduk.name - : '', - ['pricelist']: data.filePricelist ? data.filePricelist.name : '', - })); - } - } catch (error) { - console.error('Error loading profile:', error); - handleIsError(true); // Jika ada error, panggil fungsi error handler - } - }; +// const auth = useAuth(); +// if (auth == false) { +// router.push(`/login?next=${encodeURIComponent('/daftar-merchant')}`); +// } +// useEffect(() => { +// const loadData = async () => { +// try { +// const data = await getMerchantApi(); +// if (data) { +// setFileNames((prev) => ({ +// ...prev, +// ['npwp']: data.fileNpwp ? data.fileNpwp.name : '', +// ['sppkp']: data.fileSppkp ? data.fileSppkp.name : '', +// ['dokumenKtpDirut']: data.fileDokumenKtpDirut +// ? data.fileDokumenKtpDirut.name +// : '', +// ['kartuNama']: data.fileKartuNama ? data.fileKartuNama.name : '', +// ['suratPernyataan']: data.fileSuratPernyataan +// ? data.fileSuratPernyataan.name +// : '', +// ['fotoKantor']: data.fileFotoKantor +// ? data.fileFotoKantor.name +// : '', +// ['dataProduk']: data.fileDataProduk +// ? data.fileDataProduk.name +// : '', +// ['pricelist']: data.filePricelist ? data.filePricelist.name : '', +// })); +// } +// } catch (error) { +// console.error('Error loading profile:', error); +// handleIsError(true); // Jika ada error, panggil fungsi error handler +// } +// }; - loadData(); - }, [reset, handleIsError]); +// loadData(); +// }, [reset, handleIsError]); - useEffect(() => { - if (!isKonfirmasi) { - window.scrollTo({ - top: 0, - behavior: 'smooth', - }); - } - }, []); - useImperativeHandle(ref, () => () => { - handleSubmit(onSubmitHandler)(); - }); - useEffect(() => { - const loadProfile = async () => { - try { - const dataProfile = await addressApi({ - id: auth.parentId ? auth.parentId : auth.partnerId, - }); - if (dataProfile.companyType == 'pkp') { - setIsPkp(true); - } - setValue('company', dataProfile?.name); - setValue('address', dataProfile?.alamatBisnis); - setValue('state', parseInt(dataProfile.stateId.id)); - setValue('city', parseInt(dataProfile.city.id)); - setValue('district', parseInt(dataProfile.district.id)); - setValue('subDistrict', parseInt(dataProfile.subDistrict.id)); - setValue('zip', parseInt(dataProfile.zip)); - } catch (error) { - console.error('Error loading profile:', error); - } - }; +// useEffect(() => { +// if (!isKonfirmasi) { +// window.scrollTo({ +// top: 0, +// behavior: 'smooth', +// }); +// } +// }, []); +// useImperativeHandle(ref, () => () => { +// handleSubmit(onSubmitHandler)(); +// }); +// useEffect(() => { +// const loadProfile = async () => { +// try { +// const dataProfile = await addressApi({ +// id: auth.parentId ? auth.parentId : auth.partnerId, +// }); +// if (dataProfile.companyType == 'pkp') { +// setIsPkp(true); +// } +// setValue('company', dataProfile?.name); +// setValue('address', dataProfile?.alamatBisnis); +// setValue('state', parseInt(dataProfile.stateId.id)); +// setValue('city', parseInt(dataProfile.city.id)); +// setValue('district', parseInt(dataProfile.district.id)); +// setValue('subDistrict', parseInt(dataProfile.subDistrict.id)); +// setValue('zip', parseInt(dataProfile.zip)); +// } catch (error) { +// console.error('Error loading profile:', error); +// } +// }; - loadProfile(); - }, [auth?.parentId]); +// loadProfile(); +// }, [auth?.parentId]); - const onSubmitHandler = async (values) => { - const options = { - behavior: 'smooth', - block: 'center', - }; - const npwp = { name: fileNames.npwp, format: DeatailFile.npwp }; - const sppkp = { name: fileNames.sppkp, format: DeatailFile.sppkp }; - const dokumenKtpDirut = { - name: fileNames.dokumenKtpDirut, - format: DeatailFile.dokumenKtpDirut, - }; - const kartuNama = { - name: fileNames.kartuNama, - format: DeatailFile.kartuNama, - }; - const suratPernyataan = { - name: fileNames.suratPernyataan, - format: DeatailFile.suratPernyataan, - }; - const fotoKantor = { - name: fileNames.fotoKantor, - format: DeatailFile.fotoKantor, - }; - const dataProduk = { - name: fileNames.dataProduk, - format: DeatailFile.dataProduk, - }; - const pricelist = { - name: fileNames.pricelist, - format: DeatailFile.pricelist, - }; +// const onSubmitHandler = async (values) => { +// const options = { +// behavior: 'smooth', +// block: 'center', +// }; +// const npwp = { name: fileNames.npwp, format: DeatailFile.npwp }; +// const sppkp = { name: fileNames.sppkp, format: DeatailFile.sppkp }; +// const dokumenKtpDirut = { +// name: fileNames.dokumenKtpDirut, +// format: DeatailFile.dokumenKtpDirut, +// }; +// const kartuNama = { +// name: fileNames.kartuNama, +// format: DeatailFile.kartuNama, +// }; +// const suratPernyataan = { +// name: fileNames.suratPernyataan, +// format: DeatailFile.suratPernyataan, +// }; +// const fotoKantor = { +// name: fileNames.fotoKantor, +// format: DeatailFile.fotoKantor, +// }; +// const dataProduk = { +// name: fileNames.dataProduk, +// format: DeatailFile.dataProduk, +// }; +// const pricelist = { +// name: fileNames.pricelist, +// format: DeatailFile.pricelist, +// }; - if (!npwp.name && isPkp) { - if (npwpRef?.current) { - npwpRef.current.scrollIntoView(options); - } - toast.error('NPWP wajib di tambahkan'); - return; - } - if (!sppkp.name && isPkp) { - toast.error('SPPKP wajib di tambahkan'); - if (sppkpRef?.current) { - sppkpRef.current.scrollIntoView(options); - } - return; - } - if (!dokumenKtpDirut.name && !isPkp) { - toast.error('KTP Dirut/Direktur wajib di tambahkan'); - if (ktpDirutRef?.current) { - ktpDirutRef.current.scrollIntoView(options); - } - return; - } - if (!fotoKantor.name) { - toast.error('Foto Gudang / Kantor Bagian Depan wajib di tambahkan'); - if (fotoKantorRef?.current) { - fotoKantorRef.current.scrollIntoView(options); - } - return; - } - if (!pricelist.name) { - toast.error('Pricelist wajib di tambahkan'); - if (pricelistRef?.current) { - pricelistRef.current.scrollIntoView(options); - } - return; - } - const toastId = toast.loading('Mengirimkan formulir merchant...'); - const dokumen = { - file_npwp: { details: npwp.format ? npwp : '' }, - file_sppkp: { details: sppkp.format ? sppkp : '' }, - file_dokumenKtpDirut: { - details: dokumenKtpDirut.format ? dokumenKtpDirut : '', - }, - file_kartuNama: { details: kartuNama.format ? kartuNama : '' }, - file_suratPernyataan: { - details: suratPernyataan.format ? suratPernyataan : '', - }, - file_fotoKantor: { details: fotoKantor.format ? fotoKantor : '' }, - file_dataProduk: { details: dataProduk.format ? dataProduk : '' }, - file_pricelist: { details: pricelist.format ? pricelist : '' }, - }; - let data = { - file_dokumen: JSON.stringify(dokumen), - }; - const create_leads = await createMerchantApi({ data }); - if (create_leads) { - toast.dismiss(toastId); - toast.success('Berhasil menambahkan data'); - isError(false); - reset(); - } else { - toast.dismiss(toastId); - toast.error('Gagal menambahkan data'); - } - }; +// if (!npwp.name && isPkp) { +// if (npwpRef?.current) { +// npwpRef.current.scrollIntoView(options); +// } +// toast.error('NPWP wajib di tambahkan'); +// return; +// } +// if (!sppkp.name && isPkp) { +// toast.error('SPPKP wajib di tambahkan'); +// if (sppkpRef?.current) { +// sppkpRef.current.scrollIntoView(options); +// } +// return; +// } +// if (!dokumenKtpDirut.name && !isPkp) { +// toast.error('KTP Dirut/Direktur wajib di tambahkan'); +// if (ktpDirutRef?.current) { +// ktpDirutRef.current.scrollIntoView(options); +// } +// return; +// } +// if (!fotoKantor.name) { +// toast.error('Foto Gudang / Kantor Bagian Depan wajib di tambahkan'); +// if (fotoKantorRef?.current) { +// fotoKantorRef.current.scrollIntoView(options); +// } +// return; +// } +// if (!pricelist.name) { +// toast.error('Pricelist wajib di tambahkan'); +// if (pricelistRef?.current) { +// pricelistRef.current.scrollIntoView(options); +// } +// return; +// } +// const toastId = toast.loading('Mengirimkan formulir merchant...'); +// const dokumen = { +// file_npwp: { details: npwp.format ? npwp : '' }, +// file_sppkp: { details: sppkp.format ? sppkp : '' }, +// file_dokumenKtpDirut: { +// details: dokumenKtpDirut.format ? dokumenKtpDirut : '', +// }, +// file_kartuNama: { details: kartuNama.format ? kartuNama : '' }, +// file_suratPernyataan: { +// details: suratPernyataan.format ? suratPernyataan : '', +// }, +// file_fotoKantor: { details: fotoKantor.format ? fotoKantor : '' }, +// file_dataProduk: { details: dataProduk.format ? dataProduk : '' }, +// file_pricelist: { details: pricelist.format ? pricelist : '' }, +// }; +// let data = { +// file_dokumen: JSON.stringify(dokumen), +// }; +// const create_leads = await createMerchantApi({ data }); +// if (create_leads) { +// toast.dismiss(toastId); +// toast.success('Berhasil menambahkan data'); +// isError(false); +// reset(); +// } else { +// toast.dismiss(toastId); +// toast.error('Gagal menambahkan data'); +// } +// }; - if (!auth) { - return; - } +// if (!auth) { +// return; +// } - const handleFileChange = async (event) => { - let fileBase64 = ''; - const file = event.target.files[0]; +// const handleFileChange = async (event) => { +// let fileBase64 = ''; +// const file = event.target.files[0]; - if (file.size > 2000000) { - // try { - // const toastId = toast.loading('mencoba mengompresi file...'); - // // Compress image file - // const options = { - // maxSizeMB: 0.5, // Target size in MB - // maxWidthOrHeight: 1920, // Adjust as needed - // useWebWorker: true, - // }; - // const compressedFile = await imageCompression(file, options); - // toast.success('berhasil mengompresi file', { duration: 4000 }); - // // Convert compressed file to Base64 - // fileBase64 = await getFileBase64(compressedFile); - // } catch (error) { - // toast.error('Gagal mengompresi file', { duration: 4000 }); - // } - toast.error('Maks file size 2MB', { duration: 4000 }); - } else { - // Convert file to Base64 - fileBase64 = await getFileBase64(file); - } - const fieldName = event.target.name; // Nama input file - setDetailFile((prev) => ({ - ...prev, - [fieldName]: file ? fileBase64 : '', // Tambahkan atau perbarui file di state - })); - setFileNames((prev) => ({ - ...prev, - [fieldName]: file ? file.name : '', // Tambahkan atau perbarui file di state - })); - }; - return ( - <> - setIsExample(false)} - > -
- Contoh SPPKP -
-
- -
-

- Dokumen -

+// if (file.size > 2000000) { +// // try { +// // const toastId = toast.loading('mencoba mengompresi file...'); +// // // Compress image file +// // const options = { +// // maxSizeMB: 0.5, // Target size in MB +// // maxWidthOrHeight: 1920, // Adjust as needed +// // useWebWorker: true, +// // }; +// // const compressedFile = await imageCompression(file, options); +// // toast.success('berhasil mengompresi file', { duration: 4000 }); +// // // Convert compressed file to Base64 +// // fileBase64 = await getFileBase64(compressedFile); +// // } catch (error) { +// // toast.error('Gagal mengompresi file', { duration: 4000 }); +// // } +// toast.error('Maks file size 2MB', { duration: 4000 }); +// } else { +// // Convert file to Base64 +// fileBase64 = await getFileBase64(file); +// } +// const fieldName = event.target.name; // Nama input file +// setDetailFile((prev) => ({ +// ...prev, +// [fieldName]: file ? fileBase64 : '', // Tambahkan atau perbarui file di state +// })); +// setFileNames((prev) => ({ +// ...prev, +// [fieldName]: file ? file.name : '', // Tambahkan atau perbarui file di state +// })); +// }; +// return ( +// <> +// setIsExample(false)} +// > +//
+// Contoh SPPKP +//
+//
+// +//
+//

+// Dokumen +//

-
-
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
-
- {isKonfirmasi && ( - - {fileNames.npwp} - - )} - - { - handleFileChange(e); // Untuk update UI (opsional) - }} - aria-invalid={errors.npwp?.message} - /> - {!isKonfirmasi && ( - - {fileNames.npwp} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} +//
+// +//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.npwp} +// +// )} +// +// { +// handleFileChange(e); // Untuk update UI (opsional) +// }} +// aria-invalid={errors.npwp?.message} +// /> +// {!isKonfirmasi && ( +// +// {fileNames.npwp} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} -
- {errors.npwp?.message} -
-
-
-
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
setIsExample(!isExample)} - className={`h-fit ${ - !isKonfirmasi && 'mr-8' - } rounded text-white p-2 flex flex-row items-center bg-red-500 hover:cursor-pointer hover:bg-red-400`} - > - - {!isKonfirmasi && ( -

Lihat Contoh

- )} -
-
-
-
- {isKonfirmasi && ( - - {fileNames.sppkp} - - )} - - -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} +//
+// {errors.npwp?.message} +//
+//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
setIsExample(!isExample)} +// className={`h-fit ${ +// !isKonfirmasi && 'mr-8' +// } rounded text-white p-2 flex flex-row items-center bg-red-500 hover:cursor-pointer hover:bg-red-400`} +// > +// +// {!isKonfirmasi && ( +//

Lihat Contoh

+// )} +//
+//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.sppkp} +// +// )} +// +// +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} -
- {errors.sppkp?.message} -
-
-
+//
+// {errors.sppkp?.message} +//
+//
+//
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
-
- {isKonfirmasi && ( - - {fileNames.dokumenKtpDirut} - - )} - - - {!isKonfirmasi && ( - - {fileNames.dokumenKtpDirut} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} +//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.dokumenKtpDirut} +// +// )} +// +// +// {!isKonfirmasi && ( +// +// {fileNames.dokumenKtpDirut} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} -
- {errors.dokumenKtpDirut?.message} -
-
-
+//
+// {errors.dokumenKtpDirut?.message} +//
+//
+//
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
-
- {isKonfirmasi && ( - - {fileNames.kartuNama} - - )} - - - {!isKonfirmasi && ( - - {fileNames.kartuNama} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} +//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.kartuNama} +// +// )} +// +// +// {!isKonfirmasi && ( +// +// {fileNames.kartuNama} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} -
- {errors.kartuNama?.message} -
-
-
+//
+// {errors.kartuNama?.message} +//
+//
+//
-
-
-
- - {!isKonfirmasi && ( - - Wajib diisi jika nomor rekening berbeda dengan nama - perusahaan - - )} -
- -

Download Template

-
-
-
-
- {isKonfirmasi && ( - - {fileNames.suratPernyataan} - - )} - - - {!isKonfirmasi && ( - - {fileNames.suratPernyataan} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} +//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Wajib diisi jika nomor rekening berbeda dengan nama +// perusahaan +// +// )} +//
+// +//

Download Template

+//
+//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.suratPernyataan} +// +// )} +// +// +// {!isKonfirmasi && ( +// +// {fileNames.suratPernyataan} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} -
- {errors.suratPernyataan?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
-
- {isKonfirmasi && ( - - {fileNames.fotoKantor} - - )} - - - {!isKonfirmasi && ( - - {fileNames.fotoKantor} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} -
- {errors.fotoKantor?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
-
- {isKonfirmasi && ( - - {fileNames.dataProduk} - - )} - - - {!isKonfirmasi && ( - - {fileNames.dataProduk} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} +//
+// {errors.suratPernyataan?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.fotoKantor} +// +// )} +// +// +// {!isKonfirmasi && ( +// +// {fileNames.fotoKantor} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} +//
+// {errors.fotoKantor?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.dataProduk} +// +// )} +// +// +// {!isKonfirmasi && ( +// +// {fileNames.dataProduk} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} -
- {errors.dataProduk?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - Pastikan dokumen yang anda upload sudah benar - - )} -
-
-
- {isKonfirmasi && ( - - {fileNames.pricelist} - - )} - - - {!isKonfirmasi && ( - - {fileNames.pricelist} - - )} -
- {!isKonfirmasi && ( - - Format: pdf, jpeg, jpg, png. max file size 2MB - - )} -
- {errors.pricelist?.message} -
-
-
-
- {/*
- -
*/} -
-
- {/* */} - {!isKonfirmasi && ( -
- - *Pastikan data yang anda masukan sudah benar dan sesuai - - -
- )} -
- - -
-
- - -
- {!isKonfirmasi && ( -

Dokumen

- )} +//
+// {errors.dataProduk?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Pastikan dokumen yang anda upload sudah benar +// +// )} +//
+//
+//
+// {isKonfirmasi && ( +// +// {fileNames.pricelist} +// +// )} +// +// +// {!isKonfirmasi && ( +// +// {fileNames.pricelist} +// +// )} +//
+// {!isKonfirmasi && ( +// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// +// )} +//
+// {errors.pricelist?.message} +//
+//
+//
+//
+// {/*
+// +//
*/} +//
+//
+// {/* */} +// {!isKonfirmasi && ( +//
+// +// *Pastikan data yang anda masukan sudah benar dan sesuai +// +// +//
+// )} +//
+// +// +//
+//
+//
+// +//
+// {!isKonfirmasi && ( +//

Dokumen

+// )} -
-
-
- -
- - { - handleFileChange(e); // Untuk update UI (opsional) - }} - aria-invalid={errors.npwp?.message} - /> - - {fileNames.npwp} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+// +//
+// +//
+// +// { +// handleFileChange(e); // Untuk update UI (opsional) +// }} +// aria-invalid={errors.npwp?.message} +// /> +// +// {fileNames.npwp} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.npwp?.message} -
-
-
-
- -
setIsExample(!isExample)} - className='h-fit rounded text-white p-2 flex flex-row items-center bg-red-500 hover:cursor-pointer hover:bg-red-400' - > - +//
+// {errors.npwp?.message} +//
+//
+//
+//
+// +//
setIsExample(!isExample)} +// className='h-fit rounded text-white p-2 flex flex-row items-center bg-red-500 hover:cursor-pointer hover:bg-red-400' +// > +// -

Lihat Contoh

-
-
-
- - - - {fileNames.sppkp} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//

Lihat Contoh

+//
+//
+//
+// +// +// +// {fileNames.sppkp} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.sppkp?.message} -
-
+//
+// {errors.sppkp?.message} +//
+//
-
- -
- - - - {fileNames.dokumenKtpDirut} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+// +//
+// +// +// +// {fileNames.dokumenKtpDirut} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.dokumenKtpDirut?.message} -
-
+//
+// {errors.dokumenKtpDirut?.message} +//
+//
-
- -
- - - - {fileNames.kartuNama} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+// +//
+// +// +// +// {fileNames.kartuNama} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.kartuNama?.message} -
-
+//
+// {errors.kartuNama?.message} +//
+//
-
-
- - -

- Download Template -

-
-
-
- - - - {fileNames.suratPernyataan} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+//
+// +// +//

+// Download Template +//

+//
+//
+//
+// +// +// +// {fileNames.suratPernyataan} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.suratPernyataan?.message} -
-
-
- -
- - - - {fileNames.fotoKantor} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+// {errors.suratPernyataan?.message} +//
+//
+//
+// +//
+// +// +// +// {fileNames.fotoKantor} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.fotoKantor?.message} -
-
-
- -
- - - - {fileNames.dataProduk} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+// {errors.fotoKantor?.message} +//
+//
+//
+// +//
+// +// +// +// {fileNames.dataProduk} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.fotoKantor?.message} -
-
-
- -
- - - - {fileNames.pricelist} - -
- - Format: pdf, jpeg, jpg, png. max file size 2MB - +//
+// {errors.fotoKantor?.message} +//
+//
+//
+// +//
+// +// +// +// {fileNames.pricelist} +// +//
+// +// Format: pdf, jpeg, jpg, png. max file size 2MB +// -
- {errors.pricelist?.message} -
-
-
- {/*
- -
*/} -
-
- {/* */} - {!isKonfirmasi && ( -
- - *Pastikan data yang anda masukan sudah benar dan sesuai - - -
- )} -
- - -
-
- - - ); - } -); -const validationSchema = Yup.object().shape({ - npwp: Yup.mixed().required('File is required'), - pricelist: Yup.mixed().required('File is required'), -}); -const defaultValues = { - company: '', - pejabatName: '', - PICName: '', - PICPosition: '', - email: '', - emailSales: '', - emailFinance: '', - phone: '', - state: '', - city: '', - district: '', - subDistrict: '', - zip: '', - bank: '', - rekening: '', - accountNumber: '', - address: '', - mobile: '', -}; +//
+// {errors.pricelist?.message} +//
+//
+//
+// {/*
+// +//
*/} +//
+//
+// {/* */} +// {!isKonfirmasi && ( +//
+// +// *Pastikan data yang anda masukan sudah benar dan sesuai +// +// +//
+// )} +//
+// +// +//
+//
+// +// +// ); +// } +// ); +// const validationSchema = Yup.object().shape({ +// npwp: Yup.mixed().required('File is required'), +// pricelist: Yup.mixed().required('File is required'), +// }); +// const defaultValues = { +// company: '', +// pejabatName: '', +// PICName: '', +// PICPosition: '', +// email: '', +// emailSales: '', +// emailFinance: '', +// phone: '', +// state: '', +// city: '', +// district: '', +// subDistrict: '', +// zip: '', +// bank: '', +// rekening: '', +// accountNumber: '', +// address: '', +// mobile: '', +// }; -export default Dokumen; +// export default Dokumen; diff --git a/src/lib/merchant/components/InformasiPerusahaan.jsx b/src/lib/merchant/components/InformasiPerusahaan.jsx index ee5560a9..e9486214 100644 --- a/src/lib/merchant/components/InformasiPerusahaan.jsx +++ b/src/lib/merchant/components/InformasiPerusahaan.jsx @@ -1,1399 +1,1399 @@ -import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; -import cityApi from '@/lib/address/api/cityApi'; -import stateApi from '@/lib/address/api/stateApi.js'; -import districtApi from '@/lib/address/api/districtApi'; -import subDistrictApi from '@/lib/address/api/subDistrictApi'; -import { yupResolver } from '@hookform/resolvers/yup'; -import React, { - useEffect, - useRef, - useState, - forwardRef, - useImperativeHandle, -} from 'react'; -import ReCAPTCHA from 'react-google-recaptcha'; -import { Controller, useForm } from 'react-hook-form'; -import { toast } from 'react-hot-toast'; -import * as Yup from 'yup'; -import createMerchantApi from '../api/createMerchantApi'; -import getMerchantApi from '../api/getMerchantApi'; -import addressApi from '@/lib/address/api/addressApi'; -import PageContent from '@/lib/content/components/PageContent'; -import { useRouter } from 'next/router'; -import useAuth from '@/core/hooks/useAuth'; -import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react'; -import { EyeIcon } from '@heroicons/react/24/outline'; -import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; -import Image from 'next/image'; -import ImageBanner from '~/components/ui/image'; -import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; -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'; +// import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; +// import cityApi from '@/lib/address/api/cityApi'; +// import stateApi from '@/lib/address/api/stateApi.js'; +// import districtApi from '@/lib/address/api/districtApi'; +// import subDistrictApi from '@/lib/address/api/subDistrictApi'; +// import { yupResolver } from '@hookform/resolvers/yup'; +// import React, { +// useEffect, +// useRef, +// useState, +// forwardRef, +// useImperativeHandle, +// } from 'react'; +// import ReCAPTCHA from 'react-google-recaptcha'; +// import { Controller, useForm } from 'react-hook-form'; +// import { toast } from 'react-hot-toast'; +// import * as Yup from 'yup'; +// import createMerchantApi from '../api/createMerchantApi'; +// import getMerchantApi from '../api/getMerchantApi'; +// import addressApi from '@/lib/address/api/addressApi'; +// import PageContent from '@/lib/content/components/PageContent'; +// import { useRouter } from 'next/router'; +// import useAuth from '@/core/hooks/useAuth'; +// import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react'; +// import { EyeIcon } from '@heroicons/react/24/outline'; +// import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +// import Image from 'next/image'; +// import ImageBanner from '~/components/ui/image'; +// import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; +// 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 CreateMerchant = forwardRef( - ({ handleIsError, isKonfirmasi, buttonSubmitClick }, ref) => { - const isError = (value) => { - // Logika menentukan error - const result = value ? true : false; - handleIsError(result); // Panggil handleIsError dari Merchant - return result; - }; - // React.useEffect(() => { - // handleIsError(isError()); - // }, [handleIsError]); - const { - register, - handleSubmit, - formState: { errors }, - control, - reset, - watch, - setValue, - getValues, - } = useForm({ - resolver: yupResolver(validationSchema), - defaultValues, - }); - const [state, setState] = useState([]); - const [cities, setCities] = useState([]); - const [districts, setDistricts] = useState([]); - const [subDistricts, setSubDistricts] = useState([]); - const [zips, setZips] = useState([]); - const [isExample, setIsExample] = useState(false); - const [isPkp, setIsPkp] = useState(false); +// const CreateMerchant = forwardRef( +// ({ handleIsError, isKonfirmasi, buttonSubmitClick }, ref) => { +// const isError = (value) => { +// // Logika menentukan error +// const result = value ? true : false; +// handleIsError(result); // Panggil handleIsError dari Merchant +// return result; +// }; +// // React.useEffect(() => { +// // handleIsError(isError()); +// // }, [handleIsError]); +// const { +// register, +// handleSubmit, +// formState: { errors }, +// control, +// reset, +// watch, +// setValue, +// getValues, +// } = useForm({ +// resolver: yupResolver(validationSchema), +// defaultValues, +// }); +// const [state, setState] = useState([]); +// const [cities, setCities] = useState([]); +// const [districts, setDistricts] = useState([]); +// const [subDistricts, setSubDistricts] = useState([]); +// const [zips, setZips] = useState([]); +// const [isExample, setIsExample] = useState(false); +// const [isPkp, setIsPkp] = useState(false); - useEffect(() => { - window.scrollTo({ - top: 0, - behavior: 'smooth', - }); - }, []); +// useEffect(() => { +// window.scrollTo({ +// top: 0, +// behavior: 'smooth', +// }); +// }, []); - useImperativeHandle(ref, () => () => { - handleSubmit(onSubmitHandler)(); - }); +// useImperativeHandle(ref, () => () => { +// handleSubmit(onSubmitHandler)(); +// }); - const recaptchaRef = useRef(null); - const router = useRouter(); +// const recaptchaRef = useRef(null); +// const router = useRouter(); - const auth = useAuth(); - if (auth == false) { - router.push(`/login?next=${encodeURIComponent('/daftar-merchant')}`); - } - const dataBisnisType = [ - { value: 1, label: 'PT' }, - { value: 2, label: 'CV' }, - { value: 3, label: 'Perorangan' }, - ]; - const dataCategoryPerusahaan = [ - { value: 1, label: 'Principal (Pemegang merk/Produsen)' }, - { value: 2, label: 'Sole Distributor (Distributor Tunggal)' }, - { value: 3, label: 'Authorized Distributor (Distributor Resmi)' }, - { value: 4, label: 'Importer (Pengimpor Barang)' }, - { value: 5, label: 'Wholesaler (Pedagang Besar)' }, - ]; +// const auth = useAuth(); +// if (auth == false) { +// router.push(`/login?next=${encodeURIComponent('/daftar-merchant')}`); +// } +// const dataBisnisType = [ +// { value: 1, label: 'PT' }, +// { value: 2, label: 'CV' }, +// { value: 3, label: 'Perorangan' }, +// ]; +// const dataCategoryPerusahaan = [ +// { value: 1, label: 'Principal (Pemegang merk/Produsen)' }, +// { value: 2, label: 'Sole Distributor (Distributor Tunggal)' }, +// { value: 3, label: 'Authorized Distributor (Distributor Resmi)' }, +// { value: 4, label: 'Importer (Pengimpor Barang)' }, +// { value: 5, label: 'Wholesaler (Pedagang Besar)' }, +// ]; - useEffect(() => { - const loadData = async () => { - try { - const data = await getMerchantApi(); - if (data) { - reset({ - pejabatName: data.pejabatName ? data.pejabatName : '', - PICName: data.picMerchant || '', - PICPosition: data.picPosition || '', - address: data.address ? data.address : '', - state: data.state ? data.state : '', - city: data.city || '', - district: data.district || '', - subDistrict: data.subDistrict || '', - zip: parseInt(data.zip) || '', - email: data.emailCompany || '', - emailSales: data.emailSales || '', - emailFinance: data.emailFinance || '', - bank: data.bankName || '', - rekening: data.rekeningName || '', - accountNumber: data.accountNumber || '', - phone: data.phone || '', - mobile: data.mobile || '', - bisnisType: data.bisnisType ? parseInt(data.bisnisType) : null, - categoryPerusahaan: data.categoryPerusahaan - ? parseInt(data.categoryPerusahaan) - : null, - website: data.website || '', - }); - } - } catch (error) { - console.error('Error loading profile:', error); - handleIsError(true); // Jika ada error, panggil fungsi error handler - } - }; +// useEffect(() => { +// const loadData = async () => { +// try { +// const data = await getMerchantApi(); +// if (data) { +// reset({ +// pejabatName: data.pejabatName ? data.pejabatName : '', +// PICName: data.picMerchant || '', +// PICPosition: data.picPosition || '', +// address: data.address ? data.address : '', +// state: data.state ? data.state : '', +// city: data.city || '', +// district: data.district || '', +// subDistrict: data.subDistrict || '', +// zip: parseInt(data.zip) || '', +// email: data.emailCompany || '', +// emailSales: data.emailSales || '', +// emailFinance: data.emailFinance || '', +// bank: data.bankName || '', +// rekening: data.rekeningName || '', +// accountNumber: data.accountNumber || '', +// phone: data.phone || '', +// mobile: data.mobile || '', +// bisnisType: data.bisnisType ? parseInt(data.bisnisType) : null, +// categoryPerusahaan: data.categoryPerusahaan +// ? parseInt(data.categoryPerusahaan) +// : null, +// website: data.website || '', +// }); +// } +// } catch (error) { +// console.error('Error loading profile:', error); +// handleIsError(true); // Jika ada error, panggil fungsi error handler +// } +// }; - loadData(); - }, [reset, handleIsError]); +// loadData(); +// }, [reset, handleIsError]); - useEffect(() => { - const loadProfile = async () => { - try { - const dataProfile = await addressApi({ - id: auth.parentId ? auth.parentId : auth.partnerId, - }); - if (dataProfile.companyType == 'pkp') { - setIsPkp(true); - } - setValue('company', dataProfile?.name); - setValue('address', dataProfile?.alamatBisnis); - setValue('state', parseInt(dataProfile.stateId.id)); - setValue('city', parseInt(dataProfile.city.id)); - setValue('district', parseInt(dataProfile.district.id)); - setValue('subDistrict', parseInt(dataProfile.subDistrict.id)); - setValue('zip', parseInt(dataProfile.zip)); - } catch (error) { - console.error('Error loading profile:', error); - } - }; +// useEffect(() => { +// const loadProfile = async () => { +// try { +// const dataProfile = await addressApi({ +// id: auth.parentId ? auth.parentId : auth.partnerId, +// }); +// if (dataProfile.companyType == 'pkp') { +// setIsPkp(true); +// } +// setValue('company', dataProfile?.name); +// setValue('address', dataProfile?.alamatBisnis); +// setValue('state', parseInt(dataProfile.stateId.id)); +// setValue('city', parseInt(dataProfile.city.id)); +// setValue('district', parseInt(dataProfile.district.id)); +// setValue('subDistrict', parseInt(dataProfile.subDistrict.id)); +// setValue('zip', parseInt(dataProfile.zip)); +// } catch (error) { +// console.error('Error loading profile:', error); +// } +// }; - loadProfile(); - }, [auth?.parentId]); +// loadProfile(); +// }, [auth?.parentId]); - useEffect(() => { - const loadState = async () => { - let dataState = await stateApi({ tempo: false }); - dataState = dataState.map((state) => ({ - value: state.id, - label: state.name, - })); - setState(dataState); - }; - loadState(); - }, []); +// useEffect(() => { +// const loadState = async () => { +// let dataState = await stateApi({ tempo: false }); +// dataState = dataState.map((state) => ({ +// value: state.id, +// label: state.name, +// })); +// setState(dataState); +// }; +// loadState(); +// }, []); - const watchState = watch('state'); - useEffect(() => { - if (auth == false) { - return; - } - if (watchState) { - // setValue('city', ''); - const loadCities = async () => { - let dataCities = await cityApi({ stateId: watchState }); - dataCities = dataCities?.map((city) => ({ - value: city.id, - label: city.name, - })); - setCities(dataCities); - }; - loadCities(); - } - }, [auth, watchState]); +// const watchState = watch('state'); +// useEffect(() => { +// if (auth == false) { +// return; +// } +// if (watchState) { +// // setValue('city', ''); +// const loadCities = async () => { +// let dataCities = await cityApi({ stateId: watchState }); +// dataCities = dataCities?.map((city) => ({ +// value: city.id, +// label: city.name, +// })); +// setCities(dataCities); +// }; +// loadCities(); +// } +// }, [auth, watchState]); - const watchCity = watch('city'); - useEffect(() => { - if (watchCity) { - // setValue('district', ''); - const loadDistricts = async () => { - let dataDistricts = await districtApi({ cityId: watchCity }); - dataDistricts = dataDistricts.map((district) => ({ - value: district.id, - label: district.name, - })); - setDistricts(dataDistricts); - }; - loadDistricts(); - } - }, [watchCity]); +// const watchCity = watch('city'); +// useEffect(() => { +// if (watchCity) { +// // setValue('district', ''); +// const loadDistricts = async () => { +// let dataDistricts = await districtApi({ cityId: watchCity }); +// dataDistricts = dataDistricts.map((district) => ({ +// value: district.id, +// label: district.name, +// })); +// setDistricts(dataDistricts); +// }; +// loadDistricts(); +// } +// }, [watchCity]); - const watchDistrict = watch('district'); - useEffect(() => { - if (watchDistrict) { - // setValue('subDistrict', ''); - const loadSubDistricts = async () => { - let dataSubDistricts = await subDistrictApi({ - districtId: watchDistrict, - }); - dataSubDistricts = dataSubDistricts.map((district) => ({ - value: district.id, - label: district.name, - })); - setSubDistricts(dataSubDistricts); - }; - loadSubDistricts(); - } - }, [watchDistrict]); +// const watchDistrict = watch('district'); +// useEffect(() => { +// if (watchDistrict) { +// // setValue('subDistrict', ''); +// const loadSubDistricts = async () => { +// let dataSubDistricts = await subDistrictApi({ +// districtId: watchDistrict, +// }); +// dataSubDistricts = dataSubDistricts.map((district) => ({ +// value: district.id, +// label: district.name, +// })); +// setSubDistricts(dataSubDistricts); +// }; +// loadSubDistricts(); +// } +// }, [watchDistrict]); - const watchsubDistrict = watch('subDistrict'); +// const watchsubDistrict = watch('subDistrict'); - useEffect(() => { - let kelurahan = ''; - let kecamatan = ''; +// useEffect(() => { +// let kelurahan = ''; +// let kecamatan = ''; - if (watchDistrict) { - // setValue('zip', ''); - for (const data in districts) { - if (districts[data].value == watchDistrict) { - kecamatan = districts[data].label.toLowerCase(); - } - } - } +// if (watchDistrict) { +// // setValue('zip', ''); +// for (const data in districts) { +// if (districts[data].value == watchDistrict) { +// kecamatan = districts[data].label.toLowerCase(); +// } +// } +// } - if (watchsubDistrict) { - for (const data in subDistricts) { - if (subDistricts[data].value == watchsubDistrict) { - kelurahan = subDistricts[data].label.toLowerCase(); - } - } - const loadZip = async () => { - const response = await fetch( - `https://alamat.thecloudalert.com/api/cari/index/?keyword=${kelurahan}` - ); +// if (watchsubDistrict) { +// for (const data in subDistricts) { +// if (subDistricts[data].value == watchsubDistrict) { +// kelurahan = subDistricts[data].label.toLowerCase(); +// } +// } +// const loadZip = async () => { +// const response = await fetch( +// `https://alamat.thecloudalert.com/api/cari/index/?keyword=${kelurahan}` +// ); - let dataMasuk = []; // Array untuk menyimpan kode pos yang sudah diproses +// let dataMasuk = []; // Array untuk menyimpan kode pos yang sudah diproses - const result = await response.json(); +// const result = await response.json(); - // Filter dan map data - const dataZips = result.result - .filter((zip) => zip.kecamatan.toLowerCase() === kecamatan) // Filter berdasarkan kecamatan - .filter((zip) => { - // Pastikan zip.kodepos belum ada di dataMasuk - if (dataMasuk.includes(zip.kodepos)) { - return false; // Jika sudah ada, maka skip (tidak akan ditambahkan) - } else { - dataMasuk.push(zip.kodepos); // Tambahkan ke dataMasuk - return true; // Tambahkan zip ke hasil - } - }) - .map((zip) => ({ - value: parseInt(zip.kodepos), - label: zip.kodepos, - })); +// // Filter dan map data +// const dataZips = result.result +// .filter((zip) => zip.kecamatan.toLowerCase() === kecamatan) // Filter berdasarkan kecamatan +// .filter((zip) => { +// // Pastikan zip.kodepos belum ada di dataMasuk +// if (dataMasuk.includes(zip.kodepos)) { +// return false; // Jika sudah ada, maka skip (tidak akan ditambahkan) +// } else { +// dataMasuk.push(zip.kodepos); // Tambahkan ke dataMasuk +// return true; // Tambahkan zip ke hasil +// } +// }) +// .map((zip) => ({ +// value: parseInt(zip.kodepos), +// label: zip.kodepos, +// })); - setZips(dataZips); // Set hasil ke state - }; +// setZips(dataZips); // Set hasil ke state +// }; - loadZip(); - } - }, [watchsubDistrict, subDistricts]); - const onSubmitHandler = async (values) => { - const toastId = toast.loading('Mengirimkan formulir merchant...'); - const data = { - name_merchant: 'Form Merchant - ' + values.company, - pejabat_name: values.pejabatName, - pic_merchant: values.PICName, - pic_position: values.PICPosition, - address: values.address, - state: parseInt(values.state), - city: parseInt(values.city), - district: parseInt(values.district), - subDistrict: parseInt(values.subDistrict), - zip: values.zip, - bank_name: values.bank, - rekening_name: values.rekening, - account_number: values.accountNumber, - email_company: values.email, - email_sales: values.emailSales, - email_finance: values.emailFinance, - phone: values.phone, - mobile: values.mobile, - bisnis_type: values.bisnisType, - category_perusahaan: values.categoryPerusahaan, - website: values.website, - description: - 'Nama Perusahaan : ' + - values.company + - ' \r\n Alamat : ' + - values.address + - ' \r\n Kota : ' + - values.city + - ' \r\n Telepon: ' + - values.phone + - ' \r\n Email : ' + - values.email + - ' \r\n No Hp : ' + - values.mobile, - }; - const create_leads = await createMerchantApi({ data }); - if (create_leads) { - toast.dismiss(toastId); - toast.success('Berhasil menambahkan data'); - isError(false); - reset(); - // router.push('/'); - } else { - toast.dismiss(toastId); - toast.error('Gagal menambahkan data'); - } - }; +// loadZip(); +// } +// }, [watchsubDistrict, subDistricts]); +// const onSubmitHandler = async (values) => { +// const toastId = toast.loading('Mengirimkan formulir merchant...'); +// const data = { +// name_merchant: 'Form Merchant - ' + values.company, +// pejabat_name: values.pejabatName, +// pic_merchant: values.PICName, +// pic_position: values.PICPosition, +// address: values.address, +// state: parseInt(values.state), +// city: parseInt(values.city), +// district: parseInt(values.district), +// subDistrict: parseInt(values.subDistrict), +// zip: values.zip, +// bank_name: values.bank, +// rekening_name: values.rekening, +// account_number: values.accountNumber, +// email_company: values.email, +// email_sales: values.emailSales, +// email_finance: values.emailFinance, +// phone: values.phone, +// mobile: values.mobile, +// bisnis_type: values.bisnisType, +// category_perusahaan: values.categoryPerusahaan, +// website: values.website, +// description: +// 'Nama Perusahaan : ' + +// values.company + +// ' \r\n Alamat : ' + +// values.address + +// ' \r\n Kota : ' + +// values.city + +// ' \r\n Telepon: ' + +// values.phone + +// ' \r\n Email : ' + +// values.email + +// ' \r\n No Hp : ' + +// values.mobile, +// }; +// const create_leads = await createMerchantApi({ data }); +// if (create_leads) { +// toast.dismiss(toastId); +// toast.success('Berhasil menambahkan data'); +// isError(false); +// reset(); +// // router.push('/'); +// } else { +// toast.dismiss(toastId); +// toast.error('Gagal menambahkan data'); +// } +// }; - // const DownLoadSurat = () => { - // download surat dari /public/file/Surat Pernyataan Nomor Rekening.docx - // }; +// // const DownLoadSurat = () => { +// // download surat dari /public/file/Surat Pernyataan Nomor Rekening.docx +// // }; - if (!auth) { - return; - } - // Tetap di bagian atas, tidak boleh ada kondisi sebelum hook +// if (!auth) { +// return; +// } +// // Tetap di bagian atas, tidak boleh ada kondisi sebelum hook - return ( - <> - setIsExample(false)} - > -
- Contoh SPPKP -
-
- -
-

- Informasi Perusahaan -

+// return ( +// <> +// setIsExample(false)} +// > +//
+// Contoh SPPKP +//
+//
+// +//
+//

+// Informasi Perusahaan +//

-
-
-
-
- - {!isKonfirmasi && ( - - Isi detail perusahaan sesuai dengan nama yang terdaftar{' '} - - )} -
-
- - - Format: PT. INDOTEKNIK DOTCOM GEMILANG - -
- {errors.company?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - isi dengan nama pejabat yang berwewenang di perusahaan - anda - - )} -
-
- -
- {errors.pejabatName?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - isi dengan nama sales / penanggung jawab - - )} -
-
- -
- {errors.PICName?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - isi dengan jabatan sales / penanggung jawab - - )} -
-
- -
- {errors.PICPosition?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - Alamat sesuai dengan alamat perusahaan - - )} -
-
-
- -
- {errors.address?.message} -
-
-
-
-
- ( - - )} - /> -
- {errors.state?.message} -
-
-
- ( - - )} - /> -
- {errors.city?.message} -
-
-
-
-
- ( - - )} - /> -
- {errors.district?.message} -
-
-
- ( - - )} - /> -
- {errors.subDistrict?.message} -
-
-
- ( - <> - {/* Jika zips tidak kosong, tampilkan dropdown */} - {zips.length < 0 ? ( - // Jika zips kosong, tampilkan input manual - - ) : ( - - )} - - )} - /> -
- {errors.zip?.message} -
-
-
-
-
-
-
-
- - {!isKonfirmasi && ( - - Isi detail data bank perusahaan anda - - )} -
-
-
- - {!isKonfirmasi && ( - - Format: BCA, Mandiri, CIMB, BNI dll - - )} -
- {errors.bank?.message} -
-
-
- - {!isKonfirmasi && ( - - Format: John Doe - - )} -
- {errors.rekening?.message} -
-
-
- - {!isKonfirmasi && ( - - Format: 01234567896 - - )} -
- {errors.accountNumber?.message} -
-
-
-
-
-
- -
-
- -
- {errors.email?.message} -
-
-
-
-
- -
-
- -
- {errors.emailSales?.message} -
-
-
-
-
- -
-
- -
- {errors.emailFinance?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - Isi no telepon perusahaan yang sesuai - - )} -
-
- -
- {errors.phone?.message} -
-
-
-
-
- - {!isKonfirmasi && ( - - Isi no handphone perusahaan yang sesuai - - )} -
-
- -
- {errors.mobile?.message} -
-
-
+//
+// +//
+//
+// +// {!isKonfirmasi && ( +// +// Isi detail perusahaan sesuai dengan nama yang terdaftar{' '} +// +// )} +//
+//
+// +// +// Format: PT. INDOTEKNIK DOTCOM GEMILANG +// +//
+// {errors.company?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// isi dengan nama pejabat yang berwewenang di perusahaan +// anda +// +// )} +//
+//
+// +//
+// {errors.pejabatName?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// isi dengan nama sales / penanggung jawab +// +// )} +//
+//
+// +//
+// {errors.PICName?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// isi dengan jabatan sales / penanggung jawab +// +// )} +//
+//
+// +//
+// {errors.PICPosition?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Alamat sesuai dengan alamat perusahaan +// +// )} +//
+//
+//
+// +//
+// {errors.address?.message} +//
+//
+//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.state?.message} +//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.city?.message} +//
+//
+//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.district?.message} +//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.subDistrict?.message} +//
+//
+//
+// ( +// <> +// {/* Jika zips tidak kosong, tampilkan dropdown */} +// {zips.length < 0 ? ( +// // Jika zips kosong, tampilkan input manual +// +// ) : ( +// +// )} +// +// )} +// /> +//
+// {errors.zip?.message} +//
+//
+//
+//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Isi detail data bank perusahaan anda +// +// )} +//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Format: BCA, Mandiri, CIMB, BNI dll +// +// )} +//
+// {errors.bank?.message} +//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Format: John Doe +// +// )} +//
+// {errors.rekening?.message} +//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Format: 01234567896 +// +// )} +//
+// {errors.accountNumber?.message} +//
+//
+//
+//
+//
+//
+// +//
+//
+// +//
+// {errors.email?.message} +//
+//
+//
+//
+//
+// +//
+//
+// +//
+// {errors.emailSales?.message} +//
+//
+//
+//
+//
+// +//
+//
+// +//
+// {errors.emailFinance?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Isi no telepon perusahaan yang sesuai +// +// )} +//
+//
+// +//
+// {errors.phone?.message} +//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Isi no handphone perusahaan yang sesuai +// +// )} +//
+//
+// +//
+// {errors.mobile?.message} +//
+//
+//
-
-
- - {!isKonfirmasi && ( - - Pilih tipe bisnis yang sesuai - - )} -
-
-
-
- ( - - )} - /> +//
+//
+// +// {!isKonfirmasi && ( +// +// Pilih tipe bisnis yang sesuai +// +// )} +//
+//
+//
+//
+// ( +// +// )} +// /> -
- {errors.bisnisType?.message} -
-
-
-
-
-
-
- - {!isKonfirmasi && ( - - Pilih kategori perusahaan yang sesuai - - )} -
-
-
-
- ( - - )} - /> +//
+// {errors.bisnisType?.message} +//
+//
+//
+//
+//
+//
+//
+// +// {!isKonfirmasi && ( +// +// Pilih kategori perusahaan yang sesuai +// +// )} +//
+//
+//
+//
+// ( +// +// )} +// /> -
- {errors.categoryPerusahaan?.message} -
-
-
-
-
+//
+// {errors.categoryPerusahaan?.message} +//
+//
+//
+//
+//
-
-
- - {!isKonfirmasi && ( - - isi dengan website perusahaan anda - - )} -
-
- -
- {errors.website?.message} -
-
-
+//
+//
+// +// {!isKonfirmasi && ( +// +// isi dengan website perusahaan anda +// +// )} +//
+//
+// +//
+// {errors.website?.message} +//
+//
+//
-
- {/*
- -
*/} -
-
- {/* */} - {!isKonfirmasi && ( -
- - *Pastikan data yang anda masukan sudah benar dan sesuai - - -
- )} -
- - -
-
- - -
- {!isKonfirmasi && ( -

- Informasi Perusahaan -

- )} +//
+// {/*
+// +//
*/} +//
+//
+// {/* */} +// {!isKonfirmasi && ( +//
+// +// *Pastikan data yang anda masukan sudah benar dan sesuai +// +// +//
+// )} +//
+// +// +//
+//
+//
+// +//
+// {!isKonfirmasi && ( +//

+// Informasi Perusahaan +//

+// )} -
-
-
-
- - -
- {errors.company?.message} -
- - Isi detail perusahaan sesuai dengan nama yang terdaftar{' '} - -
-
-
-
- - -
- {errors.pejabatName?.message} -
- - isi dengan nama pejabat yang berwewenang di perusahaan - anda{' '} - -
-
-
-
- - -
- {errors.PICName?.message} -
- - Isi dengan nama sales / penanggung jawab - -
-
-
-
- - -
- {errors.PICPosition?.message} -
- - isi dengan jabatan sales / penanggung jawab - -
-
-
-
- - -
- {errors.address?.message} -
-
-
- ( - - )} - /> -
- {errors.state?.message} -
-
-
- ( - - )} - /> -
- {errors.city?.message} -
-
-
-
-
- ( - - )} - /> -
- {errors.district?.message} -
-
-
- ( - - )} - /> -
- {errors.subDistrict?.message} -
-
-
- ( - <> - {zips.length > 0 ? ( - - ) : ( - - )} - - )} - /> -
- {errors.zip?.message} -
-
-
-
- - Alamat sesuai dengan alamat perusahaan - -
-
- -
-
- -
- {errors.bank?.message} -
-
-
- -
- {errors.rekening?.message} -
-
-
- -
- {errors.accountNumber?.message} -
-
-
- - Isi detail data bank perusahaan anda - -
-
- - -
- {errors.email?.message} -
- - Isi detail perusahaan sesuai dengan data yang terdaftar - -
-
- - -
- {errors.emailSales?.message} -
- - Isi detail perusahaan sesuai dengan data yang terdaftar - -
-
- - -
- {errors.emailFinance?.message} -
- - Isi detail perusahaan sesuai dengan data yang terdaftar - -
-
- - -
- {errors.phone?.message} -
- - Isi detail perusahaan sesuai dengan data yang terdaftar - -
-
- - -
- {errors.mobile?.message} -
- - Isi detail perusahaan sesuai dengan data yang terdaftar - -
-
- -
- ( - - )} - /> - {!isKonfirmasi && ( - - Pilih tipe bisnis yang sesuai - - )} -
- {errors.bisnisType?.message} -
-
-
-
- -
- ( - - )} - /> - {!isKonfirmasi && ( - - Pilih kategori perusahaan yang sesuai - - )} -
- {errors.categoryPerusahaan?.message} -
-
-
-
- - - {!isKonfirmasi && ( - - isi dengan website perusahaan anda - - )} -
- {errors.website?.message} -
-
+//
+// +//
+//
+// +// +//
+// {errors.company?.message} +//
+// +// Isi detail perusahaan sesuai dengan nama yang terdaftar{' '} +// +//
+//
+//
+//
+// +// +//
+// {errors.pejabatName?.message} +//
+// +// isi dengan nama pejabat yang berwewenang di perusahaan +// anda{' '} +// +//
+//
+//
+//
+// +// +//
+// {errors.PICName?.message} +//
+// +// Isi dengan nama sales / penanggung jawab +// +//
+//
+//
+//
+// +// +//
+// {errors.PICPosition?.message} +//
+// +// isi dengan jabatan sales / penanggung jawab +// +//
+//
+//
+//
+// +// +//
+// {errors.address?.message} +//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.state?.message} +//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.city?.message} +//
+//
+//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.district?.message} +//
+//
+//
+// ( +// +// )} +// /> +//
+// {errors.subDistrict?.message} +//
+//
+//
+// ( +// <> +// {zips.length > 0 ? ( +// +// ) : ( +// +// )} +// +// )} +// /> +//
+// {errors.zip?.message} +//
+//
+//
+//
+// +// Alamat sesuai dengan alamat perusahaan +// +//
+//
+// +//
+//
+// +//
+// {errors.bank?.message} +//
+//
+//
+// +//
+// {errors.rekening?.message} +//
+//
+//
+// +//
+// {errors.accountNumber?.message} +//
+//
+//
+// +// Isi detail data bank perusahaan anda +// +//
+//
+// +// +//
+// {errors.email?.message} +//
+// +// Isi detail perusahaan sesuai dengan data yang terdaftar +// +//
+//
+// +// +//
+// {errors.emailSales?.message} +//
+// +// Isi detail perusahaan sesuai dengan data yang terdaftar +// +//
+//
+// +// +//
+// {errors.emailFinance?.message} +//
+// +// Isi detail perusahaan sesuai dengan data yang terdaftar +// +//
+//
+// +// +//
+// {errors.phone?.message} +//
+// +// Isi detail perusahaan sesuai dengan data yang terdaftar +// +//
+//
+// +// +//
+// {errors.mobile?.message} +//
+// +// Isi detail perusahaan sesuai dengan data yang terdaftar +// +//
+//
+// +//
+// ( +// +// )} +// /> +// {!isKonfirmasi && ( +// +// Pilih tipe bisnis yang sesuai +// +// )} +//
+// {errors.bisnisType?.message} +//
+//
+//
+//
+// +//
+// ( +// +// )} +// /> +// {!isKonfirmasi && ( +// +// Pilih kategori perusahaan yang sesuai +// +// )} +//
+// {errors.categoryPerusahaan?.message} +//
+//
+//
+//
+// +// +// {!isKonfirmasi && ( +// +// isi dengan website perusahaan anda +// +// )} +//
+// {errors.website?.message} +//
+//
-
- {/*
- -
*/} -
-
- {/* */} - {!isKonfirmasi && ( -
- - *Pastikan data yang anda masukan sudah benar dan sesuai - - -
- )} -
- - -
-
- - - ); - } -); +//
+// {/*
+// +//
*/} +//
+//
+// {/* */} +// {!isKonfirmasi && ( +//
+// +// *Pastikan data yang anda masukan sudah benar dan sesuai +// +// +//
+// )} +//
+// +// +//
+//
+// +// +// ); +// } +// ); -const validationSchema = Yup.object().shape({ - company: Yup.string().required('Harus di-isi'), - pejabatName: Yup.string().required('Harus di-isi'), - PICName: Yup.string().required('Harus di-isi'), - PICPosition: Yup.string().required('Harus di-isi'), - address: Yup.string().required('Harus di-isi'), - state: Yup.string().required('Harus dipilih'), - city: Yup.string().required('Harus dipilih'), - district: Yup.string().required('Harus dipilih'), - subDistrict: Yup.string().required('Harus dipilih'), - zip: Yup.string().required('Harus di-isi'), - bank: Yup.string().required('Harus di-isi'), - rekening: Yup.string().required('Harus di-isi'), - accountNumber: Yup.string().required('Harus di-isi'), - email: Yup.string() - .email('Format harus seperti contoh@email.com') - .required('Harus di-isi'), - emailSales: Yup.string() - .email('Format harus seperti contoh@email.com') - .required('Harus di-isi'), - emailFinance: Yup.string() - .email('Format harus seperti contoh@email.com') - .required('Harus di-isi'), - phone: Yup.string().required('Harus di-isi'), - mobile: Yup.string().required('Harus di-isi'), - bisnisType: Yup.string().required('Harus dipilih'), - categoryPerusahaan: Yup.string().required('Harus dipilih'), -}); -const defaultValues = { - company: '', - pejabatName: '', - PICName: '', - PICPosition: '', - address: '', - state: '', - city: '', - district: '', - subDistrict: '', - zip: '', - email: '', - emailSales: '', - emailFinance: '', - bank: '', - rekening: '', - accountNumber: '', - phone: '', - mobile: '', -}; +// const validationSchema = Yup.object().shape({ +// company: Yup.string().required('Harus di-isi'), +// pejabatName: Yup.string().required('Harus di-isi'), +// PICName: Yup.string().required('Harus di-isi'), +// PICPosition: Yup.string().required('Harus di-isi'), +// address: Yup.string().required('Harus di-isi'), +// state: Yup.string().required('Harus dipilih'), +// city: Yup.string().required('Harus dipilih'), +// district: Yup.string().required('Harus dipilih'), +// subDistrict: Yup.string().required('Harus dipilih'), +// zip: Yup.string().required('Harus di-isi'), +// bank: Yup.string().required('Harus di-isi'), +// rekening: Yup.string().required('Harus di-isi'), +// accountNumber: Yup.string().required('Harus di-isi'), +// email: Yup.string() +// .email('Format harus seperti contoh@email.com') +// .required('Harus di-isi'), +// emailSales: Yup.string() +// .email('Format harus seperti contoh@email.com') +// .required('Harus di-isi'), +// emailFinance: Yup.string() +// .email('Format harus seperti contoh@email.com') +// .required('Harus di-isi'), +// phone: Yup.string().required('Harus di-isi'), +// mobile: Yup.string().required('Harus di-isi'), +// bisnisType: Yup.string().required('Harus dipilih'), +// categoryPerusahaan: Yup.string().required('Harus dipilih'), +// }); +// const defaultValues = { +// company: '', +// pejabatName: '', +// PICName: '', +// PICPosition: '', +// address: '', +// state: '', +// city: '', +// district: '', +// subDistrict: '', +// zip: '', +// email: '', +// emailSales: '', +// emailFinance: '', +// bank: '', +// rekening: '', +// accountNumber: '', +// phone: '', +// mobile: '', +// }; -export default CreateMerchant; +// export default CreateMerchant; diff --git a/src/lib/merchant/components/InformasiVendor.jsx b/src/lib/merchant/components/InformasiVendor.jsx index d00f27ed..90763029 100644 --- a/src/lib/merchant/components/InformasiVendor.jsx +++ b/src/lib/merchant/components/InformasiVendor.jsx @@ -1,748 +1,748 @@ -import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; -import cityApi from '@/lib/address/api/cityApi'; -import stateApi from '@/lib/address/api/stateApi.js'; -import districtApi from '@/lib/address/api/districtApi'; -import subDistrictApi from '@/lib/address/api/subDistrictApi'; -import { yupResolver } from '@hookform/resolvers/yup'; -import React, { - useEffect, - useRef, - useState, - forwardRef, - useImperativeHandle, -} from 'react'; -import ReCAPTCHA from 'react-google-recaptcha'; -import { Controller, useForm } from 'react-hook-form'; -import { toast } from 'react-hot-toast'; -import * as Yup from 'yup'; -import createMerchantApi from '../api/createMerchantApi'; -import getMerchantApi from '../api/getMerchantApi'; -import addressApi from '@/lib/address/api/addressApi'; -import PageContent from '@/lib/content/components/PageContent'; -import { useRouter } from 'next/router'; -import useAuth from '@/core/hooks/useAuth'; -import { Radio, RadioGroup, Stack, Checkbox, Button } from '@chakra-ui/react'; -import { EyeIcon } from '@heroicons/react/24/outline'; -import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; -import Image from 'next/image'; -import ImageBanner from '~/components/ui/image'; -import { ChevronRightIcon } from '@heroicons/react/24/outline'; -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'; -import { formatValue } from 'react-currency-input-field'; -const InformasiVendor = forwardRef(({ handleIsError, isKonfirmasi }, ref) => { - const isError = (value) => { - // Logika menentukan error - const result = value ? true : false; - handleIsError(result); // Panggil handleIsError dari Merchant - return result; - }; - const { - register, - handleSubmit, - formState: { errors }, - control, - reset, - watch, - setValue, - getValues, - } = useForm({ - resolver: yupResolver(validationSchema), - defaultValues, - }); - const [categoryProduk, setCategoryProduk] = useState([]); - const [isExample, setIsExample] = useState(false); - - const router = useRouter(); - - const auth = useAuth(); - if (auth == false) { - router.push(`/login?next=${encodeURIComponent('/daftar-merchant')}`); - } - const dataTerhitungSejak = [ - { value: 1, label: 'Terima PO' }, - { value: 2, label: 'Barang Dikirimkan' }, - { value: 3, label: 'Tukar Faktur' }, - ]; - - const dataTempo = [ - { value: 24, label: 'Tempo 14 Hari' }, - { value: 25, label: 'Tempo 30 Hari' }, - { value: 28, label: 'Tempo 60 Hari' }, - { value: 31, label: 'Tempo 90 Hari' }, - ]; - - const midIndex = Math.ceil(categoryProduk.length / 2); - const firstColumn = categoryProduk.slice(0, midIndex); - const secondColumn = categoryProduk.slice(midIndex); - const [kreditLimitFormat, setKreditLimitFormat] = useState(); - - useEffect(() => { - const loadData = async () => { - const data = await getMerchantApi(); - if (data) { - reset({ - hargaTayang: data.hargaTayang || '', - categoryProduk: data.categoryProduk || '', - merkDagang: data.merkDagang || '', - isPengajuanTempo: data.isPengajuanTempo || '', - tempoDuration: parseInt(data.tempoDuration) || '', - // kreditLimit: parseInt(data.kreditLimit) || '', - waktuPengiriman: data.waktuPengiriman || '', - terhitungSejak: parseInt(data.terhitungSejak) || '', - }); - handleKreditLimitChange(data.kreditLimit || ''); - setSelectedIds(watch('categoryProduk').split(',').map(Number)); - } - }; - - loadData(); - }, []); - - useImperativeHandle(ref, () => () => { - handleSubmit(onSubmitHandler)(); - }); - - const handleKreditLimitChange = (e) => { - let value = e.target?.value ? e.target.value : e; - - // Hapus semua karakter non-numeric - value = value.replace(/[^\d]/g, ''); - - // Format angka sebagai Rupiah tanpa mengubah nilai sebenarnya - const formattedValue1 = formatValue({ - value: value, - groupSeparator: '.', - decimalSeparator: ',', - prefix: 'Rp ', - }); - - setKreditLimitFormat(formattedValue1); - setValue('kreditLimit', formattedValue1); - }; - - const [selectedIds, setSelectedIds] = useState( - watch('categoryProduk') - ? watch('categoryProduk').split(',').map(Number) - : [] - // form.categoryProduk ? form.categoryProduk.split(',').map(Number) : [] // Parse string menjadi array angka - // [] // Parse string menjadi array angka - ); - const handleCheckboxChange = (id) => { - const updatedSelected = selectedIds.includes(id) - ? selectedIds.filter((selectedId) => selectedId !== id) - : [...selectedIds, id]; - - setSelectedIds(updatedSelected); - - // Mengubah array kembali menjadi string yang dipisahkan oleh koma - setValue('categoryProduk', updatedSelected.join(',')); - }; - - const isChecked = (id) => selectedIds.includes(id); - - const handleCheckboxPortalChange = (value) => { - setValue('isPengajuanTempo', `${value}`); - }; - - useEffect(() => { - if (!isKonfirmasi) { - window.scrollTo({ - top: 0, - behavior: 'smooth', - }); - } - }, []); - - useEffect(() => { - const loadCategories = async () => { - let dataCategories = await odooApi('GET', '/api/v1/category/tree'); - const formattedCategories = dataCategories.map((category) => ({ - id: category.id, - name: category.name, - })); - // Simpan hasil ke state - setCategoryProduk(formattedCategories); - }; - loadCategories(); - }, []); - - const onSubmitHandler = async (values) => { - const toastId = toast.loading('Mengirimkan formulir merchant...'); - const data = { - harga_tayang: values.hargaTayang, - categoryProduk: values.categoryProduk, - merk_dagang: values.merkDagang, - is_pengajuan_tempo: values.isPengajuanTempo, - tempo_duration: values.tempoDuration, - kredit_limit: values.kreditLimit, - waktu_pengiriman: values.waktuPengiriman, - terhitung_sejak: values.terhitungSejak, - }; - const create_leads = await createMerchantApi({ data }); - if (create_leads) { - toast.dismiss(toastId); - isError(false); - toast.success('Berhasil menambahkan data'); - reset(); - // router.push('/+'); - } else { - toast.dismiss(toastId); - toast.error('Gagal menambahkan data'); - } - }; - - // const DownLoadSurat = () => { - // download surat dari /public/file/Surat Pernyataan Nomor Rekening.docx - // }; - - if (!auth) { - return; - } - - return ( - <> - setIsExample(false)} - > -
- Contoh SPPKP -
-
- -
-

- Informasi Vendor -

- -
-
-
-
- -
-
-