From 930919a6f99626436bf2e24aa0ee2b0566808a88 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Mon, 11 Aug 2025 13:53:36 +0700 Subject: (andri) add iframe embed tutorial pengajuan tempo --- src/lib/pengajuan-tempo/component/FinishTempo.jsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/lib') diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index aacb9ef3..84c80e60 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -111,6 +111,26 @@ const FinishTempo = ({ query }) => { : 'Kembali Ke Beranda'} + {/* Video panduan khusus tampil saat status switch-account */} + {query?.status === 'switch-account' && ( +
+
+

Agar tidak bingung saat mengubah akun,

+

Yuk pelajari dulu langkah-langkah pengajuan tempo lewat video berikut

+
+
+ +
+
+ )} ); }; -- cgit v1.2.3 From 7647104348478302778c0afbd3a3d1b2637bc03b Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Mon, 11 Aug 2025 15:35:25 +0700 Subject: (andri) set true checklist ubah ke akun bisnis --- src/lib/pengajuan-tempo/component/FinishTempo.jsx | 58 +++++++++++++++-------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'src/lib') diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index 84c80e60..9d912b1a 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -8,6 +8,7 @@ import useAuth from '@/core/hooks/useAuth'; import axios from 'axios'; import { toast } from 'react-hot-toast'; import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; +import { useRouter } from 'next/router'; const FinishTempo = ({ query }) => { const [data, setData] = useState(); @@ -15,6 +16,8 @@ const FinishTempo = ({ query }) => { const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); const so_order = query?.order_id?.replaceAll('-', '/'); + const router = useRouter(); + useEffect(() => { const fetchData = async () => { const fetchedData = await odooApi( @@ -26,6 +29,14 @@ const FinishTempo = ({ query }) => { fetchData(); }, [query]); + // Handler khusus untuk tombol Ubah Akun + const handleSwitchAccountClick = () => { + // Set flag di localStorage + localStorage.setItem('autoCheckProfile', 'true'); + // Navigate tanpa query param ke halaman profile + router.push('/my/profile'); + }; + return (
{ {query?.status == 'approve' && 'Proses pengajuan tempo anda sudah berhasil terdaftar di indoteknik.com. Nikmati pembelian anda di website indoteknik dengan menggunakan pembayaran tempo'}
- - {query?.status === 'switch-account' - ? 'Ubah Akun' - : query?.status === 'approve' - ? 'Lihat Detail Tempo' - : 'Kembali Ke Beranda'} - - + + {/* Tombol dengan behavior berbeda jika status switch-account */} + {query?.status === 'switch-account' ? ( + + ) : ( + + {query?.status === 'approve' + ? 'Lihat Detail Tempo' + : 'Kembali Ke Beranda'} + + + )} + {/* Video panduan khusus tampil saat status switch-account */} {query?.status === 'switch-account' && ( -
-
+
+

Agar tidak bingung saat mengubah akun,

Yuk pelajari dulu langkah-langkah pengajuan tempo lewat video berikut

-- cgit v1.2.3 From dd0c699d8a866b53b962f92f98939ebb527dded0 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Mon, 11 Aug 2025 15:56:53 +0700 Subject: (andri) fix layout --- src/lib/pengajuan-tempo/component/FinishTempo.jsx | 55 +++++++++++++---------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/lib') diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index 9d912b1a..ad8a7e67 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -106,11 +106,41 @@ const FinishTempo = ({ query }) => { 'Proses pengajuan tempo anda sudah berhasil terdaftar di indoteknik.com. Nikmati pembelian anda di website indoteknik dengan menggunakan pembayaran tempo'}
+
+ + {/* Video panduan khusus tampil saat status switch-account */} + {query?.status === 'switch-account' && ( +
+
+

+ Video Panduan Pengajuan Tempo +

+
+
+ +
+
+ )} + {/* Tombol dengan behavior berbeda jika status switch-account */} {query?.status === 'switch-account' ? (
); }; -- cgit v1.2.3 From c527fa8fe9772b456a11a52f52c7ee091504d734 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Tue, 12 Aug 2025 17:31:31 +0700 Subject: (andri) fix switch account ke bisnis --- src/lib/auth/api/editPersonalProfileApi.js | 2 +- src/lib/auth/api/switchAccountApi.js | 2 +- src/lib/auth/components/SwitchAccount.jsx | 67 +++++++++++++++------- .../pengajuan-tempo/api/createPengajuanTempoApi.js | 2 +- 4 files changed, 48 insertions(+), 25 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/api/editPersonalProfileApi.js b/src/lib/auth/api/editPersonalProfileApi.js index 39cd44c1..90bda114 100644 --- a/src/lib/auth/api/editPersonalProfileApi.js +++ b/src/lib/auth/api/editPersonalProfileApi.js @@ -3,7 +3,7 @@ import { getAuth } from '@/core/utils/auth' const editPersonalProfileApi = async ({ data }) => { const auth = getAuth() - const dataProfile = await odooApi('PUT', `/api/v1/user/${auth.id}`, data) + const dataProfile = await odooApi('POST', `/api/v1/user/${auth.id}`, data) return dataProfile } diff --git a/src/lib/auth/api/switchAccountApi.js b/src/lib/auth/api/switchAccountApi.js index 79ca2553..f62693f6 100644 --- a/src/lib/auth/api/switchAccountApi.js +++ b/src/lib/auth/api/switchAccountApi.js @@ -4,7 +4,7 @@ import { getAuth } from '@/core/utils/auth'; const switchAccountApi = async ({ data }) => { const auth = getAuth(); const switchAccount = await odooApi( - 'PUT', + 'POST', `/api/v1/user/${auth.partnerId}/switch`, data ); diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index 46e57348..80bc584f 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -13,6 +13,7 @@ import { useRegisterStore } from '~/modules/register/stores/useRegisterStore.ts' import { registerUser } from '~/services/auth'; import { useMutation } from 'react-query'; import { isValid } from 'zod'; +import Spinner from "@/core/components/elements/Spinner/LogoSpinner"; import useDevice from '@/core/hooks/useDevice'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; const SwitchAccount = ({ company_type }) => { @@ -27,6 +28,8 @@ const SwitchAccount = ({ company_type }) => { const [selectedValue, setSelectedValue] = useState('PKP'); const [buttonSubmitClick, setButtonSubmitClick] = useState(false); const [changeConfirmation, setChangeConfirmation] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [isLoadingPopup, setIsLoadingPopup] = useState(false); const { register, setValue, handleSubmit } = useForm({ defaultValues: { email: '', @@ -131,35 +134,44 @@ const SwitchAccount = ({ company_type }) => { setIsPKP(false); } }; - const onSubmitHandler = async (values) => { - toast.loading('Mengubah status akun...'); + const onSubmitHandler = async () => { + setChangeConfirmation(false); // Tutup popup konfirmasi + setIsLoadingPopup(true); // Munculkan popup loading + updateForm('parent_id', `${auth.parentId}`); - setChangeConfirmation(false); - // let data = { ...form, id: `${auth.partnerId}` }; + const data = form; if (!isFormValid) { setNotValid(true); setButtonSubmitClick(!buttonSubmitClick); + toast.error('Form belum valid. Mohon periksa kembali input Anda.'); + setIsLoadingPopup(false); return; - } else { - setButtonSubmitClick(!buttonSubmitClick); - setNotValid(false); } - // if (!values.password) delete data.password; - const isUpdated = await switchAccountApi({ data }); - if (isUpdated?.switch === 'Pending') { - // setAuth(isUpdated.user); - // setValue('password', ''); - toast.success('Berhasil mengubah akun', { duration: 1500 }); - setTimeout(() => { - window.location.reload(); - }, 1500); - return; + try { + const isUpdated = await switchAccountApi({ data }); + + if (isUpdated?.switch === 'Pending') { + toast.success('Berhasil mengajukan ubah akun', { duration: 1500 }); + if (typeof window !== 'undefined') { + localStorage.setItem('autoCheckProfile', 'true'); + } + setTimeout(() => { + window.location.reload(); + }, 1500); + } else { + toast.error('Gagal mengubah akun. Silakan coba lagi nanti.'); + setIsLoadingPopup(false); + } + } catch (error) { + console.error(error); + toast.error('Terjadi kesalahan saat menghubungi server.'); + setIsLoadingPopup(false); } - toast.error('Terjadi kesalahan internal'); }; + const onSubmitHandlerCancel = async (values) => { window.location.reload(); }; @@ -172,26 +184,37 @@ const SwitchAccount = ({ company_type }) => { title='Ubah profil Bisnis' >
- Anda yakin akan merubah profil bisnis anda dari INDIVIDU menjadi{' '} - {selectedValue}? + Anda yakin akan merubah profil bisnis anda dari INDIVIDU menjadi {selectedValue}?
+ +
+ Mengubah status akun... +
+
+ +
+
+ {/*
{ return dataPengajuanTempo; }; -export default createPengajuanTempoApi; +export default createPengajuanTempoApi; \ No newline at end of file -- cgit v1.2.3 From 1085602ad84e73692e3ab8b9141c5f61381a8cea Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 13 Aug 2025 10:57:36 +0700 Subject: (andri) layout pengajuan tempo jika status akun pending --- src/lib/pengajuan-tempo/component/FinishTempo.jsx | 77 +++++++++++++++++------ 1 file changed, 57 insertions(+), 20 deletions(-) (limited to 'src/lib') diff --git a/src/lib/pengajuan-tempo/component/FinishTempo.jsx b/src/lib/pengajuan-tempo/component/FinishTempo.jsx index ad8a7e67..abf218d9 100644 --- a/src/lib/pengajuan-tempo/component/FinishTempo.jsx +++ b/src/lib/pengajuan-tempo/component/FinishTempo.jsx @@ -9,9 +9,12 @@ import axios from 'axios'; import { toast } from 'react-hot-toast'; import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline'; import { useRouter } from 'next/router'; +import switchAccountProgresApi from '@/lib/auth/api/switchAccountProgresApi.js'; const FinishTempo = ({ query }) => { const [data, setData] = useState(); + const [switchStatus, setSwitchStatus] = useState(null); + const [loadingStatus, setLoadingStatus] = useState(true); const [transactionData, setTransactionData] = useState(); const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); @@ -29,16 +32,46 @@ const FinishTempo = ({ query }) => { fetchData(); }, [query]); + useEffect(() => { + const fetchSwitchStatus = async () => { + try { + const progres = await switchAccountProgresApi(); + setSwitchStatus(progres?.status); + } catch (err) { + console.error('Gagal cek progres switch account:', err); + } finally { + setLoadingStatus(false); + } + }; + fetchSwitchStatus(); + }, []); + // Handler khusus untuk tombol Ubah Akun const handleSwitchAccountClick = () => { - // Set flag di localStorage + if (switchStatus === 'pending') { + toast.info('Akun sedang menunggu verifikasi. Tidak dapat mengubah akun saat ini.', { duration: 2500 }); + return; + } localStorage.setItem('autoCheckProfile', 'true'); - // Navigate tanpa query param ke halaman profile router.push('/my/profile'); }; + if (loadingStatus) { + return ( +
+
Memuat data...
+
+ ); + } + return ( -
+
{ > {query?.status == 'finish' && 'Form Pengajuan Tempo kamu Telah Berhasil Didaftarkan Mohon menunggu hingga Proses Verifikasi Selesai Dilakukan'} - {query?.status == 'switch-account' && - 'Form Pengajuan Tempo Kamu Gagal Dilakukan'} + {switchStatus === 'pending' + ? 'Form Pengajuan Tempo Kamu Belum Dapat Dilakukan' + : query?.status == 'switch-account' && + 'Form Pengajuan Tempo Kamu Gagal Dilakukan' + } {query?.status == 'review' && 'Pengajuan Tempo dalam Proses Verifikasi'} {query?.status == 'approve' && 'Pengajuan Tempo Berhasil'} @@ -96,8 +132,11 @@ const FinishTempo = ({ query }) => { isMobile ? 'w-full text-sm' : 'w-4/5 text-base' }`} > - {query?.status == 'switch-account' && - 'Terima kasih atas minat anda untuk mendaftar Tempo, namun sayangnya akun anda bukan merupakan akun bisnis. Segera ubah akun anda menjadi Bisnis untuk menggunakan fitur ini'} + {switchStatus === 'pending' + ? 'Proses perubahan ke akun bisnis sedang kami review, mohon menunggu hingga 2x24 jam' + : query?.status == 'switch-account' && + 'Terima kasih atas minat anda untuk mendaftar Tempo, namun sayangnya akun anda bukan merupakan akun bisnis. Segera ubah akun anda menjadi Bisnis untuk menggunakan fitur ini' + } {query?.status == 'finish' && 'Mohon menunggu untuk verifikasi dokumen dan kelengkapan data yang telah anda berikan. Proses approval pembayaran tempo kamu berhasil atau tidak akan diinfokan melalui email perusahaan / email yang mendaftar'} {query?.status == 'review' && @@ -106,10 +145,12 @@ const FinishTempo = ({ query }) => { 'Proses pengajuan tempo anda sudah berhasil terdaftar di indoteknik.com. Nikmati pembelian anda di website indoteknik dengan menggunakan pembayaran tempo'}
-
+ {switchStatus !== 'pending' && ( +
+ )} {/* Video panduan khusus tampil saat status switch-account */} - {query?.status === 'switch-account' && ( + {query?.status === 'switch-account' && switchStatus !== 'pending' && (

{ )} {/* Tombol dengan behavior berbeda jika status switch-account */} - {query?.status === 'switch-account' ? ( + {query?.status === 'switch-account' && switchStatus !== 'pending' ? ( - ) : ( + ) : query?.status !== 'switch-account' && ( {query?.status === 'approve' ? 'Lihat Detail Tempo' : 'Kembali Ke Beranda'} - + )}

-- cgit v1.2.3 From 9159b649258703ea0539ea958cdf8b3c5987e474 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 15 Aug 2025 09:48:06 +0700 Subject: fix alur repeat order --- src/lib/transaction/components/Transactions.jsx | 39 +++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index de93d742..2596b47f 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -345,8 +345,6 @@ const Transactions = ({ context = '' }) => { }, []); const handleBuyBack = async (products) => { - // if (status === 'success') return; - try { // setStatus('loading'); @@ -358,32 +356,37 @@ const Transactions = ({ context = '' }) => { id: product.id, qty: product.quantity, selected: true, - source: 'buy', // Tetap gunakan 'buy' agar bisa masuk ke halaman pembelian + source: 'buy', qtyAppend: false, + }).catch(error => { + return { error, product }; }) ) ); - // ✅ Panggil setRefreshCart(true) setiap kali satu produk berhasil ditambahkan + const failedOperations = results.filter(result => result && result.error); + + if (failedOperations.length > 0) { + console.error('Some products failed to add to cart:', failedOperations); + toast.error(`${failedOperations.length} produk gagal ditambahkan ke keranjang`); + + // You might want to proceed with the successful ones or handle differently + if (failedOperations.length < products.length) { + toast.success(`${products.length - failedOperations.length} produk berhasil ditambahkan ke keranjang`); + setRefreshCart(true); + router.push('/shop/cart'); + } + return; + } + // All operations succeeded setRefreshCart(true); - - // setStatus('idle'); toast.success('Semua produk berhasil ditambahkan ke keranjang belanja'); - // Tampilkan notifikasi - // toast({ - // title: 'Tambah ke keranjang', - // description: 'Semua produk berhasil ditambahkan ke keranjang belanja', - // status: 'success', - // duration: 3000, - // isClosable: true, - // position: 'top', - // }); - - // Redirect ke halaman checkout - router.push('/shop/checkout?source=buy'); + router.push('/shop/cart'); + } catch (error) { console.error('Gagal menambahkan produk ke keranjang:', error); + toast.error('Terjadi kesalahan saat menambahkan produk ke keranjang'); // setStatus('error'); } }; -- cgit v1.2.3 From ea68149a86437bd89dfcc608d602aa194cd3b436 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 15 Aug 2025 13:43:58 +0700 Subject: fix alur repeat order --- src/lib/transaction/components/Transactions.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index 2596b47f..893fbfbb 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -347,6 +347,7 @@ const Transactions = ({ context = '' }) => { const handleBuyBack = async (products) => { try { // setStatus('loading'); + console.log("Products to add:", products); const results = await Promise.all( products.map((product) => @@ -356,8 +357,8 @@ const Transactions = ({ context = '' }) => { id: product.id, qty: product.quantity, selected: true, - source: 'buy', - qtyAppend: false, + source: 'add_to_cart', + qtyAppend: true, }).catch(error => { return { error, product }; }) @@ -365,6 +366,7 @@ const Transactions = ({ context = '' }) => { ); const failedOperations = results.filter(result => result && result.error); + console.log(results); if (failedOperations.length > 0) { console.error('Some products failed to add to cart:', failedOperations); -- cgit v1.2.3 From d042efda0985a4a28c4484749fb0b2cd34b7bf9e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 15 Aug 2025 13:47:56 +0700 Subject: fix alur repeat order --- src/lib/transaction/components/Transactions.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index 893fbfbb..5e37be50 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -366,7 +366,7 @@ const Transactions = ({ context = '' }) => { ); const failedOperations = results.filter(result => result && result.error); - console.log(results); + // console.log(results); if (failedOperations.length > 0) { console.error('Some products failed to add to cart:', failedOperations); -- cgit v1.2.3 From b1bdfbb9f780a1a1305e02c4b9c338b98c7a4556 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Fri, 15 Aug 2025 13:58:59 +0700 Subject: (andri) fix switch account --- src/lib/auth/api/checkParentStatusApi.js | 13 +++++++++++++ src/lib/auth/components/SwitchAccount.jsx | 10 ++++++---- src/lib/pengajuan-tempo/component/PengajuanTempo.jsx | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/lib/auth/api/checkParentStatusApi.js (limited to 'src/lib') diff --git a/src/lib/auth/api/checkParentStatusApi.js b/src/lib/auth/api/checkParentStatusApi.js new file mode 100644 index 00000000..aa2eb1b6 --- /dev/null +++ b/src/lib/auth/api/checkParentStatusApi.js @@ -0,0 +1,13 @@ +import odooApi from '@/core/api/odooApi'; +import { getAuth } from '@/core/utils/auth'; + +const checkParentStatusApi = async () => { + const auth = getAuth(); + const checkParentStatus = await odooApi( + 'GET', + `/api/v1/user/${auth.partnerId}/parent_status` + ); + return checkParentStatus; +}; + +export default checkParentStatusApi; \ No newline at end of file diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index 80bc584f..840758c9 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -16,7 +16,7 @@ import { isValid } from 'zod'; import Spinner from "@/core/components/elements/Spinner/LogoSpinner"; import useDevice from '@/core/hooks/useDevice'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; -const SwitchAccount = ({ company_type }) => { +const SwitchAccount = ({ company_type, setIsAprove, setUbahAkun }) => { const { isDesktop, isMobile } = useDevice(); const auth = useAuth(); const [isOpen, setIsOpen] = useState(true); @@ -152,21 +152,23 @@ const SwitchAccount = ({ company_type }) => { try { const isUpdated = await switchAccountApi({ data }); - if (isUpdated?.switch === 'Pending') { + if (isUpdated?.switch === 'pending') { toast.success('Berhasil mengajukan ubah akun', { duration: 1500 }); if (typeof window !== 'undefined') { localStorage.setItem('autoCheckProfile', 'true'); } setTimeout(() => { + setIsAprove('pending'); + setUbahAkun('pending'); window.location.reload(); }, 1500); } else { - toast.error('Gagal mengubah akun. Silakan coba lagi nanti.'); + toast.error('Gagal mengubah akun. Silakan coba lagi nanti atau hubungi admin jika masalah tetap terjadi.'); setIsLoadingPopup(false); } } catch (error) { console.error(error); - toast.error('Terjadi kesalahan saat menghubungi server.'); + toast.error('Terjadi kesalahan saat menghubungi server, silahkan cek internet Anda atau hubungi admin Indoteknik.'); setIsLoadingPopup(false); } }; diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx index d59bfd75..3dac0015 100644 --- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx +++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx @@ -40,6 +40,7 @@ const PengajuanTempo = () => { const { form, errors, validate, updateForm } = usePengajuanTempoStore(); const { control, watch, setValue } = useForm(); const auth = useAuth(); + console.log('auth', auth); const router = useRouter(); const [BannerTempo, setBannerTempo] = useState(); const { formDokumen, errorsDokumen, validateDokumen, updateFormDokumen } = -- cgit v1.2.3