diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-05-23 09:38:22 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-05-23 09:38:22 +0700 |
| commit | a2c424ebb371ce2716d7fc55bb70807303c2e0e0 (patch) | |
| tree | 1a4bbbcf7cee381e10fa473926223abfe7c4bcf8 /src/pages/daftar-merchant/index.jsx | |
| parent | 4904573845478e7e9648735d008153728870a123 (diff) | |
| parent | 60cbad2ae4b551d8f1e6959a3c90134c16b10e26 (diff) | |
Merge branch 'new-release' of https://bitbucket.org/altafixco/next-indoteknik.giT into fix_responsive_cart
Diffstat (limited to 'src/pages/daftar-merchant/index.jsx')
| -rw-r--r-- | src/pages/daftar-merchant/index.jsx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/pages/daftar-merchant/index.jsx b/src/pages/daftar-merchant/index.jsx new file mode 100644 index 00000000..36fedafc --- /dev/null +++ b/src/pages/daftar-merchant/index.jsx @@ -0,0 +1,53 @@ +import Seo from '@/core/components/Seo'; +import BasicLayout from '@/core/components/layouts/BasicLayout'; +import CreateMerchant from '@/lib/merchant/components/Merchant'; +import ErrorMerchant from '@/lib/merchant/components/AccountSwitch'; +import getMerchantProgresApi from '@/lib/merchant/api/getMerchantProgresApi'; +import useAuth from '@/core/hooks/useAuth'; +import { useRouter } from 'next/router'; +import React, { useEffect, useState } from 'react'; +export default function DaftarMerchant() { + const router = useRouter(); + const auth = useAuth(); + const [isLoading, setIsLoading] = useState(true); + useEffect(() => { + const loadData = async () => { + setIsLoading(true); + try { + const data = await getMerchantProgresApi(); + switch (data) { + case 'draft': + router.push(`/daftar-merchant/review`); + break; + case 'approve': + router.push(`/daftar-merchant/approve`); + break; + case 'reject': + router.push(`/daftar-merchant/reject`); + break; + } + } catch (error) { + console.error('Error loading profile:', error); + handleIsError(true); // Jika ada error, panggil fungsi error handler + } + setIsLoading(false); + }; + + loadData(); + }, []); + if (auth == false) { + router.push(`/login?next=${encodeURIComponent('/daftar-merchant')}`); + } + if (!auth || isLoading) { + return; + } + return ( + <> + <Seo title='Daftar Merchant - Indoteknik.com' /> + + <BasicLayout> + {auth && auth?.company ? <CreateMerchant /> : <ErrorMerchant />} + </BasicLayout> + </> + ); +} |
