From b89d57916ec9d2be3db786a8481a0acc5fd74e2f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 11 Sep 2024 11:11:38 +0700 Subject: update tampilan desktop switcj account --- .../modules/register/components/FormBisnis.tsx | 85 ++++++++++++++-------- 1 file changed, 54 insertions(+), 31 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 2080ae75..70b6df1f 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -292,7 +292,12 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { /> -
+
-
+
-
-
+
+
= ({ type, required, isPKP, chekValid }) => { )}
-
+
= ({ type, required, isPKP, chekValid }) => {
-
+
- ( - +
+ ( + + )} + /> + {selectedCategory && ( + + Kategori : {selectedCategory} + )} - /> - {selectedCategory && ( - - Kategori : {selectedCategory} - - )} +
{chekValid && !required && !!errors.industry_id && ( {errors.industry_id} )} @@ -404,7 +413,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { name='alamat_bisnis' placeholder='Masukan alamat bisnis anda' value={!required ? form.alamat_bisnis : ''} - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input mt-3 max-h-11 ${ + required ? 'cursor-no-drop' : '' + }`} disabled={required} contentEditable={required} readOnly={required} @@ -431,7 +442,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { name='nama_wajib_pajak' placeholder='Masukan nama lengkap anda' value={!required ? form.nama_wajib_pajak : ''} - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input mt-3 max-h-11 ${ + required ? 'cursor-no-drop' : '' + }`} disabled={required} contentEditable={required} readOnly={required} @@ -483,7 +496,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { : form.alamat_wajib_pajak : '' } - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input max-h-11 mt-3 ${ + required ? 'cursor-no-drop' : '' + }`} disabled={isChekBox || required} contentEditable={required} readOnly={required} @@ -510,7 +525,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { type='tel' id='npwp' name='npwp' - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input max-h-11 mt-3 ${ + required ? 'cursor-no-drop' : '' + }`} disabled={required} contentEditable={required} readOnly={required} @@ -567,7 +584,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { type='tel' id='sppkp' name='sppkp' - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input max-h-11 mt-3 ${ + required ? 'cursor-no-drop' : '' + }`} disabled={required} contentEditable={required} readOnly={required} @@ -594,7 +613,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { type='file' id='npwp_document' name='npwp_document' - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input ${ + type === 'bisnis' ? '' : 'border-none' + } mt-3 ${required ? 'cursor-no-drop' : ''}`} disabled={required} contentEditable={required} readOnly={required} @@ -619,7 +640,9 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { type='file' id='sppkp_document' name='sppkp_document' - className={`form-input mt-3 ${required ? 'cursor-no-drop' : ''}`} + className={`form-input ${ + type === 'bisnis' ? '' : 'border-none' + } mt-3 ${required ? 'cursor-no-drop' : ''}`} disabled={required} contentEditable={required} readOnly={required} -- cgit v1.2.3 From f67560a48990dddcc820c5233a5bf3270d1d69d0 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 11 Sep 2024 11:54:05 +0700 Subject: update switch account --- .../modules/register/components/FormBisnis.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 70b6df1f..6631cb3b 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -293,9 +293,11 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => {
@@ -378,7 +380,7 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { -
+
= ({ type, required, isPKP, chekValid }) => { /> )} /> - {selectedCategory && ( - - Kategori : {selectedCategory} - - )}
+ {selectedCategory && ( + + Kategori : {selectedCategory} + + )} {chekValid && !required && !!errors.industry_id && ( {errors.industry_id} )} -- cgit v1.2.3 From ab39764b288b4d60923cc8cc6146ccdc1b4bfbac Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 11 Sep 2024 14:01:53 +0700 Subject: update switch acc --- src-migrate/modules/register/components/FormBisnis.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 6631cb3b..73de60cb 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -296,7 +296,7 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { className={` ${ type === 'bisnis' ? 'mt-6 grid grid-cols-1 gap-y-4' - : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-2' + : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-5 auto-rows-min' }`} onSubmit={handleSubmit} > @@ -332,11 +332,11 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { )}
-
+
-
+
= ({ type, required, isPKP, chekValid }) => { -
+
Date: Wed, 11 Sep 2024 17:07:49 +0700 Subject: update switch account --- src-migrate/modules/register/components/FormBisnis.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 73de60cb..85bb491d 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -296,7 +296,7 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { className={` ${ type === 'bisnis' ? 'mt-6 grid grid-cols-1 gap-y-4' - : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-5 auto-rows-min' + : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-6 auto-rows-min' }`} onSubmit={handleSubmit} > @@ -332,7 +332,7 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { )}
-
+
-- cgit v1.2.3 From 935066853ab4847fbff605eed21f98ddbb445864 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 26 Sep 2024 17:02:45 +0700 Subject: update form bisnis --- .../modules/register/components/FormBisnis.tsx | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 6185179f..c88ec735 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -87,16 +87,31 @@ const form: React.FC = ({ label: o.name, })) ); + // setValue('companyType', form.company_type_id); }; loadCompanyTypes(); }, []); + useEffect(() => { + if (form.company_type_id) { + console.log('form.company_type_id', form.company_type_id); + setValue('companyType', form.company_type_id); + } + }, [form.company_type_id]); + useEffect(() => { const selectedCompanyType = companyTypes.find( (company) => company.value === watch('companyType') ); if (selectedCompanyType) { + console.log('selectedCompanyType', selectedCompanyType); updateForm('company_type_id', `${selectedCompanyType?.value}`); + // setCompanyTypes([ + // { + // value: '2', + // label: 'Distributor', + // }, + // ]); validate(); } }, [watch('companyType'), companyTypes]); @@ -122,6 +137,7 @@ const form: React.FC = ({ category: o.category, })) ); + // setValue('industry_id', form.industry_id); }; loadIndustries(); }, []); @@ -582,7 +598,13 @@ const form: React.FC = ({ readOnly={required} ref={npwpRef} placeholder='000.000.000.0-000.000' - value={!required ? formattedNpwp : ''} + value={ + !required + ? formattedNpwp === '' + ? form.npwp + : formattedNpwp + : '' + } maxLength={21} // Set maximum length to 16 characters onChange={(e) => { if (!required) { -- cgit v1.2.3 From 11f415a8c9438362078d0eceee37701edbdeaafc Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 27 Sep 2024 09:28:14 +0700 Subject: update fetch data --- src-migrate/modules/page-content/index.tsx | 1 - .../modules/register/components/FormBisnis.tsx | 72 ++++++++++++---------- 2 files changed, 41 insertions(+), 32 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/page-content/index.tsx b/src-migrate/modules/page-content/index.tsx index af597641..edecb855 100644 --- a/src-migrate/modules/page-content/index.tsx +++ b/src-migrate/modules/page-content/index.tsx @@ -20,7 +20,6 @@ const PageContent = ({ path }: Props) => { `src="${process.env.NEXT_PUBLIC_ODOO_API_HOST}/web/image` ); }, [data]); - console.log('parsedContent', parsedContent); if (isLoading) return ; return
; diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index c88ec735..d4fdbbbd 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -1,4 +1,11 @@ -import { ChangeEvent, useEffect, useMemo, useRef, useState } from 'react'; +import { + ChangeEvent, + useEffect, + useMemo, + useRef, + useState, + MouseEvent, +} from 'react'; import { useMutation } from 'react-query'; import { useRegisterStore } from '../stores/useRegisterStore'; import { RegisterProps } from '~/types/auth'; @@ -62,7 +69,6 @@ const form: React.FC = ({ const router = useRouter(); const toast = useToast(); - const emailRef = useRef(null); const businessNameRef = useRef(null); const companyTypeRef = useRef(null); @@ -94,38 +100,14 @@ const form: React.FC = ({ useEffect(() => { if (form.company_type_id) { - console.log('form.company_type_id', form.company_type_id); - setValue('companyType', form.company_type_id); + setValue('companyType', parseInt(form.company_type_id)); } - }, [form.company_type_id]); - - useEffect(() => { - const selectedCompanyType = companyTypes.find( - (company) => company.value === watch('companyType') - ); - if (selectedCompanyType) { - console.log('selectedCompanyType', selectedCompanyType); - updateForm('company_type_id', `${selectedCompanyType?.value}`); - // setCompanyTypes([ - // { - // value: '2', - // label: 'Distributor', - // }, - // ]); - validate(); - } - }, [watch('companyType'), companyTypes]); - + }, []); useEffect(() => { - const selectedIndustryType = industries.find( - (industry) => industry.value === watch('industry_id') - ); - if (selectedIndustryType) { - updateForm('industry_id', `${selectedIndustryType?.value}`); - setSelectedCategory(selectedIndustryType.category); - validate(); + if (form.industry_id) { + setValue('industry_id', parseInt(form.industry_id)); } - }, [watch('industry_id'), industries]); + }, []); useEffect(() => { const loadIndustries = async () => { @@ -326,6 +308,32 @@ const form: React.FC = ({ }; loadIndustries(); }, [buttonSubmitClick, chekValid]); + + const handleCompanyTypeChange = (event: MouseEvent) => { + const selectedCompanyTypeValue = watch('companyType'); + const selectedCompanyType = companyTypes.find( + (company) => company.value === selectedCompanyTypeValue + ); + + if (selectedCompanyType !== undefined) { + updateForm('company_type_id', `${selectedCompanyType.value}`); + validate(); + } + }; + useEffect(() => {}, [watch('industry_id'), industries]); + + const handleIndustriIdChange = (event: MouseEvent) => { + const selectedIndustriIdValue = watch('industry_id'); + const selectedIndustryType = industries.find( + (industry) => industry.value === selectedIndustriIdValue + ); + if (selectedIndustryType) { + updateForm('industry_id', `${selectedIndustryType?.value}`); + setSelectedCategory(selectedIndustryType.category); + validate(); + } + }; + return ( <> = ({
= ({
Date: Fri, 27 Sep 2024 15:36:39 +0700 Subject: update form bisnis to switch account --- .../modules/register/components/FormBisnis.tsx | 126 +++++++++++++++++++-- 1 file changed, 115 insertions(+), 11 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index d4fdbbbd..ad92948e 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -24,10 +24,15 @@ import { Controller, useForm } from 'react-hook-form'; import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; import odooApi from '~/libs/odooApi'; import { toast } from 'react-hot-toast'; -import { EyeIcon } from '@heroicons/react/24/outline'; +import { + EyeIcon, + CheckCircleIcon, + XCircleIcon, +} from '@heroicons/react/24/outline'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; import Image from 'next/image'; import useDevice from '@/core/hooks/useDevice'; +import useAuth from '@/core/hooks/useAuth'; interface FormProps { type: string; required: boolean; @@ -101,14 +106,16 @@ const form: React.FC = ({ useEffect(() => { if (form.company_type_id) { setValue('companyType', parseInt(form.company_type_id)); + updateForm('sppkp_document', 'fileBase64.jpg'); } - }, []); + }, [form.company_type_id]); useEffect(() => { if (form.industry_id) { setValue('industry_id', parseInt(form.industry_id)); } - }, []); + }, [form.industry_id]); + console.log('form', form); useEffect(() => { const loadIndustries = async () => { const dataIndustries = await odooApi('GET', '/api/v1/partner/industry'); @@ -230,7 +237,7 @@ const form: React.FC = ({ toast({ ...toastProps, title: - 'Format file yang diijinkan adalah .pdf, .doc, .docx, .png, .jpg, atau .jpeg', + 'Format file yang diijinkan adalah .pdf, .png, .jpg, atau .jpeg', status: 'error', }); event.target.value = ''; @@ -238,10 +245,10 @@ const form: React.FC = ({ } // Check for file size - if (file.size > 5000000) { + if (file.size > 2000000) { toast({ ...toastProps, - title: 'Maksimal ukuran file adalah 5MB', + title: 'Maksimal ukuran file adalah 2MB', status: 'error', }); event.target.value = ''; @@ -320,7 +327,6 @@ const form: React.FC = ({ validate(); } }; - useEffect(() => {}, [watch('industry_id'), industries]); const handleIndustriIdChange = (event: MouseEvent) => { const selectedIndustriIdValue = watch('industry_id'); @@ -334,13 +340,65 @@ const form: React.FC = ({ } }; + const [fileUrl, setFileUrl] = useState(''); + const [popUpNPWP, setPopUpNpwp] = useState(false); + const [popSppkp, setPopUpSppkp] = useState(false); + const [hasNPWP, sethasNpwp] = useState(false); + const [hasSPPKP, sethasSPPKP] = useState(false); + const [fileUrlSppkp, setFileUrlSppkp] = useState(''); + + useEffect(() => { + const url = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/download/npwp/109119`; + if (url) { + setFileUrl(url); + sethasNpwp(true); + } + const urlSppkp = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/download/sppkp/109119`; + if (urlSppkp) { + setFileUrlSppkp(urlSppkp); + sethasSPPKP(true); + } + }, []); + return ( <> + setPopUpNpwp(false)} + > +
+ +
+
+ setPopUpSppkp(false)} + > +
+ +
+
setIsExample(false)} + close={() => setPopUpNpwp(false)} >
= ({ ref={docsNpwpRef} readOnly={required} onChange={handleFileChange} - accept='.pdf,.doc,.docx,.png,.jpg,.jpeg' // Filter file types + accept='.pdf,.png,.jpg,.jpeg' // Filter file types /> {chekValid && isPKP && !required && !!errors.npwp_document && ( {errors.npwp_document} )} + + Format: .pdf, .png, .jpg, atau .jpeg, Maks 2MB + + {hasNPWP && ( +
+
+
+ + Dokumen sudah diupload +
+
+ setPopUpNpwp(true)} + className={`w-6 mr-2 hover:scale-110 transition-transform duration-200}`} + /> + sethasNpwp(false)} + className='w-6 hover:scale-110 transition-transform duration-200' + /> +
+
+
+ )}
-
@@ -830,7 +852,7 @@ const form: React.FC = ({ className={`w-6 mr-2 hover:scale-110 transition-transform duration-200}`} /> sethasSPPKP(false)} + onClick={() => setHasSPPKP(false)} className='w-6 hover:scale-110 transition-transform duration-200' />
diff --git a/src-migrate/modules/register/index.tsx b/src-migrate/modules/register/index.tsx index da41fd8b..3d6158c8 100644 --- a/src-migrate/modules/register/index.tsx +++ b/src-migrate/modules/register/index.tsx @@ -170,7 +170,8 @@ const Register = () => { size='lg' onClick={handleSubmit} isDisabled={ - !isCheckedTNC || mutation.isLoading || !isValidCaptcha + // !isCheckedTNC || mutation.isLoading || !isValidCaptcha + !isCheckedTNC || mutation.isLoading } > {mutation.isLoading ? 'Loading...' : 'Daftar'} -- cgit v1.2.3 From a8aabf3a4a2fb0208684d10b6eefa9b81b2bcc25 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 28 Sep 2024 11:24:04 +0700 Subject: update code --- src-migrate/modules/register/components/FormBisnis.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 932bd326..97c0acad 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -110,7 +110,6 @@ const form: React.FC = ({ useEffect(() => { if (form.company_type_id) { setValue('companyType', parseInt(form.company_type_id)); - updateForm('sppkp_document', 'fileBase64.jpg'); } }, [form.company_type_id]); useEffect(() => { -- cgit v1.2.3 From 5ced4f02e9f2b655d61c9bef59fa0169a12a513d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 30 Sep 2024 10:07:19 +0700 Subject: update if terdaftar, tipe bisnis hidden --- .../register/components/RegistrasiBisnis.tsx | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index ce4d3972..2a52170e 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -164,19 +164,21 @@ const RegistrasiBisnis: React.FC = ({
-
-

Tipe Bisnis

- - - - PKP - - - Non-PKP - - - -
+ {!isTerdaftar && ( +
+

Tipe Bisnis

+ + + + PKP + + + Non-PKP + + + +
+ )} Date: Mon, 30 Sep 2024 13:57:59 +0700 Subject: update switch account --- .../modules/register/components/FormBisnis.tsx | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 97c0acad..16747ff3 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -348,12 +348,22 @@ const form: React.FC = ({ const [hasNPWP, setHasNpwp] = useState(false); const [hasSPPKP, setHasSPPKP] = useState(false); const [fileUrlSppkp, setFileUrlSppkp] = useState(''); - useEffect(() => { - const checkUrl = async (url: string | URL | Request) => { + const checkUrlNPWP = async (url: string | URL | Request) => { + try { + const response = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/chek/npwp/${auth?.parentId}`; + + return response; // Returns true if status is 200-299 + } catch (error) { + console.error('Error accessing URL:', url, error); + return false; + } + }; + const checkUrlSPPKP = async (url: string | URL | Request) => { try { - const response = await fetch(url, { method: 'HEAD' }); - return response.ok; // Returns true if status is 200-299 + const response = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/chek/sppkp/${auth?.parentId}`; + + return response; // Returns true if status is 200-299 } catch (error) { console.error('Error accessing URL:', url, error); return false; @@ -364,14 +374,16 @@ const form: React.FC = ({ const sppkpUrl = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/download/sppkp/${auth?.parentId}`; if (auth?.parentId) { - checkUrl(npwpUrl).then((isAccessible) => { + checkUrlNPWP(npwpUrl).then((isAccessible) => { if (isAccessible) { setFileUrl(npwpUrl); setHasNpwp(true); + updateForm('npwp_document', ' '); + updateForm('sppkp_document', ' '); } }); - checkUrl(sppkpUrl).then((isAccessible) => { + checkUrlSPPKP(sppkpUrl).then((isAccessible) => { if (isAccessible) { setFileUrlSppkp(sppkpUrl); setHasSPPKP(true); @@ -835,6 +847,9 @@ const form: React.FC = ({ accept='.pdf,.png,.jpg,.jpeg' content='lagu.jpg' /> + {chekValid && isPKP && !required && !!errors.sppkp_document && ( + {errors.sppkp_document} + )} Format: .pdf, .png, .jpg, atau .jpeg, Maks 2MB @@ -858,10 +873,6 @@ const form: React.FC = ({
)} - - {chekValid && isPKP && !required && !!errors.sppkp_document && ( - {errors.sppkp_document} - )}
-- cgit v1.2.3 From ed679c9b8ea85e8f181cf67465effc4b5ff1a7bc Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 1 Oct 2024 09:42:51 +0700 Subject: update code has npwp atau sppkp --- src-migrate/modules/register/components/FormBisnis.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 16747ff3..9e5a0c07 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -351,9 +351,11 @@ const form: React.FC = ({ useEffect(() => { const checkUrlNPWP = async (url: string | URL | Request) => { try { - const response = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/chek/npwp/${auth?.parentId}`; - - return response; // Returns true if status is 200-299 + const response = await odooApi( + 'GET', + `/api/v1/user/chek/npwp/${auth?.parentId}` + ); + return response.status; // Returns true if status is 200-299 } catch (error) { console.error('Error accessing URL:', url, error); return false; @@ -361,9 +363,12 @@ const form: React.FC = ({ }; const checkUrlSPPKP = async (url: string | URL | Request) => { try { - const response = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/user/chek/sppkp/${auth?.parentId}`; + const response = await odooApi( + 'GET', + `/api/v1/user/chek/sppkp/${auth?.parentId}` + ); - return response; // Returns true if status is 200-299 + return response.status; // Returns true if status is 200-299 } catch (error) { console.error('Error accessing URL:', url, error); return false; @@ -379,7 +384,6 @@ const form: React.FC = ({ setFileUrl(npwpUrl); setHasNpwp(true); updateForm('npwp_document', ' '); - updateForm('sppkp_document', ' '); } }); @@ -387,6 +391,7 @@ const form: React.FC = ({ if (isAccessible) { setFileUrlSppkp(sppkpUrl); setHasSPPKP(true); + updateForm('sppkp_document', ' '); } }); } -- cgit v1.2.3 From 35c40c565730c80948a226d8de7478e6c3b86478 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 1 Oct 2024 15:01:18 +0700 Subject: update switch account --- .../modules/register/stores/useRegisterStore.ts | 58 +++++++++++----------- src-migrate/validations/auth.ts | 54 +++++++++++++------- 2 files changed, 67 insertions(+), 45 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/useRegisterStore.ts b/src-migrate/modules/register/stores/useRegisterStore.ts index 273472be..815b92d9 100644 --- a/src-migrate/modules/register/stores/useRegisterStore.ts +++ b/src-migrate/modules/register/stores/useRegisterStore.ts @@ -28,7 +28,7 @@ export const useRegisterStore = create((set, get) => ({ company_type_id: '', business_name: '', name: '', - nama_wajib_pajak : '', + nama_wajib_pajak: '', email: '', email_partner: '', password: '', @@ -39,14 +39,14 @@ export const useRegisterStore = create((set, get) => ({ npwp: '', sppkp: '', is_pkp: '', - type_acc:'', - is_terdaftar:'', - alamat_bisnis:'', - alamat_wajib_pajak:'', + type_acc: '', + is_terdaftar: '', + alamat_bisnis: '', + alamat_wajib_pajak: '', + parent_id: '', }, updateForm: (name, value) => set((state) => ({ form: { ...state.form, [name]: value } })), - errors: {}, validate: () => { @@ -74,26 +74,28 @@ export const useRegisterStore = create((set, get) => ({ isValidCaptcha: false, updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })), - resetForm: () => set({ - form: { - company_type_id: '', - business_name: '', - name: '', - nama_wajib_pajak : '', - email: '', - email_partner: '', - password: '', - phone: '', - sppkp_document: '', - npwp_document: '', - industry_id: '', - npwp: '', - sppkp: '', - is_pkp: '', - type_acc:'', - is_terdaftar:'', - alamat_bisnis:'', - alamat_wajib_pajak:'', - }, - }), + resetForm: () => + set({ + form: { + company_type_id: '', + business_name: '', + name: '', + nama_wajib_pajak: '', + email: '', + email_partner: '', + password: '', + phone: '', + sppkp_document: '', + npwp_document: '', + industry_id: '', + npwp: '', + sppkp: '', + is_pkp: '', + type_acc: '', + is_terdaftar: '', + alamat_bisnis: '', + alamat_wajib_pajak: '', + parent_id: '', + }, + }), })); diff --git a/src-migrate/validations/auth.ts b/src-migrate/validations/auth.ts index 3abdfb57..0df80a2a 100644 --- a/src-migrate/validations/auth.ts +++ b/src-migrate/validations/auth.ts @@ -18,6 +18,7 @@ export const registerSchema = z nama_wajib_pajak: z.string().optional(), alamat_bisnis: z.string().optional(), alamat_wajib_pajak: z.string().optional(), + parent_id: z.string().optional(), is_pkp: z.string(), is_terdaftar: z.string(), sppkp_document: z.string().optional(), @@ -27,25 +28,42 @@ export const registerSchema = z business_name: z.string().optional(), company_type_id: z.string().optional(), isChekBox: z.string().optional(), - npwp: z.string().optional().refine((val) => !val || /^\d{15,16}$/.test(val), { - message: 'Format NPWP tidak valid, NPWP harus terdiri dari 15-16 digit angka.', - }), + npwp: z + .string() + .optional() + .refine((val) => !val || /^\d{15,16}$/.test(val), { + message: + 'Format NPWP tidak valid, NPWP harus terdiri dari 15-16 digit angka.', + }), sppkp: z.string().optional(), }) .superRefine((data, ctx) => { if (data.type_acc === 'business') { if (data.is_terdaftar === 'false') { if (data.is_pkp === 'true') { - const requiredFields: { field: keyof typeof data; message: string }[] = [ + const requiredFields: { + field: keyof typeof data; + message: string; + }[] = [ { field: 'business_name', message: 'Nama perusahaan harus diisi' }, - { field: 'alamat_bisnis', message: 'Alamat perusahaan harus diisi' }, + { + field: 'alamat_bisnis', + message: 'Alamat perusahaan harus diisi', + }, // { field: 'alamat_wajib_pajak', message: 'Alamat wajib pajak harus diisi' }, { field: 'company_type_id', message: 'Badan usaha wajib dipilih' }, { field: 'industry_id', message: 'Jenis usaha harus dipilih' }, { field: 'sppkp_document', message: 'Document harus diisi' }, { field: 'npwp_document', message: 'Document harus diisi' }, - { field: 'npwp', message: 'Format NPWP tidak valid, NPWP harus terdiri dari 15-16 digit angka.' }, - { field: 'nama_wajib_pajak', message: 'Nama wajib pajak harus diisi' }, + { + field: 'npwp', + message: + 'Format NPWP tidak valid, NPWP harus terdiri dari 15-16 digit angka.', + }, + { + field: 'nama_wajib_pajak', + message: 'Nama wajib pajak harus diisi', + }, ]; requiredFields.forEach(({ field, message }) => { @@ -57,15 +75,19 @@ export const registerSchema = z }); } }); - - if (!data.email_partner || !z.string().email().safeParse(data.email_partner).success) { + + if ( + !data.email_partner || + !z.string().email().safeParse(data.email_partner).success + ) { ctx.addIssue({ code: 'custom', path: ['email_partner'], - message: 'Email partner harus diisi dengan format example@mail.com', + message: + 'Email partner harus diisi dengan format example@mail.com', }); } - if(data.isChekBox === 'false'){ + if (data.isChekBox === 'false') { if (!data.alamat_wajib_pajak) { ctx.addIssue({ code: 'custom', @@ -74,7 +96,6 @@ export const registerSchema = z }); } } - } else { if (!data.business_name) { ctx.addIssue({ @@ -110,12 +131,12 @@ export const registerSchema = z ctx.addIssue({ code: 'custom', path: ['npwp'], - message: 'Format NPWP tidak valid, NPWP harus terdiri dari 15-16 digit angka.', + message: + 'Format NPWP tidak valid, NPWP harus terdiri dari 15-16 digit angka.', }); } - } - }else{ + } else { if (data.is_pkp === 'true') { if (!data.business_name) { ctx.addIssue({ @@ -141,7 +162,6 @@ export const registerSchema = z // path: ['business_name'], // message: 'Nama perusahaan harus diisi', // }); - }else{ - + } else { } }); -- cgit v1.2.3 From bdfe0ad9b7cc5ef819b7b74fec6159d03280ab91 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 25 Oct 2024 10:19:56 +0700 Subject: update switch account --- src-migrate/modules/register/components/FormBisnis.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 9e5a0c07..9f9f1ca5 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -435,7 +435,7 @@ const form: React.FC = ({ className='' title='Contoh SPPKP' active={isExample} - close={() => setPopUpNpwp(false)} + close={() => setIsExample(false)} >