summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/components/elements/Navbar/NavbarDesktop.jsx37
-rw-r--r--src/lib/checkout/api/getVoucher.js10
-rw-r--r--src/lib/checkout/components/Checkout.jsx44
-rw-r--r--src/pages/shop/brands/[slug].jsx6
4 files changed, 81 insertions, 16 deletions
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 308f2623..9de761a2 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -19,6 +19,14 @@ import DesktopView from '../../views/DesktopView';
import Link from '../Link/Link';
import NavbarUserDropdown from './NavbarUserDropdown';
import NextImage from 'next/image';
+import {
+ Button,
+ Menu,
+ MenuButton,
+ MenuItem,
+ MenuList,
+ useDisclosure,
+} from '@chakra-ui/react';
const Search = dynamic(() => import('./Search'), { ssr: false });
const TopBanner = dynamic(() => import('./TopBanner'), { ssr: false });
@@ -36,6 +44,7 @@ const NavbarDesktop = () => {
const router = useRouter();
const { product } = useProductContext();
+ const { isOpen, onOpen, onClose } = useDisclosure();
useEffect(() => {
if (router.pathname === '/shop/product/[slug]') {
@@ -78,7 +87,31 @@ const NavbarDesktop = () => {
</div>
</div>
<div className='flex gap-x-6'>
- <Link href='/tentang-kami' className='!text-gray_r-12'>
+ <Menu isOpen={isOpen}>
+ <MenuButton
+ rightIcon={<ChevronDownIcon />}
+ onMouseEnter={onOpen}
+ onMouseLeave={onClose}
+ >
+ <div className='flex gap-x-1'>
+ <div>Fitur Layanan </div>
+ <ChevronDownIcon className='w-5'/>
+ </div>
+ </MenuButton>
+ <MenuList
+ zIndex={100}
+ onMouseEnter={onOpen}
+ onMouseLeave={onClose}
+ >
+ <MenuItem as='a' href='/tentang-kami'>
+ Tentang Indoteknik
+ </MenuItem>
+ <MenuItem as='a' href='/my/pembayaran-tempo'>
+ Pembayaran Tempo
+ </MenuItem>
+ </MenuList>
+ </Menu>
+ {/* <Link href='/tentang-kami' className='!text-gray_r-12'>
Tentang Indoteknik.com
</Link>
<Link href='/my/pembayaran-tempo' className='!text-gray_r-12'>
@@ -86,7 +119,7 @@ const NavbarDesktop = () => {
</Link>
<Link href='/' className='!text-gray_r-12'>
Fitur Layanan
- </Link>
+ </Link> */}
</div>
</div>
</div>
diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js
index 07cf376e..15c6abbb 100644
--- a/src/lib/checkout/api/getVoucher.js
+++ b/src/lib/checkout/api/getVoucher.js
@@ -1,4 +1,5 @@
import odooApi from '@/core/api/odooApi'
+import { getAuth } from '@/core/utils/auth'
export const getVoucher = async (id, source) => {
let dataVoucher = null
@@ -19,3 +20,12 @@ export const findVoucher = async (code, id, source) => {
}
return dataVoucher
}
+
+
+export const getVoucherNew = async (source) => {
+ const id = getAuth()?.id;
+ const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?${source}`)
+
+ return dataVoucher
+
+} \ No newline at end of file
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 92e14db6..9bc0257e 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -30,7 +30,7 @@ import whatsappUrl from '@/core/utils/whatsappUrl';
import addressesApi from '@/lib/address/api/addressesApi';
import CartItem from '~/modules/cart/components/Item.tsx';
import ExpedisiList from '../api/ExpedisiList';
-import { findVoucher, getVoucher } from '../api/getVoucher';
+import { findVoucher, getVoucher, getVoucherNew } from '../api/getVoucher';
const SELF_PICKUP_ID = 32;
@@ -40,6 +40,7 @@ const { getProductsCheckout } = require('../api/checkoutApi');
const Checkout = () => {
const router = useRouter();
const query = router.query.source ?? null;
+ const qVoucher = router.query.voucher ?? null;
const auth = useAuth();
const [activeVoucher, SetActiveVoucher] = useState(null);
@@ -119,7 +120,8 @@ const Checkout = () => {
const voucher = async () => {
if (!listVouchers) {
try {
- let dataVoucher = await getVoucher(auth?.id, query);
+ let source = 'source=' + query;
+ let dataVoucher = await getVoucherNew(source);
SetListVoucher(dataVoucher);
} finally {
setLoadingVoucher(false);
@@ -127,14 +129,16 @@ const Checkout = () => {
}
};
const VoucherCode = async (code) => {
- let dataVoucher = await findVoucher(code, auth.id, query);
+ const source = 'code=' + code + '&source=' + query;
+ // let dataVoucher = await findVoucher(code, auth.id, query);
+ let dataVoucher = await getVoucherNew(source);
if (dataVoucher.length <= 0) {
SetFindVoucher(1);
return;
}
let addNewLine = dataVoucher[0];
- let checkList = listVouchers.findIndex(
+ let checkList = listVouchers?.findIndex(
(voucher) => voucher.code == addNewLine.code
);
if (checkList >= 0) {
@@ -166,6 +170,7 @@ const Checkout = () => {
}, [bottomPopup]);
useEffect(() => {
+ voucher();
const loadExpedisi = async () => {
let dataExpedisi = await ExpedisiList();
dataExpedisi = dataExpedisi.map((expedisi) => ({
@@ -186,7 +191,6 @@ const Checkout = () => {
return () => {
window.onpopstate = null;
};
- // voucher()
}, []);
const hitungDiscountVoucher = (code) => {
@@ -222,13 +226,21 @@ const Checkout = () => {
}, [activeVoucher, listVouchers]);
useEffect(() => {
+ if (qVoucher === 'PASTIHEMAT' && listVouchers) {
+ let code = qVoucher;
+ VoucherCode(code);
+ }
+ }, [listVouchers]);
+
+ useEffect(() => {
setProducts(cartCheckout?.products);
setCheckWeight(cartCheckout?.hasProductWithoutWeight);
setTotalWeight(cartCheckout?.totalWeight.g);
- const hasFlashSale = cartCheckout?.products.some(product => product.hasFlashsale);
+ const hasFlashSale = cartCheckout?.products.some(
+ (product) => product.hasFlashsale
+ );
setHasFlashSale(hasFlashSale);
}, [cartCheckout]);
-
useEffect(() => {
setCheckoutValidation(false);
@@ -347,7 +359,7 @@ const Checkout = () => {
carrier_id: selectedCarrierId,
estimated_arrival_days: splitDuration(etd),
delivery_service_type: selectedExpedisiService,
- flash_sale : hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false
+ flash_sale: hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false
voucher: activeVoucher,
type: 'sale_order',
};
@@ -363,7 +375,7 @@ const Checkout = () => {
toast.error('Gagal melakukan transaksi, terjadi kesalahan internal');
return;
}
-
+
gtagPurchase(products, biayaKirim, isCheckouted.name);
const midtrans = async () => {
@@ -407,13 +419,17 @@ const Checkout = () => {
} else {
SetActiveVoucher(code);
SetFindVoucher(null);
- document.getElementById('uniqCode').value = '';
+ document.getElementById('uniqCode')
+ ? (document.getElementById('uniqCode').value = '')
+ : '';
SetButtonTerapkan(false);
}
} else {
SetActiveVoucher(code);
SetFindVoucher(null);
- document.getElementById('uniqCode').value = '';
+ document.getElementById('uniqCode')
+ ? (document.getElementById('uniqCode').value = '')
+ : '';
SetButtonTerapkan(false);
}
};
@@ -1589,9 +1605,11 @@ const PickupAddress = ({ label }) => (
Kodepos : 14440
</p>
<p className='mt-1 text-gray_r-11'>Telp : 021-2933 8828/29</p>
- <p className='mt-1 text-gray_r-11 hover:text-red-500'><a href={whatsappUrl()} target='_blank' rel='noreferrer'>
+ <p className='mt-1 text-gray_r-11 hover:text-red-500'>
+ <a href={whatsappUrl()} target='_blank' rel='noreferrer'>
Mobile : 0817-1718-1922
- </a></p>
+ </a>
+ </p>
</div>
</div>
);
diff --git a/src/pages/shop/brands/[slug].jsx b/src/pages/shop/brands/[slug].jsx
index c3a7299f..e786ef78 100644
--- a/src/pages/shop/brands/[slug].jsx
+++ b/src/pages/shop/brands/[slug].jsx
@@ -5,6 +5,7 @@ import _ from 'lodash'
import Seo from '@/core/components/Seo'
import Breadcrumb from '@/lib/brand/components/Breadcrumb'
import useBrand from '@/lib/brand/hooks/useBrand'
+import PageNotFound from '@/pages/404';
const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout'))
const ProductSearch = dynamic(() => import('@/lib/product/components/ProductSearch'))
@@ -17,10 +18,13 @@ export default function BrandDetail() {
const brandName = getNameFromSlug(slug)
const id = getIdFromSlug(slug)
const {brand} = useBrand({id})
+ if (!brand || !brand.data || _.isEmpty(brand.data)) {
+ return <PageNotFound />;
+ }
return (
<BasicLayout>
<Seo
- title={`Distributor ${brandName} Indonesia Harga Official Indoteknik.com`}
+ title={`Jual Produk Resmi ${brandName} Indonesia | Indoteknik.com`}
description='B2B Marketplace MRO &amp; Industri dengan Layanan Pembayaran Tempo, Faktur Pajak, Online Quotation, Garansi Resmi &amp; Harga Kompetitif'
additionalMetaTags={[
{