summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-15 16:29:48 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-15 16:29:48 +0700
commit98236a47c3558c4b701009a275c7ae917ee8bf67 (patch)
tree21e0300680a724c8a24ed815ea4e9a32ab13a895 /src/pages
parent1fa1a7873aa67cdd9ca211c239276a148cd4cdda (diff)
parent7a14ed5ccdde86d0400d6aa02ac866317d4add63 (diff)
Merge branch 'new-release' into Feature/switch-account
# Conflicts: # src/lib/auth/components/CompanyProfile.jsx # src/lib/auth/components/Menu.jsx
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/api/shop/midtrans-payment.js1
-rw-r--r--src/pages/google_merchant/products/[page].js5
-rw-r--r--src/pages/my/menu.jsx13
-rw-r--r--src/pages/my/tempo/index.jsx51
-rw-r--r--src/pages/pengajuan-tempo/[status].jsx47
-rw-r--r--src/pages/pengajuan-tempo/index.jsx81
6 files changed, 196 insertions, 2 deletions
diff --git a/src/pages/api/shop/midtrans-payment.js b/src/pages/api/shop/midtrans-payment.js
index 12aaa51f..f90e9e81 100644
--- a/src/pages/api/shop/midtrans-payment.js
+++ b/src/pages/api/shop/midtrans-payment.js
@@ -3,6 +3,7 @@ import camelcaseObjectDeep from 'camelcase-object-deep'
import midtransClient from 'midtrans-client'
export default async function handler(req, res) {
+ const PPN = process.env.NEXT_PUBLIC_PPN
const { transactionId = null } = req.query
if (!transactionId) {
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js
index 0c2cf3c5..8395f839 100644
--- a/src/pages/google_merchant/products/[page].js
+++ b/src/pages/google_merchant/products/[page].js
@@ -6,6 +6,7 @@ import _ from 'lodash-contrib';
import { create } from 'xmlbuilder';
export async function getServerSideProps({ res, query }) {
+ const PPN = process.env.NEXT_PUBLIC_PPN
const titleContent = 'Indoteknik.com: B2B Industrial Supply & Solution';
const descriptionContent =
'Temukan pilihan produk B2B Industri & Alat Teknik untuk Perusahaan, UMKM & Pemerintah dengan lengkap, mudah dan transparan.';
@@ -77,7 +78,7 @@ export async function getServerSideProps({ res, query }) {
'g:availability': { '#text': availability },
'g:brand': { '#text': product.manufacture?.name || '' },
'g:price': {
- '#text': `${Math.round(product.lowestPrice.price * 1.11)} IDR`,
+ '#text': `${Math.round(product.lowestPrice.price * PPN)} IDR`,
},
};
@@ -93,7 +94,7 @@ export async function getServerSideProps({ res, query }) {
if (product.lowestPrice.discountPercentage > 0) {
item['g:sale_price'] = {
- '#text': `${Math.round(product.lowestPrice.priceDiscount * 1.11)} IDR`,
+ '#text': `${Math.round(product.lowestPrice.priceDiscount * PPN)} IDR`,
};
}
productItems.push(item);
diff --git a/src/pages/my/menu.jsx b/src/pages/my/menu.jsx
index 1b35d6ba..2a46d866 100644
--- a/src/pages/my/menu.jsx
+++ b/src/pages/my/menu.jsx
@@ -90,6 +90,19 @@ export default function Menu() {
<p>Invoice & Faktur Pajak</p>
</div>
</LinkItem>
+ {(auth?.partnerTempo || auth?.tempoProgres == 'review') && (
+ <LinkItem href='/my/tempo'>
+ {' '}
+ <div className='flex gap-x-3 items-center'>
+ <ImageNext
+ src='/images/icon/icon_tempo.svg'
+ width={18}
+ height={20}
+ />
+ <p>Pembayaran Tempo</p>
+ </div>
+ </LinkItem>
+ )}
<LinkItem href='/my/wishlist'>
<div className='flex gap-x-3 items-center'>
<ImageNext
diff --git a/src/pages/my/tempo/index.jsx b/src/pages/my/tempo/index.jsx
new file mode 100644
index 00000000..5fb9deba
--- /dev/null
+++ b/src/pages/my/tempo/index.jsx
@@ -0,0 +1,51 @@
+import Seo from '@/core/components/Seo';
+import AppLayout from '@/core/components/layouts/AppLayout';
+import BasicLayout from '@/core/components/layouts/BasicLayout';
+import DesktopView from '@/core/components/views/DesktopView';
+import MobileView from '@/core/components/views/MobileView';
+import IsAuth from '@/lib/auth/components/IsAuth';
+import InvoicesComponent from '@/lib/tempo/components/Tempo';
+import { getAuth } from '~/libs/auth';
+import { useRouter } from 'next/router';
+import { useEffect, useState } from 'react';
+export default function MyTempo() {
+ const auth = getAuth();
+ const router = useRouter();
+ const [isLoading, setIsLoading] = useState(true);
+ useEffect(() => {
+ if (!auth) {
+ const nextUrl = encodeURIComponent(router.asPath);
+ router.push(`/login?next=${nextUrl}`);
+ }
+ // else if (
+ // (auth.tempoProgres === '' || auth.tempoProgres === 'rejected') &&
+ // !auth.company
+ // ) {
+ // router.push('/pengajuan-tempo');
+ // }
+ else {
+ setIsLoading(false);
+ }
+ }, [auth]);
+
+ if (isLoading || !auth) {
+ return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
+ }
+ return (
+ <IsAuth>
+ <Seo title='Tempo - Indoteknik.com' />
+
+ <MobileView>
+ <AppLayout title='Pembayaran Tempo'>
+ <InvoicesComponent />
+ </AppLayout>
+ </MobileView>
+
+ <DesktopView>
+ <BasicLayout>
+ <InvoicesComponent />
+ </BasicLayout>
+ </DesktopView>
+ </IsAuth>
+ );
+}
diff --git a/src/pages/pengajuan-tempo/[status].jsx b/src/pages/pengajuan-tempo/[status].jsx
new file mode 100644
index 00000000..29886892
--- /dev/null
+++ b/src/pages/pengajuan-tempo/[status].jsx
@@ -0,0 +1,47 @@
+import BasicLayout from '@/core/components/layouts/BasicLayout';
+import IsAuth from '@/lib/auth/components/IsAuth';
+import FinishTempoComponent from '@/lib/pengajuan-tempo/component/FinishTempo';
+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>
+ <FinishTempoComponent query={router.query || {}} />
+ </BasicLayout>
+ </IsAuth>
+ </>
+ );
+}
diff --git a/src/pages/pengajuan-tempo/index.jsx b/src/pages/pengajuan-tempo/index.jsx
new file mode 100644
index 00000000..6987bd29
--- /dev/null
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -0,0 +1,81 @@
+import Seo from '@/core/components/Seo';
+import dynamic from 'next/dynamic';
+import SimpleFooter from '@/core/components/elements/Footer/SimpleFooter';
+import BasicLayout from '@/core/components/layouts/BasicLayout';
+import DesktopView from '@/core/components/views/DesktopView';
+import MobileView from '@/core/components/views/MobileView';
+import { getAuth } from '~/libs/auth';
+import { useRouter } from 'next/router';
+import { useEffect, useState } from 'react';
+import odooApi from '@/core/api/odooApi';
+
+const PagePengajuanTempo = dynamic(() =>
+ import('@/lib/pengajuan-tempo/component/PengajuanTempo')
+);
+
+export default function TrackingOrder() {
+ const [tempo, setTempo] = useState(null);
+ const [isLoading, setIsLoading] = useState(true);
+ const auth = getAuth();
+ const router = useRouter();
+
+ useEffect(() => {
+ const loadTempo = async () => {
+ try {
+ if (auth?.partnerId) {
+ const dataTempo = await odooApi(
+ 'GET',
+ `/api/v1/check/${auth.partnerId}/tempo`
+ );
+ setTempo(dataTempo);
+ }
+ } catch (error) {
+ console.error('Error fetching tempo data:', error);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ if (auth) {
+ loadTempo();
+ } else {
+ setIsLoading(false);
+ }
+ }, []);
+ useEffect(() => {
+ if (!auth) {
+ const nextUrl = encodeURIComponent(router.asPath);
+ router.push(`/login?next=${nextUrl}`);
+ } else if (auth.tempoProgres === 'approve' || auth?.partnerTempo) {
+ router.push('/pengajuan-tempo/approve');
+ } else if (!auth.parentId) {
+ router.push('/pengajuan-tempo/switch-account');
+ } else if (auth.tempoProgres === 'review' && !tempo?.paymentTerm) {
+ router.push('/pengajuan-tempo/review');
+ } else if (auth.tempoProgres === 'rejected') {
+ router.push('/pengajuan-tempo/rejected');
+ } else {
+ setIsLoading(false);
+ }
+ }, [tempo]);
+
+ if (isLoading || !auth || !tempo) {
+ return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
+ }
+
+ return (
+ <>
+ <Seo title='Pengajuan Tempo - Indoteknik.com' />
+ <DesktopView>
+ <BasicLayout>
+ <PagePengajuanTempo />
+ </BasicLayout>
+ </DesktopView>
+ <MobileView>
+ <BasicLayout>
+ <PagePengajuanTempo />
+ </BasicLayout>
+ </MobileView>
+ </>
+ );
+}