summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/api/shop/midtrans-payment.js1
-rw-r--r--src/pages/api/shop/variant.js1
-rw-r--r--src/pages/google_merchant/products/[page].js35
-rw-r--r--src/pages/my/menu.jsx13
-rw-r--r--src/pages/my/profile.jsx107
-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
8 files changed, 330 insertions, 6 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/api/shop/variant.js b/src/pages/api/shop/variant.js
index 249d087e..47e4f121 100644
--- a/src/pages/api/shop/variant.js
+++ b/src/pages/api/shop/variant.js
@@ -119,6 +119,7 @@ const productResponseMap = (products, pricelist) => {
let productMapped = {
id: product.product_id_i || '',
+ productTemplate: product.template_id_i || '',
image: product.image_s || '',
code: product.default_code_s || '',
name: product.name_s || '',
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js
index 0c2cf3c5..8dd28a39 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.';
@@ -23,7 +24,7 @@ export async function getServerSideProps({ res, query }) {
const brandsData = {};
const categoriesData = {};
-
+ let i = 0;
const productItems = [];
for (const product of products.response.products) {
const productUrl = createSlug(
@@ -48,6 +49,7 @@ export async function getServerSideProps({ res, query }) {
let brandId = product.manufacture?.id ?? null;
let categoryId = null;
+ let category_level_1 = null;
if (brandId && brandId in brandsData) {
categoryId = brandsData[brandId]?.category_ids?.[0] ?? null;
@@ -56,6 +58,23 @@ export async function getServerSideProps({ res, query }) {
brandsData[brandId] = solrBrand;
categoryId = solrBrand?.category_ids?.[0] ?? null;
}
+ if (product.categories[0]?.id) {
+ const getProductTemplate = await getProductTemplateId(
+ product?.productTemplate ?? null
+ );
+ i = i + 1;
+ const id =
+ getProductTemplate?.category_parent_ids?.length > 0
+ ? getProductTemplate.category_parent_ids[0]
+ : null;
+ if (id) {
+ category_level_1 = await getCategoryById(id);
+ } else {
+ category_level_1 = null;
+ }
+ } else {
+ category_level_1 = null;
+ }
if (categoryId && categoryId in categoriesData) {
categoryName = categoriesData[categoryId]?.name_s ?? null;
@@ -77,7 +96,10 @@ 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`,
+ },
+ 'g:custom_label_3': {
+ '#text': category_level_1?.name_s || 'Tidak Ada Kategori',
},
};
@@ -93,7 +115,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);
@@ -126,6 +148,13 @@ const getBrandById = async (id) => {
return brand.data.response.docs[0] ?? null;
};
+const getProductTemplateId = async (id) => {
+ const category = await axios(
+ `${process.env.SOLR_HOST}/solr/product/select?q=id:${id}`
+ );
+ return category.data.response.docs[0] ?? null;
+};
+
const getCategoryById = async (id) => {
const category = await axios(
`${process.env.SOLR_HOST}/solr/categories/select?q=id:${id}`
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/profile.jsx b/src/pages/my/profile.jsx
index 7cf1bcbb..eaf3341c 100644
--- a/src/pages/my/profile.jsx
+++ b/src/pages/my/profile.jsx
@@ -5,19 +5,96 @@ import DesktopView from '@/core/components/views/DesktopView';
import MobileView from '@/core/components/views/MobileView';
import useAuth from '@/core/hooks/useAuth';
import CompanyProfile from '@/lib/auth/components/CompanyProfile';
+import SwitchAccount from '@/lib/auth/components/SwitchAccount';
import IsAuth from '@/lib/auth/components/IsAuth';
import Menu from '@/lib/auth/components/Menu';
import PersonalProfile from '@/lib/auth/components/PersonalProfile';
-import Seo from '@/core/components/Seo';
-
+// import StatusSwitchAccount from '@/lib/auth/components/StatusSwitchAccount';
+import { Checkbox } from '@chakra-ui/react';
+import { useState, useEffect } from 'react';
+import switchAccountProgresApi from '@/lib/auth/api/switchAccountProgresApi.js';
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
export default function Profile() {
const auth = useAuth();
+ const [isChecked, setIsChecked] = useState(false);
+ const [ubahAkun, setUbahAkun] = useState(false);
+ const [isAprove, setIsAprove] = useState();
+ const [changeConfirmation, setChangeConfirmation] = useState(false);
+ const handleChange = async () => {
+ if (isChecked) {
+ setIsChecked(!isChecked);
+ } else {
+ setChangeConfirmation(true);
+ }
+ };
+ useEffect(() => {
+ const loadPromo = async () => {
+ const progresSwitchAccount = await switchAccountProgresApi();
+ if (progresSwitchAccount) {
+ setIsAprove(progresSwitchAccount.status);
+ setUbahAkun(progresSwitchAccount.status);
+ }
+ };
+ loadPromo();
+ }, []);
+ const handleConfirmSubmit = () => {
+ setChangeConfirmation(false);
+ setIsChecked(true);
+ };
return (
<>
- <Seo title='Profile - Indoteknik.com' />
+ <BottomPopup
+ active={changeConfirmation}
+ close={() => setChangeConfirmation(false)} // Menutup popup
+ title='Ubah type akun'
+ >
+ <div className='leading-7 text-gray_r-12/80'>
+ Anda akan mengubah type akun anda?
+ </div>
+ <div className='flex mt-6 gap-x-4 md:justify-end'>
+ <button
+ className='btn-solid-red flex-1 md:flex-none'
+ type='button'
+ onClick={handleConfirmSubmit}
+ >
+ Yakin
+ </button>
+ <button
+ className='btn-light flex-1 md:flex-none'
+ type='button'
+ onClick={() => setChangeConfirmation(false)}
+ >
+ Batal
+ </button>
+ </div>
+ </BottomPopup>
<IsAuth>
<MobileView>
<AppLayout title='Akun Saya'>
+ {!auth?.parentId && !ubahAkun && (
+ <div className='text-sm p-4 flex items-center'>
+ <Checkbox
+ borderColor='gray.600'
+ colorScheme='red'
+ size='lg'
+ isChecked={isChecked}
+ onChange={handleChange}
+ />
+ <p className='ml-2'>Ubah ke akun bisnis</p>
+ </div>
+ )}
+ {isChecked && (
+ <div>
+ <SwitchAccount company_type='nonpkp' />
+ <Divider />
+ </div>
+ )}
+ {/* {!auth?.parentId
+ ? auth?.parentId
+ : auth?.parent_id &&
+ isAprove != 'unknown' && (
+ <StatusSwitchAccount status={isAprove} />
+ )} */}
<PersonalProfile />
<Divider />
{auth?.parentId && <CompanyProfile />}
@@ -31,6 +108,30 @@ export default function Profile() {
<Menu />
</div>
<div className='w-9/12 bg-white border border-gray_r-6 rounded'>
+ {!auth?.parentId && !ubahAkun && (
+ <div className='text-sm p-4 flex items-center'>
+ <Checkbox
+ borderColor='gray.600'
+ colorScheme='red'
+ size='lg'
+ isChecked={isChecked}
+ onChange={handleChange}
+ />
+ <p className='ml-2'>Ubah ke akun bisnis</p>
+ </div>
+ )}
+ {isChecked && (
+ <div>
+ <SwitchAccount company_type='nonpkp' />
+ <Divider />
+ </div>
+ )}
+ {/* {!auth?.parentId
+ ? auth?.parentId
+ : auth?.parent_id &&
+ isAprove != 'unknown' && (
+ <StatusSwitchAccount status={isAprove} />
+ )} */}
<PersonalProfile />
<Divider />
{auth?.parentId && <CompanyProfile />}
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>
+ </>
+ );
+}