From 238c675eecaf6f4f953d87c4b0a128bfa139cff4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 22 Jan 2025 10:06:37 +0700 Subject: update merchant --- .../merchant/components/InformasiPerusahaan.jsx | 520 +++++---------------- 1 file changed, 120 insertions(+), 400 deletions(-) (limited to 'src/lib/merchant/components/InformasiPerusahaan.jsx') diff --git a/src/lib/merchant/components/InformasiPerusahaan.jsx b/src/lib/merchant/components/InformasiPerusahaan.jsx index a93f72c3..ee5560a9 100644 --- a/src/lib/merchant/components/InformasiPerusahaan.jsx +++ b/src/lib/merchant/components/InformasiPerusahaan.jsx @@ -56,43 +56,12 @@ const CreateMerchant = forwardRef( resolver: yupResolver(validationSchema), defaultValues, }); - console.log('errors', errors); - console.log('errors length', errors.length); - 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 [state, setState] = useState([]); const [cities, setCities] = useState([]); const [districts, setDistricts] = useState([]); - const [fileNames, setFileNames] = useState({}); - const [DeatailFile, setDetailFile] = useState({}); const [subDistricts, setSubDistricts] = useState([]); const [zips, setZips] = useState([]); const [isExample, setIsExample] = useState(false); - const [BannerMerchant, setBannerMerchant] = useState(); const [isPkp, setIsPkp] = useState(false); useEffect(() => { @@ -102,10 +71,6 @@ const CreateMerchant = forwardRef( }); }, []); - // useEffect(() => { - // console.log('MASUK SINI IMANUEL'); - // handleSubmit(onSubmitHandler); // Jalankan handler saat buttonSubmitClick berubah - // }, [buttonSubmitClick]); useImperativeHandle(ref, () => () => { handleSubmit(onSubmitHandler)(); @@ -135,7 +100,6 @@ const CreateMerchant = forwardRef( const loadData = async () => { try { const data = await getMerchantApi(); - console.log('data', data); if (data) { reset({ pejabatName: data.pejabatName ? data.pejabatName : '', @@ -227,7 +191,6 @@ const CreateMerchant = forwardRef( }, [auth, watchState]); const watchCity = watch('city'); - console.log('watchCity', watchCity); useEffect(() => { if (watchCity) { // setValue('district', ''); @@ -315,8 +278,6 @@ const CreateMerchant = forwardRef( } }, [watchsubDistrict, subDistricts]); const onSubmitHandler = async (values) => { - console.log('apakah ada error', errors); - console.log('data yang mau dikirim IMANUEL', values); const toastId = toast.loading('Mengirimkan formulir merchant...'); const data = { name_merchant: 'Form Merchant - ' + values.company, @@ -376,40 +337,7 @@ const CreateMerchant = forwardRef( } // Tetap di bagian atas, tidak boleh ada kondisi sebelum hook - const handleFileChange = async (event) => { - let fileBase64 = ''; - const file = event.target.files[0]; - - if (file.size > 500000) { - 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 }); - } - } 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 ( <> @@ -980,25 +908,11 @@ const CreateMerchant = forwardRef(
- {BannerMerchant && ( - + {!isKonfirmasi && ( +

+ Informasi Perusahaan +

)} -

- Form Merchant -

-
- Lorem ipsum dolor sit amet consectetur. Commodo suspendisse at - enim magnis ut quisque rhoncus. Felis volutpat fringilla - sollicitudin ultricies. Enim non eget in lorem netus. Nisl - pharetra accumsan diam suspendisse. -
-

Informasi Perusahaan

+
+
+ + +
+ {errors.pejabatName?.message} +
+ + isi dengan nama pejabat yang berwewenang di perusahaan + anda{' '} + +
+
@@ -1041,6 +975,25 @@ const CreateMerchant = forwardRef(
+
+
+ + +
+ {errors.PICPosition?.message} +
+ + isi dengan jabatan sales / penanggung jawab + +
+
-
- - -
- {errors.hargaTayang?.message} -
-
- -
- -
- - { - 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} -
-
-
-
-