summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.jsx40
-rw-r--r--src/lib/checkout/components/CheckoutOld.jsx4
-rw-r--r--src/lib/checkout/components/CheckoutSection.jsx5
-rw-r--r--src/lib/product/components/ProductCard.jsx165
-rw-r--r--src/pages/shop/brands/[slug].jsx6
-rw-r--r--src/utils/solrMapping.js1
8 files changed, 193 insertions, 75 deletions
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 328bc0c9..7d9e4264 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';
import style from "./style/NavbarDesktop.module.css";
const Search = dynamic(() => import('./Search'), { ssr: false });
@@ -37,6 +45,7 @@ const NavbarDesktop = () => {
const router = useRouter();
const { product } = useProductContext();
+ const { isOpen, onOpen, onClose } = useDisclosure();
useEffect(() => {
if (router.pathname === '/shop/product/[slug]') {
@@ -79,7 +88,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'>
@@ -87,7 +120,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 54c8cce5..779cef43 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, query) => {
const queryParam = new URLSearchParams(query);
@@ -22,3 +23,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 081ad9a4..09a791ee 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);
@@ -145,14 +146,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) {
@@ -184,6 +187,7 @@ const Checkout = () => {
}, [bottomPopup]);
useEffect(() => {
+ voucher();
const loadExpedisi = async () => {
let dataExpedisi = await ExpedisiList();
dataExpedisi = dataExpedisi.map((expedisi) => ({
@@ -204,7 +208,6 @@ const Checkout = () => {
return () => {
window.onpopstate = null;
};
- // voucher()
}, []);
const hitungDiscountVoucher = (code) => {
@@ -240,10 +243,19 @@ 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]);
@@ -364,7 +376,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,
voucher_shipping: activeVoucherShipping,
type: 'sale_order',
@@ -381,7 +393,7 @@ const Checkout = () => {
toast.error('Gagal melakukan transaksi, terjadi kesalahan internal');
return;
}
-
+
gtagPurchase(products, biayaKirim, isCheckouted.name);
const midtrans = async () => {
@@ -425,13 +437,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);
}
};
@@ -1750,7 +1766,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'>Mobile : 0813 9000 7430</p>
+ <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>
</div>
</div>
);
diff --git a/src/lib/checkout/components/CheckoutOld.jsx b/src/lib/checkout/components/CheckoutOld.jsx
index e2c45ce6..5b479a73 100644
--- a/src/lib/checkout/components/CheckoutOld.jsx
+++ b/src/lib/checkout/components/CheckoutOld.jsx
@@ -802,7 +802,9 @@ const PickupAddress = ({ label }) => (
Daerah Khusus Ibukota Jakarta, Indonesia 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'>Mobile : 0813 9000 7430</p>
+ <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>
</div>
</div>
)
diff --git a/src/lib/checkout/components/CheckoutSection.jsx b/src/lib/checkout/components/CheckoutSection.jsx
index affe6138..623152c6 100644
--- a/src/lib/checkout/components/CheckoutSection.jsx
+++ b/src/lib/checkout/components/CheckoutSection.jsx
@@ -2,6 +2,7 @@ import Link from 'next/link';
import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
import { AnimatePresence, motion } from 'framer-motion';
import { Divider, Spinner } from '@chakra-ui/react';
+import whatsappUrl from '@/core/utils/whatsappUrl';
export const SectionAddress = ({ address, label, url }) => {
return (
@@ -185,7 +186,9 @@ export 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'>Mobile : 0813 9000 7430</p>
+ <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>
</div>
</div>
);
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx
index 98732407..e10241a7 100644
--- a/src/lib/product/components/ProductCard.jsx
+++ b/src/lib/product/components/ProductCard.jsx
@@ -14,7 +14,15 @@ import useUtmSource from '~/hooks/useUtmSource';
const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
const router = useRouter();
const utmSource = useUtmSource();
+ const [discount, setDiscount] = useState(0);
+ let voucherPastiHemat = 0;
+
+ if (product?.voucherPastiHemat.length > 0) {
+ const stringVoucher = product?.voucherPastiHemat[0];
+ const validJsonString = stringVoucher.replace(/'/g, '"');
+ voucherPastiHemat = JSON.parse(validJsonString);
+ }
const callForPriceWhatsapp = whatsappUrl('product', {
name: product.name,
@@ -38,42 +46,64 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
),
};
+ const hitungDiscountVoucher = () => {
+ let countDiscount = 0;
+ if (voucherPastiHemat.discount_type === 'percentage') {
+ countDiscount =
+ product?.lowestPrice.priceDiscount *
+ (voucherPastiHemat.discount_amount / 100);
+ if (
+ voucherPastiHemat.max_discount > 0 &&
+ countDiscount > voucherPastiHemat.max_discount
+ ) {
+ countDiscount = voucherPastiHemat.max_discount;
+ }
+ } else {
+ countDiscount = voucherPastiHemat.discount_amount;
+ }
+
+ setDiscount(countDiscount);
+ };
+
+ useEffect(() => {
+ hitungDiscountVoucher();
+ }, []);
+
if (variant == 'vertical') {
return (
- <div className='rounded shadow-sm border border-gray_r-4 bg-white h-[300px] md:h-[350px]'>
+ <div className='rounded shadow-sm border border-gray_r-4 bg-white h-[330px] md:h-[380px]'>
<Link href={URL.product} className='border-b border-gray_r-4 relative'>
- <div className="relative">
- <Image
- src={image}
- alt={product?.name}
- className="gambarA w-full object-contain object-center h-36 sm:h-48"
- />
- <div className="absolute top-0 right-0 flex mt-3">
- <div className="gambarB ">
- {product?.isSni && (
- <ImageNext
- src="/images/sni-logo.png"
- alt="SNI Logo"
- className="w-4 h-5 object-contain object-top sm:h-6"
- width={50}
- height={50}
- />
- )}
- </div>
- <div className="gambarC ">
- {product?.isTkdn && (
- <ImageNext
- src="/images/TKDN.png"
- alt="TKDN"
- className="w-11 h-6 object-contain object-top ml-1 mr-1 sm:h-6"
- width={50}
- height={50}
- />
- )}
+ <div className='relative'>
+ <Image
+ src={image}
+ alt={product?.name}
+ className='gambarA w-full object-contain object-center h-36 sm:h-48'
+ />
+ <div className='absolute top-0 right-0 flex mt-3'>
+ <div className='gambarB '>
+ {product?.isSni && (
+ <ImageNext
+ src='/images/sni-logo.png'
+ alt='SNI Logo'
+ className='w-4 h-5 object-contain object-top sm:h-6'
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ <div className='gambarC '>
+ {product?.isTkdn && (
+ <ImageNext
+ src='/images/TKDN.png'
+ alt='TKDN'
+ className='w-11 h-6 object-contain object-top ml-1 mr-1 sm:h-6'
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
</div>
</div>
- </div>
-
{router.pathname != '/' && product?.flashSale?.id > 0 && (
<div className='absolute bottom-0 w-full grid'>
@@ -178,6 +208,13 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
)}
</div>
)}
+ {discount > 0 && product?.flashSale?.id < 1 && (
+ <div className='flex gap-x-1 mb-1 text-sm'>
+ <div className='inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20'>
+ Voucher : {currencyFormat(discount)}
+ </div>
+ </div>
+ )}
<div className='flex w-full items-center gap-x-1 '>
{product?.stockTotal > 0 && (
@@ -200,37 +237,37 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
<div className='flex bg-white'>
<div className='w-4/12'>
<Link href={URL.product} className='relative'>
- <div className="relative">
- <Image
- src={image}
- alt={product?.name}
- className="gambarA w-full object-contain object-center h-36 sm:h-48"
- />
- <div className="absolute top-0 right-0 flex mt-3">
- <div className="gambarB ">
- {product?.isSni && (
- <ImageNext
- src="/images/sni-logo.png"
- alt="SNI Logo"
- className="w-4 h-5 object-contain object-top sm:h-6"
- width={50}
- height={50}
- />
- )}
- </div>
- <div className="gambarC ">
- {product?.isTkdn && (
- <ImageNext
- src="/images/TKDN.png"
- alt="TKDN"
- className="w-11 h-6 object-contain object-top ml-1 sm:h-6"
- width={50}
- height={50}
- />
- )}
+ <div className='relative'>
+ <Image
+ src={image}
+ alt={product?.name}
+ className='gambarA w-full object-contain object-center h-36 sm:h-48'
+ />
+ <div className='absolute top-0 right-0 flex mt-3'>
+ <div className='gambarB '>
+ {product?.isSni && (
+ <ImageNext
+ src='/images/sni-logo.png'
+ alt='SNI Logo'
+ className='w-4 h-5 object-contain object-top sm:h-6'
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
+ <div className='gambarC '>
+ {product?.isTkdn && (
+ <ImageNext
+ src='/images/TKDN.png'
+ alt='TKDN'
+ className='w-11 h-6 object-contain object-top ml-1 sm:h-6'
+ width={50}
+ height={50}
+ />
+ )}
+ </div>
</div>
</div>
- </div>
{product.variantTotal > 1 && (
<div className='absolute badge-gray bottom-1.5 left-1.5'>
{product.variantTotal} Varian
@@ -319,6 +356,14 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
</div>
)}
+ {discount > 0 && product?.flashSale?.id < 1 && (
+ <div className='flex gap-x-1 mb-1 text-sm'>
+ <div className='inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20'>
+ Voucher : {currencyFormat(discount)}
+ </div>
+ </div>
+ )}
+
<div className='flex w-full items-center gap-x-1 '>
{product?.stockTotal > 0 && (
<div className='badge-solid-red'>Ready Stock</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={[
{
diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js
index dd90ac7d..d4694eb2 100644
--- a/src/utils/solrMapping.js
+++ b/src/utils/solrMapping.js
@@ -38,6 +38,7 @@ export const productMappingSolr = (products, pricelist) => {
qtySold: product?.qty_sold_f || 0,
isTkdn:product?.tkdn_b || false,
isSni:product?.sni_b || false,
+ voucherPastiHemat:product?.voucher_pastihemat || []
};
if (product.manufacture_id_i && product.manufacture_name_s) {