From abcce110895d767a16fb961a65e7c78f9213ca0d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 24 Oct 2024 17:11:32 +0700 Subject: update pengajuan tempo --- .../component/KonfirmasiDokumen.jsx | 227 +++++++++++++++++---- 1 file changed, 182 insertions(+), 45 deletions(-) (limited to 'src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx') diff --git a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx index 528a7a4f..753af29e 100644 --- a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx +++ b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx @@ -7,11 +7,16 @@ import { toast } from 'react-hot-toast'; import getFileBase64 from '@/core/utils/getFileBase64'; import Image from 'next/image'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +import { EyeIcon } from '@heroicons/react/24/outline'; +import useDevice from '@/core/hooks/useDevice'; const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { const { control, watch } = useForm(); const [isExample, setIsExample] = useState(false); - const [popUpTittle, setPopUpTittle] = useState(false); - const [popUpSource, setSource] = useState(false); + const { isDesktop, isMobile } = useDevice(); + const [base64, setBase64] = useState(); + const [pdfData, setPdfData] = useState(); + const [format, setFormat] = useState(); + const [popUpSource, setSource] = useState(); const { formDokumen, errorsDokumen, @@ -25,17 +30,26 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { // updateFormDokumen(name, value); // validateDokumen(); // }; + const handleConfirmSubmit = (format, base64) => { + if (format == 'pdf') { + setFormat(`application/${format}`); + } else { + setFormat(`image/${format}`); + } + setBase64( + base64.trim().replace(/^"+/, '').replace(/"+$/, '').replaceAll('\\', '') + ); + setIsExample(!isExample); + }; const handleInputChange = async (event) => { let fileBase64 = ''; const { name } = event.target; const file = event.target.files?.[0]; - // Allowed file extensions const allowedExtensions = ['pdf', 'png', 'jpg', 'jpeg']; let fileExtension = ''; if (file) { - fileExtension = file.name.split('.').pop()?.toLowerCase(); // Extract file extension + fileExtension = file.name.split('.').pop()?.toLowerCase(); - // Check if the file extension is allowed if (!fileExtension || !allowedExtensions.includes(fileExtension)) { toast.error( 'Format file yang diijinkan adalah .pdf, .png, .jpg, atau .jpeg', @@ -46,7 +60,6 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { return; } - // Check for file size if (file.size > 2000000) { toast.error('Maksimal ukuran file adalah 2MB', { duration: 4000 }); @@ -54,7 +67,6 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { return; } - // Convert file to Base64 fileBase64 = await getFileBase64(file); updateFormDokumen(name, file.name, fileExtension, fileBase64); validateDokumen(); @@ -138,26 +150,8 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { useEffect(() => { validateDokumen(); }, [buttonSubmitClick]); - console.log('formDokumen', formDokumen); return ( <> - setIsExample(false)} - > -
- Contoh SPPKP -
-

Dokumen

@@ -171,7 +165,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenNib?.name} -
+
{chekValid && ( @@ -208,7 +214,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenNpwp?.name} -
+
{chekValid && ( @@ -245,7 +263,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenSppkp?.name} -
+
{chekValid && ( @@ -286,7 +316,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenAktaPerubahan?.name} -
+
{chekValid && ( @@ -326,7 +368,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenKtpDirut?.name} -
+
{chekValid && ( @@ -366,7 +420,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenAktaPendirian?.name} -
+
{chekValid && ( @@ -407,7 +473,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenLaporanKeuangan?.name} -
+
{chekValid && ( @@ -447,7 +525,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenFotoKantor?.name} -
+
{chekValid && ( @@ -485,7 +575,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => { {formDokumen?.dokumenTempatBekerja?.name} -
+
-
setIsExample(!isExample)} - className='rounded text-white p-2 flex flex-row bg-red-500 hover:cursor-pointer hover:bg-red-400' - > - - {isDesktop && ( -

Lihat Contoh

- )} -
- Contoh SPPKP + /> */}
{chekValid && (
@@ -531,8 +624,52 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
+ + setIsExample(false)} + > +
+ + {/* */} +
+
); }; export default KonfirmasiDokumen; + +{ + /* */ +} +{ + /* Contoh SPPKP */ +} -- cgit v1.2.3