From 0433d92034937c76135ceb83ef88402464006866 Mon Sep 17 00:00:00 2001
From: trisusilo48
Date: Mon, 22 Jul 2024 15:08:07 +0700
Subject: get new voucher
---
src/lib/checkout/api/getVoucher.js | 10 ++++++++++
src/lib/checkout/components/Checkout.jsx | 24 +++++++++++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
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..61410bdf 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,8 @@ const Checkout = () => {
}, [bottomPopup]);
useEffect(() => {
+
+ // voucher()
const loadExpedisi = async () => {
let dataExpedisi = await ExpedisiList();
dataExpedisi = dataExpedisi.map((expedisi) => ({
@@ -176,6 +182,10 @@ const Checkout = () => {
setExpedisi(dataExpedisi);
};
loadExpedisi();
+ if(qVoucher === 'PASTIHEMAT'){
+ let code = qVoucher;
+ handleUseVoucher(code, !isChecked);
+ }
const handlePopState = () => {
router.push('/shop/cart');
@@ -186,7 +196,7 @@ const Checkout = () => {
return () => {
window.onpopstate = null;
};
- // voucher()
+
}, []);
const hitungDiscountVoucher = (code) => {
@@ -407,13 +417,13 @@ 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);
}
};
--
cgit v1.2.3
From 95081416190d09bbbe4f3d745e69ff81258bde7a Mon Sep 17 00:00:00 2001
From: trisusilo48
Date: Mon, 22 Jul 2024 15:38:48 +0700
Subject: add params voucher
---
src/lib/checkout/components/Checkout.jsx | 40 +++++++++++++++++++-------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 61410bdf..9bc0257e 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -129,7 +129,7 @@ const Checkout = () => {
}
};
const VoucherCode = async (code) => {
- const source = 'code=' + code+'&source='+query;
+ const source = 'code=' + code + '&source=' + query;
// let dataVoucher = await findVoucher(code, auth.id, query);
let dataVoucher = await getVoucherNew(source);
if (dataVoucher.length <= 0) {
@@ -170,8 +170,7 @@ const Checkout = () => {
}, [bottomPopup]);
useEffect(() => {
-
- // voucher()
+ voucher();
const loadExpedisi = async () => {
let dataExpedisi = await ExpedisiList();
dataExpedisi = dataExpedisi.map((expedisi) => ({
@@ -182,10 +181,6 @@ const Checkout = () => {
setExpedisi(dataExpedisi);
};
loadExpedisi();
- if(qVoucher === 'PASTIHEMAT'){
- let code = qVoucher;
- handleUseVoucher(code, !isChecked);
- }
const handlePopState = () => {
router.push('/shop/cart');
@@ -196,7 +191,6 @@ const Checkout = () => {
return () => {
window.onpopstate = null;
};
-
}, []);
const hitungDiscountVoucher = (code) => {
@@ -231,14 +225,22 @@ const Checkout = () => {
SetDiscountVoucher(countDiscount);
}, [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);
@@ -357,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',
};
@@ -373,7 +375,7 @@ const Checkout = () => {
toast.error('Gagal melakukan transaksi, terjadi kesalahan internal');
return;
}
-
+
gtagPurchase(products, biayaKirim, isCheckouted.name);
const midtrans = async () => {
@@ -417,13 +419,17 @@ const Checkout = () => {
} else {
SetActiveVoucher(code);
SetFindVoucher(null);
- document.getElementById('uniqCode') ? document.getElementById('uniqCode').value = '' : '';
+ document.getElementById('uniqCode')
+ ? (document.getElementById('uniqCode').value = '')
+ : '';
SetButtonTerapkan(false);
}
} else {
SetActiveVoucher(code);
SetFindVoucher(null);
- document.getElementById('uniqCode') ? document.getElementById('uniqCode').value = '' : '';
+ document.getElementById('uniqCode')
+ ? (document.getElementById('uniqCode').value = '')
+ : '';
SetButtonTerapkan(false);
}
};
@@ -1599,9 +1605,11 @@ const PickupAddress = ({ label }) => (
Kodepos : 14440
Telp : 021-2933 8828/29
-
+
+
Mobile : 0817-1718-1922
-
+
+
);
--
cgit v1.2.3
From a5c8e89076f73389f0a9bef3a941553a7d6d9f01 Mon Sep 17 00:00:00 2001
From: trisusilo48
Date: Thu, 25 Jul 2024 08:54:44 +0700
Subject: CR - Title page brand detail
---
src/pages/shop/brands/[slug].jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pages/shop/brands/[slug].jsx b/src/pages/shop/brands/[slug].jsx
index c3a7299f..1e48e781 100644
--- a/src/pages/shop/brands/[slug].jsx
+++ b/src/pages/shop/brands/[slug].jsx
@@ -20,7 +20,7 @@ export default function BrandDetail() {
return (
Date: Sat, 27 Jul 2024 08:43:01 +0700
Subject: update refco page search
---
src/pages/shop/brands/[slug].jsx | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/pages/shop/brands/[slug].jsx b/src/pages/shop/brands/[slug].jsx
index c3a7299f..7c5aa699 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,6 +18,9 @@ export default function BrandDetail() {
const brandName = getNameFromSlug(slug)
const id = getIdFromSlug(slug)
const {brand} = useBrand({id})
+ if (!brand || !brand.data || _.isEmpty(brand.data)) {
+ return ;
+ }
return (
Date: Thu, 1 Aug 2024 15:34:59 +0700
Subject: fixing height card
---
src/lib/product/components/ProductCard.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx
index 283a10c6..e10241a7 100644
--- a/src/lib/product/components/ProductCard.jsx
+++ b/src/lib/product/components/ProductCard.jsx
@@ -71,7 +71,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
if (variant == 'vertical') {
return (
-
+
Date: Fri, 2 Aug 2024 08:58:03 +0700
Subject: delete console log
---
src-migrate/hooks/useUtmSource.ts | 2 +-
.../my/recomendation/components/products-recomendatison.jsx | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src-migrate/hooks/useUtmSource.ts b/src-migrate/hooks/useUtmSource.ts
index a72fae36..43fbdcae 100644
--- a/src-migrate/hooks/useUtmSource.ts
+++ b/src-migrate/hooks/useUtmSource.ts
@@ -7,7 +7,7 @@ const useUtmSource = () => {
const [source, setSource] = useState();
useEffect(() => {
- console.log(router.pathname);
+ // console.log(router.pathname);
if (router.pathname) {
setSource(UTM_SOURCE[router.pathname as keyof typeof UTM_SOURCE]);
diff --git a/src/pages/my/recomendation/components/products-recomendatison.jsx b/src/pages/my/recomendation/components/products-recomendatison.jsx
index d39d2a99..7da2fab1 100644
--- a/src/pages/my/recomendation/components/products-recomendatison.jsx
+++ b/src/pages/my/recomendation/components/products-recomendatison.jsx
@@ -80,7 +80,7 @@ const ProductsRecomendation = ({ id }) => {
}
});
- console.log('ini result', searchProduct.data.response);
+ // console.log('ini result', searchProduct.data.response);
}
return resultMapping;
@@ -112,7 +112,7 @@ const ProductsRecomendation = ({ id }) => {
setIsLoading(false);
} else {
setIsLoading(false);
- console.log('No excel data available');
+ // console.log('No excel data available');
}
};
@@ -129,7 +129,7 @@ const ProductsRecomendation = ({ id }) => {
const jsonData = XLSX.utils.sheet_to_json(worksheet);
setExcelData(jsonData);
- console.log('ini json data', jsonData);
+ // console.log('ini json data', jsonData);
setIsLoading(false);
};
@@ -146,13 +146,13 @@ const ProductsRecomendation = ({ id }) => {
products[foundIndex].result.code = variant?.code;
products[foundIndex].result.name = variant?.name;
} else {
- console.log('Data not found.');
+ // console.log('Data not found.');
}
setIsOpen(false);
};
const handlingOtherRec = ({ product }) => {
- console.log('ini product', product);
+ // console.log('ini product', product);
const result = async () =>
await searchRecomendation({ product, index: 0, operator: 'OR' });
--
cgit v1.2.3
From 2376bb4ab8f791ce6b99e70478f792b525d4d5fe Mon Sep 17 00:00:00 2001
From: it-fixcomart
Date: Fri, 2 Aug 2024 09:23:13 +0700
Subject: update fetch data promo
---
src/api/promoApi.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/api/promoApi.js b/src/api/promoApi.js
index f262db8d..3f85db8e 100644
--- a/src/api/promoApi.js
+++ b/src/api/promoApi.js
@@ -13,11 +13,11 @@ export const fetchPromoItems = async (type) => {
}
};
-export const fetchPromoItemsSolr = async (type) => {
+export const fetchPromoItemsSolr = async (type, start, rows) => {
// let query = type ? `type_value_s:${type}` : '*:*';
let sort ='sort=if(exists(sequence_i),0,1) asc, sequence_i asc, if(exists(total_qty_sold_f), total_qty_sold_f, -1) desc';
- let start = 0
- let rows = 100
+ // let start = 0
+ // let rows = 100
// let start = 0
// let rows = 10
try {
--
cgit v1.2.3
From 35204954ac02efd1497715dec3d2695fdd7976f8 Mon Sep 17 00:00:00 2001
From: it-fixcomart
Date: Fri, 2 Aug 2024 10:00:34 +0700
Subject: update form
---
src-migrate/modules/register/components/Form.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 4baaf380..b834f97a 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -168,7 +168,7 @@ const Form = () => {
--
cgit v1.2.3
From f86b2adc680a9c6fa0ac92c84bf6d14e2f866d9a Mon Sep 17 00:00:00 2001
From: it-fixcomart
Date: Fri, 2 Aug 2024 14:48:51 +0700
Subject: update popup cart
---
.../product-detail/components/AddToCart.tsx | 79 ++++++++++++++++++++--
.../product-detail/components/PriceAction.tsx | 2 +
.../product-detail/components/ProductDetail.tsx | 2 +-
.../modules/product-promo/components/AddToCart.tsx | 61 ++++++++++++++++-
.../modules/product-promo/components/Card.tsx | 10 +--
.../modules/product-promo/components/Modal.tsx | 8 ++-
.../product-promo/components/ModalContent.tsx | 8 ++-
.../modules/product-promo/components/Section.tsx | 8 ++-
src-migrate/modules/promo/components/PromoList.tsx | 4 +-
src-migrate/types/promotion.ts | 2 +
10 files changed, 159 insertions(+), 25 deletions(-)
diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index 097db98a..320b7234 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -1,19 +1,28 @@
-import { Button, useToast } from '@chakra-ui/react'
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
+import { Button, Link, useToast } from '@chakra-ui/react'
+import product from 'next-seo/lib/jsonld/product'
import { useRouter } from 'next/router'
-
+import { useState } from 'react'
+import Image from '~/components/ui/image'
import { getAuth } from '~/libs/auth'
import { upsertUserCart } from '~/services/cart'
-
+import LazyLoad from 'react-lazy-load';
+import ProductSimilar from '../../../../src/lib/product/components/ProductSimilar';
+import { IProductDetail } from '~/types/product';
+import ImageNext from 'next/image';
+import { useProductCartContext } from '@/contexts/ProductCartContext'
type Props = {
variantId: number | null,
quantity?: number;
source?: 'buy' | 'add_to_cart';
+ products : IProductDetail
}
const AddToCart = ({
variantId,
quantity = 1,
- source = 'add_to_cart'
+ source = 'add_to_cart',
+ products
}: Props) => {
const auth = getAuth()
const router = useRouter()
@@ -22,6 +31,18 @@ const AddToCart = ({
isClosable: true
})
+ const [product, setProducts] = useState(products);
+
+ const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
+ useProductCartContext()
+
+ const productSimilarQuery = [
+ product?.name,
+ `fq=-product_id_i:${product.id}`,
+ `fq=-manufacture_id_i:${product.manufacture?.id || 0}`,
+ ].join('&');
+ const [addCartAlert, setAddCartAlert] = useState(false);
+
const handleClick = async () => {
if (typeof auth !== 'object') {
const currentUrl = encodeURIComponent(router.asPath)
@@ -35,6 +56,9 @@ const AddToCart = ({
typeof auth !== 'object'
) return;
+ setRefreshCart(true);
+ setAddCartAlert(true);
+
toast.promise(
upsertUserCart({
userId: auth.id,
@@ -69,9 +93,50 @@ const AddToCart = ({
}
return (
-
+
+
+
{
+ setAddCartAlert(false);
+ }}
+ >
+
+
+
+
+
+ {product.name}
+
+
+
+ Lihat Keranjang
+
+
+
+
+
+ Kamu Mungkin Juga Suka
+
+
+
+
+
+
+
)
}
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index 81271f6e..9021264e 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -97,12 +97,14 @@ const PriceAction = ({ product }: Props) => {
className={style['quantity-input']}
/>
{!isApproval && (
diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx
index fad35a7d..e4555913 100644
--- a/src-migrate/modules/product-detail/components/ProductDetail.tsx
+++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx
@@ -129,7 +129,7 @@ const ProductDetail = ({ product }: Props) => {
)}
- {!!activeVariantId && !isApproval && }
+ {!!activeVariantId && !isApproval && }
diff --git a/src-migrate/modules/product-promo/components/AddToCart.tsx b/src-migrate/modules/product-promo/components/AddToCart.tsx
index 87017c14..10904f90 100644
--- a/src-migrate/modules/product-promo/components/AddToCart.tsx
+++ b/src-migrate/modules/product-promo/components/AddToCart.tsx
@@ -9,19 +9,34 @@ import { IPromotion } from '~/types/promotion'
import DesktopView from '../../../../src/core/components/views/DesktopView';
import MobileView from '../../../../src/core/components/views/MobileView';
-
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
+import ImageNext from 'next/image';
+import Link from 'next/link'
+import LazyLoad from 'react-lazy-load'
+import ProductSimilar from '../../../../src/lib/product/components/ProductSimilar';
+import { IProductDetail } from '~/types/product';
+import { useProductCartContext } from '@/contexts/ProductCartContext'
type Props = {
promotion: IPromotion
+ product: IProductDetail
}
type Status = 'idle' | 'loading' | 'success'
-const ProductPromoAddToCart = ({ promotion }: Props) => {
+const ProductPromoAddToCart = ({product, promotion }: Props) => {
const auth = getAuth()
const toast = useToast()
const router = useRouter()
const [status, setStatus] = useState('idle')
+ const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
+ useProductCartContext()
+
+ const productSimilarQuery = [
+ promotion?.name,
+ `fq=-product_id_i:${promotion.products[0].product_id}`,
+ ].join('&');
+ const [addCartAlert, setAddCartAlert] = useState(false);
const handleButton = async () => {
if (typeof auth !== 'object') {
@@ -42,7 +57,8 @@ const ProductPromoAddToCart = ({ promotion }: Props) => {
qtyAppend: true
})
setStatus('idle')
-
+ setRefreshCart(true);
+ setAddCartAlert(true);
toast({
title: 'Tambah ke keranjang',
description: 'Berhasil menambahkan barang ke keranjang belanja',
@@ -92,6 +108,45 @@ const ProductPromoAddToCart = ({ promotion }: Props) => {
{status === 'success' && Berhasil}
{status !== 'success' && Keranjang}
+ {
+ setAddCartAlert(false);
+ }}
+ >
+
+
+
+
+
+ {product.name}
+
+
+
+ Lihat Keranjang
+
+
+
+
+
+ Kamu Mungkin Juga Suka
+
+
+
+
+
+
)
diff --git a/src-migrate/modules/product-promo/components/Card.tsx b/src-migrate/modules/product-promo/components/Card.tsx
index 728d23ca..5c323276 100644
--- a/src-migrate/modules/product-promo/components/Card.tsx
+++ b/src-migrate/modules/product-promo/components/Card.tsx
@@ -15,16 +15,16 @@ import clsxm from '~/libs/clsxm'
import ProductPromoItem from './Item'
import ProductPromoAddToCart from "./AddToCart"
import ProductPromoCardCountdown from "./CardCountdown"
-
+import { IProductDetail } from '~/types/product';
import MobileView from '../../../../src/core/components/views/MobileView';
import DesktopView from '../../../../src/core/components/views/DesktopView';
type Props = {
promotion: IPromotion
-
+ product: IProductDetail
}
-const ProductPromoCard = ({ promotion}: Props) => {
+const ProductPromoCard = ({product, promotion}: Props) => {
const [products, setProducts] = useState([])
const [freeProducts, setFreeProducts] = useState([])
const [error, setError] = useState(null)
@@ -132,7 +132,7 @@ const ProductPromoCard = ({ promotion}: Props) => {
@@ -189,7 +189,7 @@ const ProductPromoCard = ({ promotion}: Props) => {
diff --git a/src-migrate/modules/product-promo/components/Modal.tsx b/src-migrate/modules/product-promo/components/Modal.tsx
index 0de672c2..1722b9df 100644
--- a/src-migrate/modules/product-promo/components/Modal.tsx
+++ b/src-migrate/modules/product-promo/components/Modal.tsx
@@ -3,8 +3,12 @@ import { Modal } from "~/components/ui/modal"
import { useModalStore } from '../stores/useModalStore'
import ProductPromoCategoryTab from './CategoryTab'
import ProductPromoModalContent from './ModalContent'
+import { IProductDetail } from '~/types/product';
-const ProductPromoModal = () => {
+type Props = {
+ product: IProductDetail
+}
+const ProductPromoModal = ({product}:Props) => {
const { active, closeModal } = useModalStore()
return (
@@ -17,7 +21,7 @@ const ProductPromoModal = () => {
-
+
)
}
diff --git a/src-migrate/modules/product-promo/components/ModalContent.tsx b/src-migrate/modules/product-promo/components/ModalContent.tsx
index ab5129f8..256ef61a 100644
--- a/src-migrate/modules/product-promo/components/ModalContent.tsx
+++ b/src-migrate/modules/product-promo/components/ModalContent.tsx
@@ -6,7 +6,11 @@ import { getVariantPromoByCategory } from "~/services/productVariant"
import { useModalStore } from "../stores/useModalStore"
import ProductPromoCard from "./Card"
-const ProductPromoModalContent = () => {
+import { IProductDetail } from '~/types/product';
+type Props = {
+ product: IProductDetail
+}
+const ProductPromoModalContent = ({product}:Props) => {
const { activeTab, variantId } = useModalStore()
const promotionsQuery = useQuery(
@@ -24,7 +28,7 @@ const ProductPromoModalContent = () => {
{promotions?.data.map((promo) => (
-
+
))}
{promotions?.data.length === 0 && (
Belum ada promo pada kategori ini
diff --git a/src-migrate/modules/product-promo/components/Section.tsx b/src-migrate/modules/product-promo/components/Section.tsx
index 4e8a7dd5..2c94c2bb 100644
--- a/src-migrate/modules/product-promo/components/Section.tsx
+++ b/src-migrate/modules/product-promo/components/Section.tsx
@@ -9,12 +9,14 @@ import { IPromotion } from '~/types/promotion'
import { useModalStore } from "../stores/useModalStore"
import ProductPromoCard from './Card'
import ProductPromoModal from "./Modal"
+import { IProductDetail } from '~/types/product';
type Props = {
productId: number;
+ product: IProductDetail;
}
-const ProductPromoSection = ({ productId }: Props) => {
+const ProductPromoSection = ({ product, productId }: Props) => {
const promotionsQuery = useQuery({
queryKey: [`promotions.highlight`, productId],
queryFn: async () => await fetch(`/api/product-variant/${productId}/promotion/highlight`).then((res) => res.json()) as { data: IPromotion[] }
@@ -30,7 +32,7 @@ const ProductPromoSection = ({ productId }: Props) => {
height='450px'
duration='700ms'
>
-
+
{promotions?.data && promotions?.data.length > 0 && (
@@ -50,7 +52,7 @@ const ProductPromoSection = ({ productId }: Props) => {
>
{promotions?.data.map((promotion) => (
))}
diff --git a/src-migrate/modules/promo/components/PromoList.tsx b/src-migrate/modules/promo/components/PromoList.tsx
index 42725034..4d0db3c2 100644
--- a/src-migrate/modules/promo/components/PromoList.tsx
+++ b/src-migrate/modules/promo/components/PromoList.tsx
@@ -114,7 +114,7 @@ const PromoList: React.FC
= ({ selectedPromo }) => {
{promoData?.map((promotion: IPromotion) => (
))}
@@ -122,7 +122,7 @@ const PromoList: React.FC = ({ selectedPromo }) => {
)}
{isMobile && (promoData?.map((promotion: IPromotion) => (
)))}
diff --git a/src-migrate/types/promotion.ts b/src-migrate/types/promotion.ts
index 85190aad..10f6d8b0 100644
--- a/src-migrate/types/promotion.ts
+++ b/src-migrate/types/promotion.ts
@@ -10,10 +10,12 @@ export interface IPromotion {
limit_user: number;
limit_trx: number;
price: number;
+ image: string;
total_qty: number;
products: {
product_id: number;
qty: number;
+ name: string;
}[];
free_products: {
product_id: number;
--
cgit v1.2.3
From d57ca7be5e2de9c48f4229b20a49a94bf05e88d1 Mon Sep 17 00:00:00 2001
From: it-fixcomart
Date: Fri, 2 Aug 2024 14:55:16 +0700
Subject: update cart pop up
---
src/lib/cart/components/Cartheader.jsx | 259 ++++++++++++++++++++++++++++++++-
1 file changed, 257 insertions(+), 2 deletions(-)
diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx
index 19f79bc9..e3a5cc1f 100644
--- a/src/lib/cart/components/Cartheader.jsx
+++ b/src/lib/cart/components/Cartheader.jsx
@@ -4,7 +4,12 @@ import useAuth from '@/core/hooks/useAuth'
import { useRouter } from 'next/router'
import odooApi from '@/core/api/odooApi'
import { useProductCartContext } from '@/contexts/ProductCartContext'
-
+import currencyFormat from '@/core/utils/currencyFormat'
+import Image from '@/core/components/elements/Image/Image'
+import { createSlug } from '@/core/utils/slug'
+import whatsappUrl from '@/core/utils/whatsappUrl'
+import { AnimatePresence, motion } from 'framer-motion'
+import style from '../../../../src-migrate/modules/cart/styles/item-promo.module.css'
const { ShoppingCartIcon, PhotoIcon } = require('@heroicons/react/24/outline')
const { default: Link } = require('next/link')
@@ -19,7 +24,7 @@ const Cardheader = (cartCount) => {
useProductCartContext()
const [isHovered, setIsHovered] = useState(false)
-
+ const [isTop, setIsTop] = useState(true)
const products = useMemo(() => {
return productCart?.products || []
}, [productCart])
@@ -77,6 +82,16 @@ const Cardheader = (cartCount) => {
setCountCart(cartCount.cartCount)
}, [cartCount])
+ useEffect(() => {
+ const handleScroll = () => {
+ setIsTop(window.scrollY === 0)
+ }
+ window.addEventListener('scroll', handleScroll)
+ return () => {
+ window.removeEventListener('scroll', handleScroll)
+ }
+ }, [])
+
const handleCheckout = async () => {
SetButtonTerapkan(true)
let checkoutAll = await odooApi('POST', `/api/v1/user/${auth.id}/cart/select-all`)
@@ -109,6 +124,246 @@ const Cardheader = (cartCount) => {
+
+ {isHovered && (
+ <>
+
+
+
+
+
Keranjang Belanja
+
+ Lihat Semua
+
+
+
+
+ {!auth && (
+
+
+ Silahkan{' '}
+
+ Login
+ {' '}
+ Untuk Melihat Daftar Keranjang Belanja Anda
+
+
+ )}
+ {isLoading &&
+ itemLoading.map((item) => (
+
+ ))}
+ {auth && products.length === 0 && !isLoading && (
+
+
+ Tidak Ada Produk di Keranjang Belanja Anda
+
+
+ )}
+ {auth && products.length > 0 && !isLoading && (
+ <>
+
+ {products &&
+ products?.map((product, index) => (
+ <>
+ -
+
+
+ {product.cartType === 'promotion' && (
+
+ )}
+ {product.cartType === 'product' && (
+
+
+
+ )}
+
+
+ {product.cartType === 'promotion' && (
+
+ {product.name}
+
+ )}
+ {product.cartType === 'product' && (
+
+ {' '}
+
+ {product.parent.name}
+
+
+ )}
+ {product?.hasFlashsale && (
+
+
+ {product?.price?.discountPercentage}%
+
+
+ {currencyFormat(product?.price?.price)}
+
+
+ )}
+
+
+
+ {product?.price?.priceDiscount > 0 ? (
+ currencyFormat(product?.price?.priceDiscount)
+ ) : (
+
+
+ Call For Price
+
+
+ )}
+
+
+
+
+
+ {product.products?.map((product) =>
+
+
+ {product?.image &&
}
+
+
+
+
+ {product.displayName}
+
+
+
+
+ {/*
{product.code}
*/}
+
+ Berat Barang:
+ {product.packageWeight} Kg
+
+
+
+
+
+
+ )}
+ {product.freeProducts?.map((product) =>
+
+
+ {product?.image &&
}
+
+
+
+
+ {product.displayName}
+
+
+
+
+ {/*
{product.code}
*/}
+
+ Berat Barang:
+ {product.packageWeight} Kg
+
+
+
+
+
+
+ )}
+
+
+ >
+ ))}
+
+
+ >
+ )}
+
+ {auth && products.length > 0 && !isLoading && (
+ <>
+
+ Subtotal Sebelum PPN :
+ {currencyFormat(subTotal)}
+
+
+
+
+ >
+ )}
+
+
+ >
+ )}
+
)
}
--
cgit v1.2.3