diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 16:34:44 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 16:34:44 +0700 |
| commit | 898c82a908d604862596e477bd66ecc15fe3af0c (patch) | |
| tree | 18c5c3765748759d4538e766d62110353d24b9fc | |
| parent | cb083185ce59df7143ea258e147a118a1e416e56 (diff) | |
<iman> update merchant
| -rw-r--r-- | src/lib/merchant/components/InformasiPerusahaan.jsx | 8 | ||||
| -rw-r--r-- | src/lib/merchant/components/Konfirmasi.jsx | 18 | ||||
| -rw-r--r-- | src/lib/merchant/components/SyaratDagang.jsx | 38 |
3 files changed, 40 insertions, 24 deletions
diff --git a/src/lib/merchant/components/InformasiPerusahaan.jsx b/src/lib/merchant/components/InformasiPerusahaan.jsx index 88bad0c4..a93f72c3 100644 --- a/src/lib/merchant/components/InformasiPerusahaan.jsx +++ b/src/lib/merchant/components/InformasiPerusahaan.jsx @@ -324,10 +324,10 @@ const CreateMerchant = forwardRef( pic_merchant: values.PICName, pic_position: values.PICPosition, address: values.address, - state: values.state, - city: values.city, - district: values.district, - subDistrict: values.subDistrict, + 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, diff --git a/src/lib/merchant/components/Konfirmasi.jsx b/src/lib/merchant/components/Konfirmasi.jsx index 45db7388..6deabe05 100644 --- a/src/lib/merchant/components/Konfirmasi.jsx +++ b/src/lib/merchant/components/Konfirmasi.jsx @@ -17,6 +17,7 @@ import InformasiPerusahaan from './InformasiPerusahaan'; import InformasiVendor from './InformasiVendor'; import SyaratDagang from './SyaratDagang'; import Dokumen from './Dokumen'; +import createMerchantApi from '../api/createMerchantApi'; import useDevice from '@/core/hooks/useDevice'; import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'; import { useRouter } from 'next/router'; @@ -34,11 +35,24 @@ const Konfirmasi = ({ chekValid, buttonSubmitClick }) => { formRef.current(); // Memicu submit form di InformasiPerusahaan } }; - const handleIsError = (value) => { + const handleIsError = async (value) => { console.log('LAHKAH SELANJUTNYA', value); if (!value) { // goToNextStep(); - toast.success('Berhasil medaftarkan merchant'); + const toastId = toast.loading('Mengirimkan formulir merchant...'); + const data = { + merchant_request: true, + }; + const create_leads = await createMerchantApi({ data }); + if (create_leads) { + toast.dismiss(toastId); + toast.success('Berhasil medaftarkan merchant'); + reset(); + // router.push('/+'); + } else { + toast.dismiss(toastId); + toast.error('Gagal menambahkan data'); + } } reset(); router.push('/'); diff --git a/src/lib/merchant/components/SyaratDagang.jsx b/src/lib/merchant/components/SyaratDagang.jsx index 362302fd..3451fa96 100644 --- a/src/lib/merchant/components/SyaratDagang.jsx +++ b/src/lib/merchant/components/SyaratDagang.jsx @@ -123,7 +123,9 @@ const SyaratDagang = forwardRef(({ handleIsError, isKonfirmasi }, ref) => { isOrderQuantity: data.isOrderQuantity || '', }); // handleKreditLimitChange(data.kreditLimit); - setSelectedIds(watch('sertifikatProduk').split(',').map(Number)); + if (watch('sertifikatProduk') != false) { + setSelectedIds(watch('sertifikatProduk').split(',').map(Number)); + } if (watch('customSertifikatProduk')) { // setSelectedIds([...selectedIds, 4]); } @@ -176,10 +178,10 @@ const SyaratDagang = forwardRef(({ handleIsError, isKonfirmasi }, ref) => { ]; const category_produk = [ - { id: 1, name: 'TKDN' }, - { id: 2, name: 'SNI' }, - { id: 3, name: 'K3L' }, - { id: 4, name: '' }, + { id: 0, name: 'TKDN' }, + { id: 1, name: 'SNI' }, + { id: 2, name: 'K3L' }, + { id: 3, name: '' }, ]; const firstColumn = category_produk; @@ -203,7 +205,7 @@ const SyaratDagang = forwardRef(({ handleIsError, isKonfirmasi }, ref) => { setValue('sertifikatProduk', updatedSelected.join(',')); }; const custom_sertifikat_produk_handle = () => { - const updatedSelected = [...selectedIds, 4]; + const updatedSelected = [...selectedIds, 3]; setSelectedIds(updatedSelected); @@ -578,34 +580,34 @@ const SyaratDagang = forwardRef(({ handleIsError, isKonfirmasi }, ref) => { > <Checkbox colorScheme='red' - key={1} - onChange={() => handleCheckboxChange(1)} - isChecked={isChecked(1)} + key={0} + onChange={() => handleCheckboxChange(0)} + isChecked={isChecked(0)} > TKDN </Checkbox> <Checkbox colorScheme='red' - key={2} - onChange={() => handleCheckboxChange(2)} - isChecked={isChecked(2)} + key={1} + onChange={() => handleCheckboxChange(1)} + isChecked={isChecked(1)} > SNI </Checkbox> <Checkbox colorScheme='red' - key={3} - onChange={() => handleCheckboxChange(3)} - isChecked={isChecked(3)} + key={2} + onChange={() => handleCheckboxChange(2)} + isChecked={isChecked(2)} > K3L </Checkbox> <div className='flex flex-row gap-2 w-full'> <Checkbox colorScheme='red' - key={4} - onChange={() => handleCheckboxChange(4)} - isChecked={isChecked(4)} + key={3} + onChange={() => handleCheckboxChange(3)} + isChecked={isChecked(3)} ></Checkbox> <input {...register('customSertifikatProduk')} |
