summaryrefslogtreecommitdiff
path: root/src/pages/daftar-merchant
diff options
context:
space:
mode:
authorIndoteknik . <andrifebriyadiputra@gmail.com>2025-05-26 12:37:08 +0700
committerIndoteknik . <andrifebriyadiputra@gmail.com>2025-05-26 12:37:08 +0700
commit2102158d77211991673aa7ed7cfacda69cceda2e (patch)
treec788fe583c25d172df93841f403389d01d9198dd /src/pages/daftar-merchant
parentca05a70e98e9066882de6394ffbd89db7af2cb9d (diff)
parent4ef92b4d9fea4fdd636d62194514b33ed3b3c387 (diff)
(andri) resolve conflict
Diffstat (limited to 'src/pages/daftar-merchant')
-rw-r--r--src/pages/daftar-merchant/[status].jsx47
-rw-r--r--src/pages/daftar-merchant/index.jsx53
2 files changed, 100 insertions, 0 deletions
diff --git a/src/pages/daftar-merchant/[status].jsx b/src/pages/daftar-merchant/[status].jsx
new file mode 100644
index 00000000..61c07571
--- /dev/null
+++ b/src/pages/daftar-merchant/[status].jsx
@@ -0,0 +1,47 @@
+import BasicLayout from '@/core/components/layouts/BasicLayout';
+import IsAuth from '@/lib/auth/components/IsAuth';
+import StatusMerchant from '@/lib/merchant/components/AccountSwitch';
+import { useRouter } from 'next/router';
+import axios from 'axios';
+import { useState, useEffect } from 'react';
+import Seo from '@/core/components/Seo';
+import { getAuth } from '~/libs/auth';
+
+export async function getServerSideProps(context) {
+ const { status } = context.query;
+ // await axios.post(
+ // `${process.env.NEXT_PUBLIC_SELF_HOST}/api/pengajuan-tempo/${status}`,
+ // {},
+ // { headers: context.req.headers }
+ // );
+ return { props: {} };
+}
+
+export default function Finish() {
+ const [isLoading, setIsLoading] = useState(true);
+ const router = useRouter();
+ const auth = getAuth();
+ useEffect(() => {
+ if (!auth) {
+ const nextUrl = encodeURIComponent(router.asPath);
+ router.push(`/login?next=${nextUrl}`);
+ } else {
+ setIsLoading(false);
+ }
+ }, [auth]);
+
+ if (isLoading || !auth) {
+ return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
+ }
+ return (
+ <>
+ <Seo title='Pengajuan Tempo Indoteknik.com' />
+
+ <IsAuth>
+ <BasicLayout>
+ <StatusMerchant query={router.query || {}} />
+ </BasicLayout>
+ </IsAuth>
+ </>
+ );
+}
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>
+ </>
+ );
+}