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 f555e7bc9d070e7e0bd4900941592480d4ba6c6a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 17 Oct 2024 14:39:17 +0700 Subject: update pengajuan tempo --- .../register/stores/usePengajuanTempoStore.ts | 93 ++++++++++++++++++++++ src-migrate/types/tempo.ts | 59 ++++++++++++++ src-migrate/validations/tempo.ts | 28 +++++++ 3 files changed, 180 insertions(+) create mode 100644 src-migrate/modules/register/stores/usePengajuanTempoStore.ts create mode 100644 src-migrate/types/tempo.ts create mode 100644 src-migrate/validations/tempo.ts (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts new file mode 100644 index 00000000..6f3bc13d --- /dev/null +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -0,0 +1,93 @@ +import { create } from 'zustand'; +import { TempoProps } from '~/types/tempo'; +import { TempoSchema } from '~/validations/tempo'; +import { boolean, ZodError } from 'zod'; + +type State = { + form: TempoProps; + errors: { + [key in keyof TempoProps]?: string; + }; + isCheckedTNC: boolean; + isOpenTNC: boolean; + isValidCaptcha: boolean; +}; + +type Action = { + updateForm: (name: string, value: string) => void; + updateValidCaptcha: (value: boolean) => void; + toggleCheckTNC: () => void; + openTNC: () => void; + closeTNC: () => void; + validate: () => void; + resetForm: () => void; +}; + +export const usePengajuanTempoStore = create((set, get) => ({ + form: { + name: '', + industry_id: '', + street: '', + state: '', + city: '', + zip: '', + mobile: '', + bankName: '', + accountName: '', + accountNumber: '', + estimasi: '', + tempoDuration: '', + bersedia: '', + categoryProduk: '', + tempoLimit: '', + }, + updateForm: (name, value) => + set((state) => ({ form: { ...state.form, [name]: value } })), + + errors: {}, + validate: () => { + try { + TempoSchema.parse(get().form); + set({ errors: {} }); + } catch (error) { + if (error instanceof ZodError) { + const errors: State['errors'] = {}; + error.errors.forEach( + (e) => (errors[e.path[0] as keyof TempoProps] = e.message) + ); + set({ errors }); + } + } + }, + + isCheckedTNC: false, + toggleCheckTNC: () => set((state) => ({ isCheckedTNC: !state.isCheckedTNC })), + + isOpenTNC: false, + openTNC: () => set(() => ({ isOpenTNC: true })), + closeTNC: () => set(() => ({ isOpenTNC: false })), + + isValidCaptcha: false, + updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })), + + resetForm: () => + set({ + form: { + name: '', + industry_id: '', + street: '', + state: '', + city: '', + zip: '', + mobile: '', + bankName: '', + accountName: '', + accountNumber: '', + estimasi: '', + tempoDuration: '', + bersedia: '', + categoryProduk: '', + tempoLimit: '', + }, + }), +})); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts new file mode 100644 index 00000000..f8a3c5b8 --- /dev/null +++ b/src-migrate/types/tempo.ts @@ -0,0 +1,59 @@ +import { TempoSchema } from '~/validations/tempo'; +import { OdooApiRes } from './odoo'; +import { z } from 'zod'; + +export type tempoProps = { + name: string; + industry_id: string; + street: string; + state: string; + city: string; + zip: string; + mobile: string; + bankName: string; + accountName: string; + accountNumber: string; + estimasi: string; + tempoDuration: string; + bersedia: string; +}; + +export type TempoApiProps = OdooApiRes; + +export type TempoProps = z.infer; + +export type TempoResApiProps = { + Tempo: boolean; + reason: 'EMAIL_USED' | 'NOT_ACTIVE' | null; +}; + +type ActivationResProps = { + activation: boolean; + user: TempoProps | null; +}; + +export type ActivationTokenProps = { + token: string; +}; + +export type ActivationTokenResApiProps = ActivationResProps & { + reason: 'INVALID_TOKEN' | null; +}; + +export type ActivationOtpProps = { + email: string; + otp: string; +}; + +export type ActivationOtpResApiProps = ActivationResProps & { + reason: 'INVALID_OTP' | null; +}; + +export type ActivationReqProps = { + email: string; +}; + +export type ActivationReqResApiProps = { + activation_request: boolean; + reason: 'NOT_FOUND' | 'ACTIVE' | null; +}; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts new file mode 100644 index 00000000..6999c1c6 --- /dev/null +++ b/src-migrate/validations/tempo.ts @@ -0,0 +1,28 @@ +import { z } from 'zod'; + +export const TempoSchema = z.object({ + name: z.string().min(1, { message: 'Nama harus diisi' }), + street: z.string().min(1, { message: 'Alamat harus diisi' }), + industry_id: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), + zip: z.string().min(1, { message: 'Kode pos harus diisi' }), + state: z.string().min(1, { message: 'Provinsi harus dipilih' }), + city: z.string().min(1, { message: 'Kota harus dipilih' }), + mobile: z + .string() + .min(1, { message: 'Nomor telepon harus diisi' }) + .refine((val) => /^\d{10,12}$/.test(val), { + message: 'Format nomor telepon tidak valid, contoh: 081234567890', + }), + bankName: z.string().min(1, { message: 'Nama bank harus diisi' }), + accountName: z.string().min(1, { message: 'Nama rekening harus diisi' }), + accountNumber: z.string().min(1, { message: 'Nomor rekening harus diisi' }), + estimasi: z + .string() + .min(1, { message: 'Estimasi pemmbelian pertahun harus diisi' }), + tempoDuration: z.string().min(1, { message: 'Durasi tempo harus dipilih' }), + tempoLimit: z.string().min(1, { message: 'Limit tempo harus dipilih' }), + bersedia: z.string().min(1, { message: 'Harus dipilih' }), + categoryProduk: z + .string() + .min(1, { message: 'Category produk harus dipilih' }), +}); -- cgit v1.2.3 From ead46a6d760850530946926b390a8954ca64e1c2 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 17 Oct 2024 17:06:58 +0700 Subject: update pengajuan tempo --- .../register/stores/usePengajuanTempoStore.ts | 86 +++++++++++++++++++++- src-migrate/types/tempo.ts | 20 ++++- src-migrate/validations/tempo.ts | 30 ++++++++ 3 files changed, 133 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 6f3bc13d..8891e6ea 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -1,6 +1,6 @@ import { create } from 'zustand'; -import { TempoProps } from '~/types/tempo'; -import { TempoSchema } from '~/validations/tempo'; +import { TempoProps, TempoPropsKontakPerson } from '~/types/tempo'; +import { TempoSchema, TempoSchemaKontakPerson } from '~/validations/tempo'; import { boolean, ZodError } from 'zod'; type State = { @@ -91,3 +91,85 @@ export const usePengajuanTempoStore = create((set, get) => ({ }, }), })); + +type StateKontakPerson = { + form: TempoPropsKontakPerson; + errors: { + [key in keyof TempoPropsKontakPerson]?: string; + }; + isCheckedTNC: boolean; + isOpenTNC: boolean; + isValidCaptcha: boolean; +}; +export const usePengajuanTempoStoreKontakPerson = create< + StateKontakPerson & Action +>((set, get) => ({ + form: { + direkturName: '', + direkturMobile: '', + direkturEmail: '', + industry_id: '', + street: '', + state: '', + city: '', + zip: '', + bankName: '', + accountName: '', + accountNumber: '', + estimasi: '', + tempoDuration: '', + bersedia: '', + categoryProduk: '', + tempoLimit: '', + }, + updateForm: (name, value) => + set((state) => ({ form: { ...state.form, [name]: value } })), + + errors: {}, + validate: () => { + try { + TempoSchemaKontakPerson.parse(get().form); + set({ errors: {} }); + } catch (error) { + if (error instanceof ZodError) { + const errors: StateKontakPerson['errors'] = {}; + error.errors.forEach( + (e) => (errors[e.path[0] as keyof TempoPropsKontakPerson] = e.message) + ); + set({ errors }); + } + } + }, + + isCheckedTNC: false, + toggleCheckTNC: () => set((state) => ({ isCheckedTNC: !state.isCheckedTNC })), + + isOpenTNC: false, + openTNC: () => set(() => ({ isOpenTNC: true })), + closeTNC: () => set(() => ({ isOpenTNC: false })), + + isValidCaptcha: false, + updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })), + + resetForm: () => + set({ + form: { + direkturName: '', + direkturMobile: '', + direkturEmail: '', + industry_id: '', + street: '', + state: '', + city: '', + zip: '', + bankName: '', + accountName: '', + accountNumber: '', + estimasi: '', + tempoDuration: '', + bersedia: '', + categoryProduk: '', + tempoLimit: '', + }, + }), +})); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index f8a3c5b8..a4bd3d0a 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -1,4 +1,4 @@ -import { TempoSchema } from '~/validations/tempo'; +import { TempoSchema, TempoSchemaKontakPerson } from '~/validations/tempo'; import { OdooApiRes } from './odoo'; import { z } from 'zod'; @@ -18,9 +18,27 @@ export type tempoProps = { bersedia: string; }; +export type tempoPropsKontakPerson = { + direkturName: string; + direkturMobile: string; + direkturEmail: string; + industry_id: string; + street: string; + state: string; + city: string; + zip: string; + bankName: string; + accountName: string; + accountNumber: string; + estimasi: string; + tempoDuration: string; + bersedia: string; +}; + export type TempoApiProps = OdooApiRes; export type TempoProps = z.infer; +export type TempoPropsKontakPerson = z.infer; export type TempoResApiProps = { Tempo: boolean; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 6999c1c6..dca60869 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -26,3 +26,33 @@ export const TempoSchema = z.object({ .string() .min(1, { message: 'Category produk harus dipilih' }), }); +export const TempoSchemaKontakPerson = z.object({ + direkturName: z.string().min(1, { message: 'Nama harus diisi' }), + direkturMobile: z + .string() + .min(1, { message: 'Nomor telepon harus diisi' }) + .refine((val) => /^\d{10,12}$/.test(val), { + message: 'Format nomor telepon tidak valid, contoh: 081234567890', + }), + direkturEmail: z + .string() + .min(1, { message: 'Email harus diisi' }) + .email({ message: 'Email harus menggunakan format example@mail.com' }), + street: z.string().min(1, { message: 'Alamat harus diisi' }), + industry_id: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), + zip: z.string().min(1, { message: 'Kode pos harus diisi' }), + state: z.string().min(1, { message: 'Provinsi harus dipilih' }), + city: z.string().min(1, { message: 'Kota harus dipilih' }), + bankName: z.string().min(1, { message: 'Nama bank harus diisi' }), + accountName: z.string().min(1, { message: 'Nama rekening harus diisi' }), + accountNumber: z.string().min(1, { message: 'Nomor rekening harus diisi' }), + estimasi: z + .string() + .min(1, { message: 'Estimasi pemmbelian pertahun harus diisi' }), + tempoDuration: z.string().min(1, { message: 'Durasi tempo harus dipilih' }), + tempoLimit: z.string().min(1, { message: 'Limit tempo harus dipilih' }), + bersedia: z.string().min(1, { message: 'Harus dipilih' }), + categoryProduk: z + .string() + .min(1, { message: 'Category produk harus dipilih' }), +}); -- cgit v1.2.3 From 661d742193b62aeb3d2a2350433bdd3714667625 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 18 Oct 2024 10:39:40 +0700 Subject: add kontak perusahaan --- .../register/stores/usePengajuanTempoStore.ts | 89 +++++++++------------- src-migrate/types/tempo.ts | 16 ++-- src-migrate/validations/tempo.ts | 29 ++++--- 3 files changed, 54 insertions(+), 80 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 8891e6ea..247f62dd 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -93,83 +93,64 @@ export const usePengajuanTempoStore = create((set, get) => ({ })); type StateKontakPerson = { - form: TempoPropsKontakPerson; - errors: { + formKontakPerson: TempoPropsKontakPerson; + errorsKontakPerson: { [key in keyof TempoPropsKontakPerson]?: string; }; - isCheckedTNC: boolean; - isOpenTNC: boolean; - isValidCaptcha: boolean; +}; +type ActionKontakPerson = { + updateFormKontakPerson: (name: string, value: string) => void; + + validateKontakPerson: () => void; + resetFormKontakPerson: () => void; }; export const usePengajuanTempoStoreKontakPerson = create< - StateKontakPerson & Action + StateKontakPerson & ActionKontakPerson >((set, get) => ({ - form: { + formKontakPerson: { direkturName: '', direkturMobile: '', direkturEmail: '', - industry_id: '', - street: '', - state: '', - city: '', - zip: '', - bankName: '', - accountName: '', - accountNumber: '', - estimasi: '', - tempoDuration: '', - bersedia: '', - categoryProduk: '', - tempoLimit: '', + purchasingName: '', + purchasingEmail: '', + financeMobile: '', + financeName: '', + financeEmail: '', }, - updateForm: (name, value) => - set((state) => ({ form: { ...state.form, [name]: value } })), + updateFormKontakPerson: (name, value) => + set((state) => ({ + formKontakPerson: { ...state.formKontakPerson, [name]: value }, + })), - errors: {}, - validate: () => { + errorsKontakPerson: {}, + validateKontakPerson: () => { try { - TempoSchemaKontakPerson.parse(get().form); - set({ errors: {} }); + TempoSchemaKontakPerson.parse(get().formKontakPerson); + set({ errorsKontakPerson: {} }); } catch (error) { if (error instanceof ZodError) { - const errors: StateKontakPerson['errors'] = {}; + const errorsKontakPerson: StateKontakPerson['errorsKontakPerson'] = {}; error.errors.forEach( - (e) => (errors[e.path[0] as keyof TempoPropsKontakPerson] = e.message) + (e) => + (errorsKontakPerson[e.path[0] as keyof TempoPropsKontakPerson] = + e.message) ); - set({ errors }); + set({ errorsKontakPerson }); } } }, - isCheckedTNC: false, - toggleCheckTNC: () => set((state) => ({ isCheckedTNC: !state.isCheckedTNC })), - - isOpenTNC: false, - openTNC: () => set(() => ({ isOpenTNC: true })), - closeTNC: () => set(() => ({ isOpenTNC: false })), - - isValidCaptcha: false, - updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })), - - resetForm: () => + resetFormKontakPerson: () => set({ - form: { + formKontakPerson: { direkturName: '', direkturMobile: '', direkturEmail: '', - industry_id: '', - street: '', - state: '', - city: '', - zip: '', - bankName: '', - accountName: '', - accountNumber: '', - estimasi: '', - tempoDuration: '', - bersedia: '', - categoryProduk: '', - tempoLimit: '', + purchasingName: '', + purchasingEmail: '', + financeName: '', + financeMobile: '', + financeEmail: '', }, }), })); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index a4bd3d0a..fc920c05 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -22,17 +22,11 @@ export type tempoPropsKontakPerson = { direkturName: string; direkturMobile: string; direkturEmail: string; - industry_id: string; - street: string; - state: string; - city: string; - zip: string; - bankName: string; - accountName: string; - accountNumber: string; - estimasi: string; - tempoDuration: string; - bersedia: string; + purchasingName: string; + purchasingEmail: string; + financeMobile: string; + financeEmail: string; + financeName: string; }; export type TempoApiProps = OdooApiRes; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index dca60869..45cc8cd2 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -28,31 +28,30 @@ export const TempoSchema = z.object({ }); export const TempoSchemaKontakPerson = z.object({ direkturName: z.string().min(1, { message: 'Nama harus diisi' }), + financeName: z.string().min(1, { message: 'Nama harus diisi' }), direkturMobile: z .string() .min(1, { message: 'Nomor telepon harus diisi' }) .refine((val) => /^\d{10,12}$/.test(val), { message: 'Format nomor telepon tidak valid, contoh: 081234567890', }), + financeMobile: z + .string() + .min(1, { message: 'Nomor telepon harus diisi' }) + .refine((val) => /^\d{10,12}$/.test(val), { + message: 'Format nomor telepon tidak valid, contoh: 081234567890', + }), direkturEmail: z .string() .min(1, { message: 'Email harus diisi' }) .email({ message: 'Email harus menggunakan format example@mail.com' }), - street: z.string().min(1, { message: 'Alamat harus diisi' }), - industry_id: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), - zip: z.string().min(1, { message: 'Kode pos harus diisi' }), - state: z.string().min(1, { message: 'Provinsi harus dipilih' }), - city: z.string().min(1, { message: 'Kota harus dipilih' }), - bankName: z.string().min(1, { message: 'Nama bank harus diisi' }), - accountName: z.string().min(1, { message: 'Nama rekening harus diisi' }), - accountNumber: z.string().min(1, { message: 'Nomor rekening harus diisi' }), - estimasi: z + purchasingEmail: z .string() - .min(1, { message: 'Estimasi pemmbelian pertahun harus diisi' }), - tempoDuration: z.string().min(1, { message: 'Durasi tempo harus dipilih' }), - tempoLimit: z.string().min(1, { message: 'Limit tempo harus dipilih' }), - bersedia: z.string().min(1, { message: 'Harus dipilih' }), - categoryProduk: z + .min(1, { message: 'Email harus diisi' }) + .email({ message: 'Email harus menggunakan format example@mail.com' }), + financeEmail: z .string() - .min(1, { message: 'Category produk harus dipilih' }), + .min(1, { message: 'Email harus diisi' }) + .email({ message: 'Email harus menggunakan format example@mail.com' }), + purchasingName: z.string().min(1, { message: 'Nama harus diisi' }), }); -- cgit v1.2.3 From 87ffd2fa7edc240693ddd81401ef23c5cd1bbb3e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 18 Oct 2024 16:11:17 +0700 Subject: update fix kontak person --- src-migrate/modules/register/stores/usePengajuanTempoStore.ts | 2 ++ src-migrate/types/tempo.ts | 1 + src-migrate/validations/tempo.ts | 6 ++++++ 3 files changed, 9 insertions(+) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 247f62dd..7f1bcbb0 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -116,6 +116,7 @@ export const usePengajuanTempoStoreKontakPerson = create< financeMobile: '', financeName: '', financeEmail: '', + purchasingMobile: '', }, updateFormKontakPerson: (name, value) => set((state) => ({ @@ -151,6 +152,7 @@ export const usePengajuanTempoStoreKontakPerson = create< financeName: '', financeMobile: '', financeEmail: '', + purchasingMobile: '', }, }), })); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index fc920c05..85680cba 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -27,6 +27,7 @@ export type tempoPropsKontakPerson = { financeMobile: string; financeEmail: string; financeName: string; + purchasingMobile: string; }; export type TempoApiProps = OdooApiRes; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 45cc8cd2..756bb722 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -41,6 +41,12 @@ export const TempoSchemaKontakPerson = z.object({ .refine((val) => /^\d{10,12}$/.test(val), { message: 'Format nomor telepon tidak valid, contoh: 081234567890', }), + purchasingMobile: z + .string() + .min(1, { message: 'Nomor telepon harus diisi' }) + .refine((val) => /^\d{10,12}$/.test(val), { + message: 'Format nomor telepon tidak valid, contoh: 081234567890', + }), direkturEmail: z .string() .min(1, { message: 'Email harus diisi' }) -- cgit v1.2.3 From 548e2b48b1c2f6521037765f96083a8d79f611d6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 18 Oct 2024 17:08:55 +0700 Subject: add pengiriman section --- .../register/stores/usePengajuanTempoStore.ts | 71 +++++++++++++++++++++- src-migrate/types/tempo.ts | 13 +++- src-migrate/validations/tempo.ts | 9 +++ 3 files changed, 90 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 7f1bcbb0..0d397c78 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -1,6 +1,14 @@ import { create } from 'zustand'; -import { TempoProps, TempoPropsKontakPerson } from '~/types/tempo'; -import { TempoSchema, TempoSchemaKontakPerson } from '~/validations/tempo'; +import { + TempoProps, + TempoPropsKontakPerson, + TempoPropsPengiriman, +} from '~/types/tempo'; +import { + TempoSchema, + TempoSchemaKontakPerson, + TempoSchemaPengiriman, +} from '~/validations/tempo'; import { boolean, ZodError } from 'zod'; type State = { @@ -156,3 +164,62 @@ export const usePengajuanTempoStoreKontakPerson = create< }, }), })); + +type StatePengiriman = { + formPengiriman: TempoPropsPengiriman; + errorsPengiriman: { + [key in keyof TempoPropsPengiriman]?: string; + }; +}; +type ActionPengiriman = { + updateFormPengiriman: (name: string, value: string) => void; + + validatePengiriman: () => void; + resetFormPengiriman: () => void; +}; +export const usePengajuanTempoStorePengiriman = create< + StatePengiriman & ActionPengiriman +>((set, get) => ({ + formPengiriman: { + PICName: '', + streetPengiriman: '', + statePengiriman: '', + cityPengiriman: '', + zip: '', + invoicePic: '', + }, + updateFormPengiriman: (name, value) => + set((state) => ({ + formPengiriman: { ...state.formPengiriman, [name]: value }, + })), + + errorsPengiriman: {}, + validatePengiriman: () => { + try { + TempoSchemaPengiriman.parse(get().formPengiriman); + set({ errorsPengiriman: {} }); + } catch (error) { + if (error instanceof ZodError) { + const errorsPengiriman: StatePengiriman['errorsPengiriman'] = {}; + error.errors.forEach( + (e) => + (errorsPengiriman[e.path[0] as keyof TempoPropsPengiriman] = + e.message) + ); + set({ errorsPengiriman }); + } + } + }, + + resetFormPengiriman: () => + set({ + formPengiriman: { + PICName: '', + streetPengiriman: '', + statePengiriman: '', + cityPengiriman: '', + zip: '', + invoicePic: '', + }, + }), +})); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index 85680cba..6e3f2502 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -1,4 +1,8 @@ -import { TempoSchema, TempoSchemaKontakPerson } from '~/validations/tempo'; +import { + TempoSchema, + TempoSchemaKontakPerson, + TempoSchemaPengiriman, +} from '~/validations/tempo'; import { OdooApiRes } from './odoo'; import { z } from 'zod'; @@ -29,11 +33,18 @@ export type tempoPropsKontakPerson = { financeName: string; purchasingMobile: string; }; +export type tempoPropsPengiriman = { + PICName: string; + streetPengiriman: string; + statePengiriman: string; + cityPengiriman: string; +}; export type TempoApiProps = OdooApiRes; export type TempoProps = z.infer; export type TempoPropsKontakPerson = z.infer; +export type TempoPropsPengiriman = z.infer; export type TempoResApiProps = { Tempo: boolean; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 756bb722..7adfa780 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -26,6 +26,7 @@ export const TempoSchema = z.object({ .string() .min(1, { message: 'Category produk harus dipilih' }), }); + export const TempoSchemaKontakPerson = z.object({ direkturName: z.string().min(1, { message: 'Nama harus diisi' }), financeName: z.string().min(1, { message: 'Nama harus diisi' }), @@ -61,3 +62,11 @@ export const TempoSchemaKontakPerson = z.object({ .email({ message: 'Email harus menggunakan format example@mail.com' }), purchasingName: z.string().min(1, { message: 'Nama harus diisi' }), }); +export const TempoSchemaPengiriman = z.object({ + PICName: z.string().min(1, { message: 'Nama harus diisi' }), + streetPengiriman: z.string().min(1, { message: 'Alamat harus diisi' }), + statePengiriman: z.string().min(1, { message: 'Provinsi harus dipilih' }), + cityPengiriman: z.string().min(1, { message: 'Kota harus dipilih' }), + zip: z.string().min(1, { message: 'Kode pos harus diisi' }), + invoicePic: z.string().min(1, { message: 'Nama pic invoice harus diisi' }), +}); -- cgit v1.2.3 From c61477111b95d83a9b862f242923b911364f3612 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 19 Oct 2024 11:49:38 +0700 Subject: fix section pengiriman --- .../register/stores/usePengajuanTempoStore.ts | 37 ++++++++++++++++++++++ src-migrate/types/tempo.ts | 21 ++++++++++++ src-migrate/validations/tempo.ts | 25 +++++++++++++++ 3 files changed, 83 insertions(+) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 0d397c78..e531c3d0 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -187,6 +187,24 @@ export const usePengajuanTempoStorePengiriman = create< cityPengiriman: '', zip: '', invoicePic: '', + streetInvoice: '', + stateInvoice: '', + cityInvoice: '', + everyWeekday: false, + everyWeekdayInput: '', + everyWeek: false, + everyWeekInput: '', + tukarInvoice: false, + tukarInvoiceInput: '', + everyWeekdayPembayaran: false, + everyWeekdayInputPembayaran: '', + everyWeekPembayaran: false, + everyWeekInputPembayaran: '', + tukarInvoicePembayaran: false, + tukarInvoiceInputPembayaran: '', + dokumenPengiriman: '', + dokumenPengirimanInput: '', + dokumenPengirimanInvoice: '', }, updateFormPengiriman: (name, value) => set((state) => ({ @@ -220,6 +238,25 @@ export const usePengajuanTempoStorePengiriman = create< cityPengiriman: '', zip: '', invoicePic: '', + streetInvoice: '', + stateInvoice: '', + cityInvoice: '', + everyWeekday: false, + everyWeekdayInput: '', + everyWeek: false, + everyWeekInput: '', + tukarInvoice: false, + tukarInvoiceInput: '', + everyWeekdayPembayaran: false, + everyWeekdayInputPembayaran: '', + everyWeekPembayaran: false, + everyWeekInputPembayaran: '', + tukarInvoicePembayaran: false, + tukarInvoiceInputPembayaran: '', + dokumenPengiriman: '', + dokumenPengirimanInput: '', + dokumenPengirimanInvoice: '', + dokumenPengirimanInvoiceInput: '', }, }), })); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index 6e3f2502..b40ef8d7 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -38,6 +38,27 @@ export type tempoPropsPengiriman = { streetPengiriman: string; statePengiriman: string; cityPengiriman: string; + streetInvoice: string; + zip: string; + invoicePic: string; + stateInvoice: string; + cityInvoice: string; + everyWeekday: boolean; + everyWeekdayInput: string; + everyWeek: boolean; + everyWeekInput: string; + tukarInvoice: boolean; + tukarInvoiceInput: string; + everyWeekdayPembayaran: boolean; + everyWeekdayInputPembayaran: string; + everyWeekPembayaran: boolean; + everyWeekInputPembayaran: string; + tukarInvoicePembayaran: boolean; + tukarInvoiceInputPembayaran: string; + dokumenPengiriman: string; + dokumenPengirimanInput: string; + dokumenPengirimanInvoice: string; + dokumenPengirimanInvoiceInput: string; }; export type TempoApiProps = OdooApiRes; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 7adfa780..9a0df8bb 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -69,4 +69,29 @@ export const TempoSchemaPengiriman = z.object({ cityPengiriman: z.string().min(1, { message: 'Kota harus dipilih' }), zip: z.string().min(1, { message: 'Kode pos harus diisi' }), invoicePic: z.string().min(1, { message: 'Nama pic invoice harus diisi' }), + streetInvoice: z.string().min(1, { message: 'Alamat invoice harus diisi' }), + stateInvoice: z + .string() + .min(1, { message: 'Provinsi invoice harus dipilih' }), + cityInvoice: z.string().min(1, { message: 'Kota invoice harus dipilih' }), + everyWeekday: z.boolean().optional(), + everyWeekdayInput: z.string().optional(), + everyWeek: z.boolean().optional(), + everyWeekInput: z.string().optional(), + tukarInvoice: z.boolean().optional(), + tukarInvoiceInput: z.string().optional(), + everyWeekdayPembayaran: z.boolean().optional(), + everyWeekdayInputPembayaran: z.string().optional(), + everyWeekPembayaran: z.boolean().optional(), + everyWeekInputPembayaran: z.string().optional(), + tukarInvoicePembayaran: z.boolean().optional(), + tukarInvoiceInputPembayaran: z.string().optional(), + dokumenPengiriman: z.string().min(1, { + message: 'dokumen lampiran saat pengiriman barang harus dipilih', + }), + dokumenPengirimanInput: z.string().optional(), + dokumenPengirimanInvoice: z.string().min(1, { + message: 'dokumen lampiran saat pengiriman barang harus dipilih', + }), + dokumenPengirimanInvoiceInput: z.string().optional(), }); -- cgit v1.2.3 From 3a0f3c6ed7ef886d3205d51937b1ecbb035b1a87 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 21 Oct 2024 16:16:34 +0700 Subject: update and fix section dokumen --- .../register/stores/usePengajuanTempoStore.ts | 41 ++++++++++++++++++++++ src-migrate/types/tempo.ts | 9 +++++ src-migrate/validations/tempo.ts | 12 +++++++ 3 files changed, 62 insertions(+) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index e531c3d0..08053e42 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -3,11 +3,13 @@ import { TempoProps, TempoPropsKontakPerson, TempoPropsPengiriman, + TempoPropsSupplier, } from '~/types/tempo'; import { TempoSchema, TempoSchemaKontakPerson, TempoSchemaPengiriman, + TempoSchemaSupplier, } from '~/validations/tempo'; import { boolean, ZodError } from 'zod'; @@ -260,3 +262,42 @@ export const usePengajuanTempoStorePengiriman = create< }, }), })); + +type StateSupplier = { + formSupplier: TempoPropsSupplier[]; + errorsSupplier: { + [key in keyof TempoPropsSupplier]?: string; + }; +}; +type ActionSupplier = { + updateFormSupplier: (data: TempoPropsSupplier[]) => void; + + validateSupplier: () => void; +}; +export const usePengajuanTempoStoreSupplier = create< + StateSupplier & ActionSupplier +>((set, get) => ({ + formSupplier: [], + updateFormSupplier: (data) => { + set(() => ({ + formSupplier: data, // Menyimpan data baru ke dalam formSupplier + })); + }, + + errorsSupplier: {}, + validateSupplier: () => { + // try { + // TempoSchemaSupplier.parse(get().formSupplier); + // set({ errorsSupplier: {} }); + // } catch (error) { + // if (error instanceof ZodError) { + // const errorsSupplier: StateSupplier['errorsSupplier'] = {}; + // error.errors.forEach( + // (e) => + // (errorsSupplier[e.path[0] as keyof TempoPropsSupplier] = e.message) + // ); + // set({ errorsSupplier }); + // } + // } + }, +})); diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index b40ef8d7..17c4c906 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -2,6 +2,7 @@ import { TempoSchema, TempoSchemaKontakPerson, TempoSchemaPengiriman, + TempoSchemaSupplier, } from '~/validations/tempo'; import { OdooApiRes } from './odoo'; import { z } from 'zod'; @@ -60,12 +61,20 @@ export type tempoPropsPengiriman = { dokumenPengirimanInvoice: string; dokumenPengirimanInvoiceInput: string; }; +export type tempoPropsSupplier = { + supplier: string; + pic: string; + telepon: string; + durasiTempo: string; + creditLimit: string; +}; export type TempoApiProps = OdooApiRes; export type TempoProps = z.infer; export type TempoPropsKontakPerson = z.infer; export type TempoPropsPengiriman = z.infer; +export type TempoPropsSupplier = z.infer; export type TempoResApiProps = { Tempo: boolean; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 9a0df8bb..86bcf6d1 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -95,3 +95,15 @@ export const TempoSchemaPengiriman = z.object({ }), dokumenPengirimanInvoiceInput: z.string().optional(), }); +export const TempoSchemaSupplier = z.object({ + supplier: z.string().min(1, { message: 'Nama supplier harus diisi' }), + pic: z.string().min(1, { message: 'Nama PIC harus diisi' }), + telepon: z + .string() + .min(1, { message: 'Nomor telepon harus diisi' }) + .refine((val) => /^\d{10,12}$/.test(val), { + message: 'Format nomor telepon tidak valid, contoh: 081234567890', + }), + durasiTempo: z.string().min(1, { message: 'Durasi tempo harus diisi' }), + creditLimit: z.string().min(1, { message: 'Limit Kredit harus diisi' }), +}); -- cgit v1.2.3 From d6ede238658d90315a5dc5b864f20037e8a776f6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 22 Oct 2024 11:24:43 +0700 Subject: update & add section dokumen --- .../register/stores/usePengajuanTempoStore.ts | 89 ++++++++++++++++++++++ src-migrate/types/tempo.ts | 13 ++++ src-migrate/validations/tempo.ts | 47 ++++++++++++ 3 files changed, 149 insertions(+) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 08053e42..9c97b8a0 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -4,12 +4,14 @@ import { TempoPropsKontakPerson, TempoPropsPengiriman, TempoPropsSupplier, + TempoPropsDokumen, } from '~/types/tempo'; import { TempoSchema, TempoSchemaKontakPerson, TempoSchemaPengiriman, TempoSchemaSupplier, + TempoSchemaDokumen, } from '~/validations/tempo'; import { boolean, ZodError } from 'zod'; @@ -262,6 +264,93 @@ export const usePengajuanTempoStorePengiriman = create< }, }), })); +type StateDokumen = { + formDokumen: TempoPropsDokumen; + errorsDokumen: { + [key in keyof TempoPropsDokumen]?: string; + }; +}; +type ActionDokumen = { + updateFormDokumen: ( + name: string, + fileName: string, + fileFormat: string, + value: string + ) => void; + + validateDokumen: () => void; + resetFormDokumen: () => void; + getJumlahDokumenDiisi: () => void; +}; +export const usePengajuanTempoStoreDokumen = create< + StateDokumen & ActionDokumen +>((set, get) => ({ + formDokumen: { + dokumenNib: { name: '', format: '', base64: '' }, + dokumenNpwp: { name: '', format: '', base64: '' }, + dokumenSppkp: { name: '', format: '', base64: '' }, + dokumenAktaPerubahan: { name: '', format: '', base64: '' }, + dokumenKtpDirut: { name: '', format: '', base64: '' }, + dokumenAktaPendirian: { name: '', format: '', base64: '' }, + dokumenLaporanKeuangan: { name: '', format: '', base64: '' }, + dokumenFotoKantor: { name: '', format: '', base64: '' }, + dokumenTempatBekerja: { name: '', format: '', base64: '' }, + }, + + // Memperbarui dokumen dengan name, format, dan base64 + updateFormDokumen: (name, fileName, fileFormat, value) => + set((state) => ({ + formDokumen: { + ...state.formDokumen, + [name]: { + name: fileName, + format: fileFormat, + base64: value, + }, + }, + })), + + errorsDokumen: {}, + validateDokumen: () => { + try { + TempoSchemaDokumen.parse(get().formDokumen); + set({ errorsDokumen: {} }); + } catch (error) { + if (error instanceof ZodError) { + const errorsDokumen: StateDokumen['errorsDokumen'] = {}; + error.errors.forEach( + (e) => + (errorsDokumen[e.path[0] as keyof TempoPropsDokumen] = e.message) + ); + set({ errorsDokumen }); + } + } + }, + + getJumlahDokumenDiisi: () => { + const formDokumen = get().formDokumen; + // Menghitung jumlah field yang base64 tidak kosong + const jumlahTerisi = Object.values(formDokumen).filter( + (dokumen) => dokumen.base64 !== '' + ).length; + return jumlahTerisi; + }, + + resetFormDokumen: () => + set({ + formDokumen: { + dokumenNib: { name: '', format: '', base64: '' }, + dokumenNpwp: { name: '', format: '', base64: '' }, + dokumenSppkp: { name: '', format: '', base64: '' }, + dokumenAktaPerubahan: { name: '', format: '', base64: '' }, + dokumenKtpDirut: { name: '', format: '', base64: '' }, + dokumenAktaPendirian: { name: '', format: '', base64: '' }, + dokumenLaporanKeuangan: { name: '', format: '', base64: '' }, + dokumenFotoKantor: { name: '', format: '', base64: '' }, + dokumenTempatBekerja: { name: '', format: '', base64: '' }, + }, + }), +})); type StateSupplier = { formSupplier: TempoPropsSupplier[]; diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index 17c4c906..d928d9c3 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -3,6 +3,7 @@ import { TempoSchemaKontakPerson, TempoSchemaPengiriman, TempoSchemaSupplier, + TempoSchemaDokumen, } from '~/validations/tempo'; import { OdooApiRes } from './odoo'; import { z } from 'zod'; @@ -68,6 +69,17 @@ export type tempoPropsSupplier = { durasiTempo: string; creditLimit: string; }; +export type tempoPropsDokumen = { + dokumenNib: { name: string; format: string; base64: string }; + dokumenNpwp: { name: string; format: string; base64: string }; + dokumenSppkp: { name: string; format: string; base64: string }; + dokumenAktaPerubahan: { name: string; format: string; base64: string }; + dokumenKtpDirut: { name: string; format: string; base64: string }; + dokumenAktaPendirian: { name: string; format: string; base64: string }; + dokumenLaporanKeuangan: { name: string; format: string; base64: string }; + dokumenFotoKantor: { name: string; format: string; base64: string }; + dokumenTempatBekerja: { name: string; format: string; base64: string }; +}; export type TempoApiProps = OdooApiRes; @@ -75,6 +87,7 @@ export type TempoProps = z.infer; export type TempoPropsKontakPerson = z.infer; export type TempoPropsPengiriman = z.infer; export type TempoPropsSupplier = z.infer; +export type TempoPropsDokumen = z.infer; export type TempoResApiProps = { Tempo: boolean; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 86bcf6d1..ccef8d83 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -107,3 +107,50 @@ export const TempoSchemaSupplier = z.object({ durasiTempo: z.string().min(1, { message: 'Durasi tempo harus diisi' }), creditLimit: z.string().min(1, { message: 'Limit Kredit harus diisi' }), }); +export const TempoSchemaDokumen = z.object({ + dokumenNib: z.object({ + name: z.string().min(1, { message: 'Nama file harus diisi' }), + format: z.string().min(1, { message: 'Format file harus diisi' }), + base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + }), + dokumenNpwp: z.object({ + name: z.string().min(1, { message: 'Nama file harus diisi' }), + format: z.string().min(1, { message: 'Format file harus diisi' }), + base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + }), + dokumenSppkp: z.object({ + name: z.string().optional(), + format: z.string().optional(), + base64: z.string().optional(), + }), + dokumenAktaPerubahan: z.object({ + name: z.string().optional(), + format: z.string().optional(), + base64: z.string().optional(), + }), + dokumenKtpDirut: z.object({ + name: z.string().optional(), + format: z.string().optional(), + base64: z.string().optional(), + }), + dokumenAktaPendirian: z.object({ + name: z.string().optional(), + format: z.string().optional(), + base64: z.string().optional(), + }), + dokumenLaporanKeuangan: z.object({ + name: z.string().optional(), + format: z.string().optional(), + base64: z.string().optional(), + }), + dokumenFotoKantor: z.object({ + name: z.string().min(1, { message: 'Nama file harus diisi' }), + format: z.string().min(1, { message: 'Format file harus diisi' }), + base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + }), + dokumenTempatBekerja: z.object({ + name: z.string().min(1, { message: 'Nama file harus diisi' }), + format: z.string().min(1, { message: 'Format file harus diisi' }), + base64: z.string().min(1, { message: 'Dokumen harus diisi' }), + }), +}); -- cgit v1.2.3 From c19c7eee924b70d25cb47d40fd7c8e00d5efa867 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 23 Oct 2024 17:07:37 +0700 Subject: update pengajuan tempo section konfirmasi --- src-migrate/modules/register/stores/usePengajuanTempoStore.ts | 2 ++ src-migrate/types/tempo.ts | 1 + src-migrate/validations/tempo.ts | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 9c97b8a0..e09639db 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -191,6 +191,7 @@ export const usePengajuanTempoStorePengiriman = create< cityPengiriman: '', zip: '', invoicePic: '', + isSameAddrees: '', streetInvoice: '', stateInvoice: '', cityInvoice: '', @@ -245,6 +246,7 @@ export const usePengajuanTempoStorePengiriman = create< streetInvoice: '', stateInvoice: '', cityInvoice: '', + isSameAddrees: '', everyWeekday: false, everyWeekdayInput: '', everyWeek: false, diff --git a/src-migrate/types/tempo.ts b/src-migrate/types/tempo.ts index d928d9c3..815a7557 100644 --- a/src-migrate/types/tempo.ts +++ b/src-migrate/types/tempo.ts @@ -43,6 +43,7 @@ export type tempoPropsPengiriman = { streetInvoice: string; zip: string; invoicePic: string; + isSameAddrees: string; stateInvoice: string; cityInvoice: string; everyWeekday: boolean; diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index ccef8d83..66535fc4 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -73,6 +73,7 @@ export const TempoSchemaPengiriman = z.object({ stateInvoice: z .string() .min(1, { message: 'Provinsi invoice harus dipilih' }), + isSameAddrees: z.string(), cityInvoice: z.string().min(1, { message: 'Kota invoice harus dipilih' }), everyWeekday: z.boolean().optional(), everyWeekdayInput: z.string().optional(), @@ -119,9 +120,9 @@ export const TempoSchemaDokumen = z.object({ base64: z.string().min(1, { message: 'Dokumen harus diisi' }), }), dokumenSppkp: z.object({ - name: z.string().optional(), - format: z.string().optional(), - base64: z.string().optional(), + name: z.string().min(1, { message: 'Nama file harus diisi' }), + format: z.string().min(1, { message: 'Format file harus diisi' }), + base64: z.string().min(1, { message: 'Dokumen harus diisi' }), }), dokumenAktaPerubahan: z.object({ name: z.string().optional(), -- 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)} >
Date: Tue, 29 Oct 2024 16:22:33 +0700 Subject: updarte pengajuan tempo --- src-migrate/modules/register/stores/usePengajuanTempoStore.ts | 4 ++-- src-migrate/validations/tempo.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index e09639db..be5a3e45 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -189,7 +189,7 @@ export const usePengajuanTempoStorePengiriman = create< streetPengiriman: '', statePengiriman: '', cityPengiriman: '', - zip: '', + zipPengiriman: '', invoicePic: '', isSameAddrees: '', streetInvoice: '', @@ -241,7 +241,7 @@ export const usePengajuanTempoStorePengiriman = create< streetPengiriman: '', statePengiriman: '', cityPengiriman: '', - zip: '', + zipPengiriman: '', invoicePic: '', streetInvoice: '', stateInvoice: '', diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 66535fc4..7f02019c 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -67,7 +67,7 @@ export const TempoSchemaPengiriman = z.object({ streetPengiriman: z.string().min(1, { message: 'Alamat harus diisi' }), statePengiriman: z.string().min(1, { message: 'Provinsi harus dipilih' }), cityPengiriman: z.string().min(1, { message: 'Kota harus dipilih' }), - zip: z.string().min(1, { message: 'Kode pos harus diisi' }), + zipPengiriman: z.string().min(1, { message: 'Kode pos harus diisi' }), invoicePic: z.string().min(1, { message: 'Nama pic invoice harus diisi' }), streetInvoice: z.string().min(1, { message: 'Alamat invoice harus diisi' }), stateInvoice: z -- cgit v1.2.3 From b5701645ce23deed5e32afc4a0f98bd523c6c92c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 31 Oct 2024 13:58:23 +0700 Subject: update pengajuan tempo --- .../register/stores/usePengajuanTempoStore.ts | 28 ++++++++-------------- 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index be5a3e45..47168a2a 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -355,6 +355,7 @@ export const usePengajuanTempoStoreDokumen = create< })); type StateSupplier = { + hasSavedata: boolean; formSupplier: TempoPropsSupplier[]; errorsSupplier: { [key in keyof TempoPropsSupplier]?: string; @@ -362,33 +363,24 @@ type StateSupplier = { }; type ActionSupplier = { updateFormSupplier: (data: TempoPropsSupplier[]) => void; - + updateHasSave: (data: boolean) => void; validateSupplier: () => void; }; export const usePengajuanTempoStoreSupplier = create< StateSupplier & ActionSupplier >((set, get) => ({ formSupplier: [], + hasSavedata: false, updateFormSupplier: (data) => { set(() => ({ - formSupplier: data, // Menyimpan data baru ke dalam formSupplier + formSupplier: data, })); }, - - errorsSupplier: {}, - validateSupplier: () => { - // try { - // TempoSchemaSupplier.parse(get().formSupplier); - // set({ errorsSupplier: {} }); - // } catch (error) { - // if (error instanceof ZodError) { - // const errorsSupplier: StateSupplier['errorsSupplier'] = {}; - // error.errors.forEach( - // (e) => - // (errorsSupplier[e.path[0] as keyof TempoPropsSupplier] = e.message) - // ); - // set({ errorsSupplier }); - // } - // } + updateHasSave: (data) => { + set(() => ({ + hasSavedata: data, + })); }, + errorsSupplier: {}, + validateSupplier: () => {}, })); -- cgit v1.2.3 From 6bbf1dbd94355f34f58f4b72f134f3dbeac776aa Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 23 Nov 2024 11:55:59 +0700 Subject: update tempo --- src-migrate/modules/register/stores/usePengajuanTempoStore.ts | 6 ++++-- src-migrate/validations/tempo.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 47168a2a..39508158 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -38,7 +38,7 @@ type Action = { export const usePengajuanTempoStore = create((set, get) => ({ form: { name: '', - industry_id: '', + industryId: '', street: '', state: '', city: '', @@ -86,7 +86,7 @@ export const usePengajuanTempoStore = create((set, get) => ({ set({ form: { name: '', - industry_id: '', + industryId: '', street: '', state: '', city: '', @@ -192,6 +192,7 @@ export const usePengajuanTempoStorePengiriman = create< zipPengiriman: '', invoicePic: '', isSameAddrees: '', + isSameAddreesStreet: '', streetInvoice: '', stateInvoice: '', cityInvoice: '', @@ -247,6 +248,7 @@ export const usePengajuanTempoStorePengiriman = create< stateInvoice: '', cityInvoice: '', isSameAddrees: '', + isSameAddreesStreet: '', everyWeekday: false, everyWeekdayInput: '', everyWeek: false, diff --git a/src-migrate/validations/tempo.ts b/src-migrate/validations/tempo.ts index 7f02019c..cb2b279d 100644 --- a/src-migrate/validations/tempo.ts +++ b/src-migrate/validations/tempo.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; export const TempoSchema = z.object({ name: z.string().min(1, { message: 'Nama harus diisi' }), street: z.string().min(1, { message: 'Alamat harus diisi' }), - industry_id: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), + industryId: z.string().min(1, { message: 'Jenis usaha harus dipilih' }), zip: z.string().min(1, { message: 'Kode pos harus diisi' }), state: z.string().min(1, { message: 'Provinsi harus dipilih' }), city: z.string().min(1, { message: 'Kota harus dipilih' }), @@ -74,6 +74,7 @@ export const TempoSchemaPengiriman = z.object({ .string() .min(1, { message: 'Provinsi invoice harus dipilih' }), isSameAddrees: z.string(), + isSameAddreesStreet: z.string(), cityInvoice: z.string().min(1, { message: 'Kota invoice harus dipilih' }), everyWeekday: z.boolean().optional(), everyWeekdayInput: z.string().optional(), -- cgit v1.2.3 From 494909f40b918e4273d6258a74f12ac42253a4a7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 25 Nov 2024 17:04:51 +0700 Subject: pengajuan tempo --- src-migrate/modules/register/stores/usePengajuanTempoStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts index 39508158..8e2436a2 100644 --- a/src-migrate/modules/register/stores/usePengajuanTempoStore.ts +++ b/src-migrate/modules/register/stores/usePengajuanTempoStore.ts @@ -358,13 +358,13 @@ export const usePengajuanTempoStoreDokumen = create< type StateSupplier = { hasSavedata: boolean; - formSupplier: TempoPropsSupplier[]; + formSupplier: []; errorsSupplier: { [key in keyof TempoPropsSupplier]?: string; }; }; type ActionSupplier = { - updateFormSupplier: (data: TempoPropsSupplier[]) => void; + updateFormSupplier: (data: []) => void; updateHasSave: (data: boolean) => void; validateSupplier: () => void; }; -- cgit v1.2.3 From ddb82d97f794d59d846aa9b7c3d1dd1eff9cb9a9 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 29 Nov 2024 16:31:58 +0700 Subject: ppn 12 persen --- src-migrate/modules/cart/components/Summary.tsx | 3 ++- src-migrate/modules/cart/stores/useCartStore.ts | 14 +++++++++----- .../modules/product-card/components/ProductCard.tsx | 3 ++- .../modules/product-detail/components/PriceAction.tsx | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/cart/components/Summary.tsx b/src-migrate/modules/cart/components/Summary.tsx index 2e55c8df..0af5ab18 100644 --- a/src-migrate/modules/cart/components/Summary.tsx +++ b/src-migrate/modules/cart/components/Summary.tsx @@ -25,6 +25,7 @@ const CartSummary = ({ grandTotal, isLoaded = false, }: Props) => { + const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; return ( <>
Ringkasan Pesanan
@@ -50,7 +51,7 @@ const CartSummary = ({ - Tax 11% + Tax {((PPN - 1) * 100).toFixed(0)}% Rp {formatCurrency(tax || 0)} diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts index c2ebf50f..e7d2cdd3 100644 --- a/src-migrate/modules/cart/stores/useCartStore.ts +++ b/src-migrate/modules/cart/stores/useCartStore.ts @@ -43,17 +43,20 @@ export const useCartStore = create((set, get) => ({ updateCartItem: (updatedCart) => { const cart = get().cart; if (!cart) return; - + set({ cart: updatedCart }); const summary = computeSummary(updatedCart); set({ summary }); }, - + })); const computeSummary = (cart: CartProps) => { let subtotal = 0; let discount = 0; + + const PPN: number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; + for (const item of cart?.products) { if (!item.selected) continue; @@ -67,8 +70,9 @@ const computeSummary = (cart: CartProps) => { discount += price - item.price.price_discount * item.quantity; } let total = subtotal - discount; - let tax = Math.round(total * 0.11); - let grandTotal = total + tax; + let grandTotal = total * PPN; + let tax = grandTotal - total; + // let grandTotal = total + tax; - return { subtotal, discount, total, tax, grandTotal }; + return { subtotal, discount, total, grandTotal, tax }; }; \ No newline at end of file diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx index a439cdc8..8d3b55fb 100644 --- a/src-migrate/modules/product-card/components/ProductCard.tsx +++ b/src-migrate/modules/product-card/components/ProductCard.tsx @@ -16,6 +16,7 @@ type Props = { layout?: 'vertical' | 'horizontal'; }; +const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; const ProductCard = ({ product, layout = 'vertical' }: Props) => { const utmSource = useUtmSource(); const { isDesktop, isMobile } = useDevice(); @@ -127,7 +128,7 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
Inc PPN: Rp{' '} - {formatCurrency(Math.round(product.lowest_price.price * 1.11))} + {formatCurrency(Math.round(product.lowest_price.price * PPN))}
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 0b27b1b3..9348bbfb 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -17,6 +17,7 @@ type Props = { product: IProductDetail; }; +const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; const PriceAction = ({ product }: Props) => { const { activePrice, @@ -101,7 +102,7 @@ const PriceAction = ({ product }: Props) => {
Termasuk PPN: Rp{' '} - {formatCurrency(Math.round(activePrice.price_discount * 1.11))} + {formatCurrency(Math.round(activePrice.price_discount * PPN))}
)} -- cgit v1.2.3 From 77f9843ad5072583cb1797d7ecf5ac80394bad3f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 2 Dec 2024 09:31:44 +0700 Subject: pengajuan tempo --- src-migrate/types/auth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src-migrate') diff --git a/src-migrate/types/auth.ts b/src-migrate/types/auth.ts index 8feac2e1..1b400e95 100644 --- a/src-migrate/types/auth.ts +++ b/src-migrate/types/auth.ts @@ -20,7 +20,8 @@ export type AuthProps = { onlyReadyStock: boolean; soApproval: boolean; }; - partner_tempo: boolean; + partner_tempo: string; + tempo_progres: string; }; export type AuthApiProps = OdooApiRes; -- cgit v1.2.3 From 9a49b8d84761781531cb417731cb9ef802f63541 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 4 Dec 2024 10:59:21 +0700 Subject: update pengajuan tempo --- src-migrate/modules/register/index.tsx | 5 +++-- src-migrate/validations/tempo.ts | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/index.tsx b/src-migrate/modules/register/index.tsx index da41fd8b..2cc8a28b 100644 --- a/src-migrate/modules/register/index.tsx +++ b/src-migrate/modules/register/index.tsx @@ -161,7 +161,7 @@ const Register = () => { )}
- + {/* */}