From e07a57651649cb2493e5b00a361797cf1392a186 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 1 Aug 2024 11:59:26 +0700 Subject: update template switch --- .../components/Product/ProductDesktopVariant.jsx | 66 ++++++++++++++++++-- .../components/Product/ProductMobileVariant.jsx | 71 +++++++++++++++++++--- 2 files changed, 123 insertions(+), 14 deletions(-) diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 09b30a44..882673f4 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -6,6 +6,11 @@ import { useRouter } from 'next/router'; import { useCallback, useEffect, useRef, useState } from 'react'; import { toast } from 'react-hot-toast'; import LazyLoad from 'react-lazy-load'; +import { Button } from '@chakra-ui/react' +import { MessageCircleIcon, Share2Icon } from 'lucide-react' +import AddToWishlist from '../../../../../src-migrate/modules/product-detail/components/AddToWishlist' +import { RWebShare } from 'react-web-share' +// import Link from 'next/link' import { useProductCartContext } from '@/contexts/ProductCartContext'; import odooApi from '@/core/api/odooApi'; @@ -18,11 +23,14 @@ import { updateItemCart } from '@/core/utils/cart'; import currencyFormat from '@/core/utils/currencyFormat'; import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; +import Breadcrumb from '../../../../../src-migrate/modules/product-detail/components/Breadcrumb'; import productSimilarApi from '../../api/productSimilarApi'; import ProductCard from '../ProductCard'; import ProductSimilar from '../ProductSimilar'; +const SELF_HOST = process.env.NEXT_PUBLIC_SELF_HOST + const ProductDesktopVariant = ({ product, wishlist, @@ -32,7 +40,7 @@ const ProductDesktopVariant = ({ const router = useRouter(); const auth = useAuth(); const { slug } = router.query; - + const [ askAdminUrl, setAskAdminUrl ] = useState() const [lowestPrice, setLowestPrice] = useState(null); const [addCartAlert, setAddCartAlert] = useState(false); @@ -53,6 +61,20 @@ const ProductDesktopVariant = ({ setLowestPrice(lowest); }, [getLowestPrice]); + useEffect(() => { + const createdAskUrl = whatsappUrl({ + template: 'product', + payload: { + manufacture: product.manufacture.name, + productName: product.name, + url: process.env.NEXT_PUBLIC_SELF_HOST + router.asPath + }, + fallbackUrl: router.asPath + }) + + setAskAdminUrl(createdAskUrl) + }, [router.asPath, product.manufacture.name, product.name, setAskAdminUrl]) + const [informationTab, setInformationTab] = useState( informationTabOptions[0].value ); @@ -154,6 +176,7 @@ const ProductDesktopVariant = ({ return (
+
@@ -263,9 +286,42 @@ const ProductDesktopVariant = ({
+
+
+ + + + + + + +
+ -
+ +

Informasi Produk

-
+
{product?.isFlashsale > 0 && product?.price?.discountPercentage > 0 ? ( <> @@ -359,7 +415,7 @@ const ProductDesktopVariant = ({ Beli
-
+ {/*
+
*/}
Produk Serupa diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index af9e52bb..ce836d5b 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -16,9 +16,15 @@ import currencyFormat from '@/core/utils/currencyFormat'; import { gtagAddToCart } from '@/core/utils/googleTag'; import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; - +import Breadcrumb from '../../../../../src-migrate/modules/product-detail/components/Breadcrumb'; +import { Button } from '@chakra-ui/react' +import { MessageCircleIcon, Share2Icon } from 'lucide-react' +import AddToWishlist from '../../../../../src-migrate/modules/product-detail/components/AddToWishlist' +import { RWebShare } from 'react-web-share' import ProductSimilar from '../ProductSimilar'; +const SELF_HOST = process.env.NEXT_PUBLIC_SELF_HOST + const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { const router = useRouter(); @@ -28,7 +34,7 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { informationTabOptions[0].value ); const [addCartAlert, setAddCartAlert] = useState(false); - + const [ askAdminUrl, setAskAdminUrl ] = useState() const [isLoadingSLA, setIsLoadingSLA] = useState(true); const getLowestPrice = () => { @@ -60,6 +66,20 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { } }, [selectedVariant, product]); + useEffect(() => { + const createdAskUrl = whatsappUrl({ + template: 'product', + payload: { + manufacture: product.manufacture.name, + productName: product.name, + url: process.env.NEXT_PUBLIC_SELF_HOST + router.asPath + }, + fallbackUrl: router.asPath + }) + + setAskAdminUrl(createdAskUrl) + }, [router.asPath, product.manufacture.name, product.name, setAskAdminUrl]) + const validAction = () => { let isValid = true; if (!selectedVariant) { @@ -120,14 +140,17 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { return ( +
+ +
{product.name}
-
+
{product.manufacture?.name ? ( { ) : (
-
)} - + + + + + + +
+ {/* + */}
-

{activeVariant?.name}

+

{activeVariant?.name}

{activeVariant.isFlashSale && activeVariant?.price?.discountPercentage > 0 ? ( @@ -173,11 +226,11 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => {
) : ( -

+

{activeVariant?.price?.price > 0 ? ( <> {currencyFormat(activeVariant?.price?.price)} -
+
Termasuk PPN:{' '} {currencyFormat( activeVariant?.price.price * process.env.NEXT_PUBLIC_PPN -- cgit v1.2.3 From bd62835db7dc521a17d6b0aea81badaae6ade95c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 2 Aug 2024 16:47:42 +0700 Subject: update template switch --- .../product-card/components/ProductCard.tsx | 150 ++++++++++++++++++--- src-migrate/services/product.ts | 37 ++++- src-migrate/types/product.ts | 6 +- 3 files changed, 171 insertions(+), 22 deletions(-) diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx index 0febfadb..3e34d5c3 100644 --- a/src-migrate/modules/product-card/components/ProductCard.tsx +++ b/src-migrate/modules/product-card/components/ProductCard.tsx @@ -10,6 +10,10 @@ import formatCurrency from '~/libs/formatCurrency' import { formatToShortText } from '~/libs/formatNumber' import { createSlug } from '~/libs/slug' import { IProduct } from '~/types/product' +import { useRouter } from 'next/router'; +import currencyFormat from '@/core/utils/currencyFormat'; +import whatsappUrl from '@/core/utils/whatsappUrl'; +import { sellingProductFormat } from '@/core/utils/formatValue'; type Props = { product: IProduct @@ -18,7 +22,14 @@ type Props = { const ProductCard = ({ product, layout = 'vertical' }: Props) => { const utmSource = useUtmSource() - + const router = useRouter(); + + const id = product.id.toString () + const callForPriceWhatsapp = whatsappUrl('product', { + name: product.name, + manufacture: product.manufacture?.name, + url: createSlug('/shop/product/', product.name, id, true), + }); const URL = { product: createSlug('/shop/product/', product.name, product.id.toString()) + `?utm_source=${utmSource}`, @@ -75,6 +86,42 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {

+ {layout === 'vertical' && ( +
+ {router.pathname != '/' && product?.flash_sale.id > 0 && ( +
+
+ +
+
+
+
+ + {Math.floor(product?.lowest_price.discount_percentage ? product?.lowest_price.discount_percentage : product?.lowest_price.discountPercentage)}% + +
+
+ + + {product?.flash_sale?.tag != 'false' || + product?.flash_sale?.tag + ? product?.flash_sale?.tag + : 'FLASH SALE'} + +
+
+
+
+ )} +
+ )} {product.variant_total > 1 && (
{product.variant_total} Varian
@@ -86,6 +133,24 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { [style['content-v']]: layout === 'vertical', [style['content-h']]: layout === 'horizontal', })}> + {layout === 'horizontal' && ( +
+ {product.flash_sale.id > 0 && ( +
+ + + {' '} + {product?.flash_sale?.tag != 'false' || product?.flash_sale?.tag + ? product?.flash_sale?.tag + : 'FLASH SALE'} + +
+ )} +
+ )} { {product.name}
- -
+ {product?.flash_sale?.id > 0 ? (
) : + ( +
Rp {formatCurrency(product.lowest_price.price)}
+ ) + } + +
-
- Inc PPN: - Rp {formatCurrency(Math.round(product.lowest_price.price * 1.11))} -
+ {product?.flash_sale?.id > 0 && + product?.lowest_price?.discountPercentage > 0 ? ( + <> + {product?.lowest_price.discountPercentage > 0 && ( +
+
+ {Math.floor(product?.lowest_price.discount_percentage ? product?.lowest_price.discount_percentage : product?.lowest_price.discountPercentage)}% +
+
+ {currencyFormat(product?.lowest_price?.price)} +
+
+ )} -
+
+ {product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount > 0 ? ( + currencyFormat(product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount) + ) : ( + + Call for Inquiry + + )} +
+
+ {product?.stockTotal > 0 && ( +
Ready Stock
+ )} + {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} + {product?.qtySold > 0 && ( +
+ {sellingProductFormat(product?.qtySold) + ' Terjual'} +
+ )} +
+ + ) : ( +
+
+ Inc PPN: + Rp {formatCurrency(Math.round(product.lowest_price.price * 1.11))} +
-
- {product.stock_total > 0 && ( -
- Ready Stock -
- )} - {product.qty_sold > 0 && ( -
- {formatToShortText(product.qty_sold)} Terjual +
+ +
+ {product.stock_total > 0 && ( +
+ Ready Stock +
+ )} + {product.qty_sold > 0 && ( +
+ {formatToShortText(product.qty_sold)} Terjual +
+ )} +
)} -
+
diff --git a/src-migrate/services/product.ts b/src-migrate/services/product.ts index fe415d11..51667eb9 100644 --- a/src-migrate/services/product.ts +++ b/src-migrate/services/product.ts @@ -2,6 +2,7 @@ import { IProduct, IProductDetail } from '~/types/product'; import snakeCase from 'snakecase-keys'; import odooApi from '~/libs/odooApi'; import { ICategoryBreadcrumb } from '~/types/category'; +import productSearchApi from '../../src/lib/product/api/productSearchApi' const SELF_HOST = process.env.NEXT_PUBLIC_SELF_HOST; @@ -40,6 +41,27 @@ export const getProductSimilar = async ({ except, limit = 30, }: GetProductSimilarProps): Promise => { + let dataflashSale = null + const flashSale = await odooApi('GET', '/api/v1/flashsale/header') + if (flashSale && flashSale.length > 0) { + const dataFlash = await productSearchApi({ + query: `fq=flashsale_id_i:${flashSale[0].pricelist_id}&fq=flashsale_price_f:[1 TO *]&limit=4`, + operation: 'AND' + }) + + dataflashSale = dataFlash.response.products.map((product: { + qtySold: any; + stockTotal: any; + flashSale: any; lowestPrice: any; +}) => ({ + ...product, + lowest_price: product.lowestPrice, + flash_sale: product.flashSale, + stock_total: product.stockTotal, + qty_sold: product.qtySold, + lowestPrice: undefined + })); + } const query = [ `q=${name}`, 'page=1', @@ -47,16 +69,25 @@ export const getProductSimilar = async ({ 'operation=OR', 'priceFrom=1', ]; - if (except?.productId) query.push(`fq=-product_id_i:${except.productId}`); if (except?.manufactureId) query.push(`fq=-manufacture_id_i:${except.manufactureId}`); - const url = `${SELF_HOST}/api/shop/search?${query.join('&')}`; - return await fetch(url) + const fetchedData = await fetch(url) .then((res) => res.json()) .then((res) => snakeCase(res.response)); + + if (dataflashSale) { + fetchedData.products = [ + ...dataflashSale, + ...fetchedData.products + ] + } else { + fetchedData.products = [...fetchedData.products] + } + + return fetchedData; }; export const getProductCategoryBreadcrumb = async ( diff --git a/src-migrate/types/product.ts b/src-migrate/types/product.ts index 681cdc8e..75d55002 100644 --- a/src-migrate/types/product.ts +++ b/src-migrate/types/product.ts @@ -1,6 +1,8 @@ import { IProductVariantDetail } from './productVariant'; export interface IProduct { + qtySold: number; + stockTotal: number; id: number; image: string; code: string; @@ -18,11 +20,13 @@ export interface IProduct { name: string; }[]; flash_sale: { - id: string; + id: number; remaining_time: number; tag: string; }; lowest_price: { + priceDiscount: number; + discountPercentage: number; price: number; price_discount: number; discount_percentage: number; -- cgit v1.2.3 From 77d01b81d46dfb2d20fec48246be4293f1d8fe69 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 5 Aug 2024 09:30:38 +0700 Subject: update error code --- src/lib/cart/components/Cartheader.jsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index f76634ce..6915d4f6 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -7,9 +7,6 @@ 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' -- cgit v1.2.3 From 574754df6366cd693fbe2cd04a7a50fdf9597d1e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 5 Aug 2024 09:35:30 +0700 Subject: update error --- src/lib/cart/components/Cartheader.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index 6915d4f6..f76634ce 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -7,6 +7,9 @@ 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' -- cgit v1.2.3 From 04c73b4da52658b0060a20bbd100a8fdacd68ef9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 5 Aug 2024 09:47:26 +0700 Subject: Revert " update error code" This reverts commit 70ec90799154dab2da475e840d8277d85648483b. --- src/lib/cart/components/Cartheader.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index c7a8f0b8..30e89317 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -6,6 +6,9 @@ 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 Image from '@/core/components/elements/Image/Image' import whatsappUrl from '@/core/utils/whatsappUrl' import { AnimatePresence, motion } from 'framer-motion' -- cgit v1.2.3 From 53d4cc076bbf52b1c4220df912755513e4bb5864 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 5 Aug 2024 09:53:48 +0700 Subject: Revert " update error code" This reverts commit 70ec90799154dab2da475e840d8277d85648483b. --- src/lib/cart/components/Cartheader.jsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index 30e89317..c7a8f0b8 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -6,9 +6,6 @@ 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 Image from '@/core/components/elements/Image/Image' import whatsappUrl from '@/core/utils/whatsappUrl' import { AnimatePresence, motion } from 'framer-motion' -- cgit v1.2.3 From 73c8846a85e4ddd1a5806aaf82f831cf8e718b83 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 5 Aug 2024 10:14:19 +0700 Subject: update unchek cart --- src-migrate/modules/cart/components/ItemSelect.tsx | 26 +++++++------- src-migrate/modules/cart/stores/useCartStore.ts | 11 +++++- src-migrate/pages/shop/cart/index.tsx | 42 ++++++++++++++++++---- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src-migrate/modules/cart/components/ItemSelect.tsx b/src-migrate/modules/cart/components/ItemSelect.tsx index b904a1de..2faf5172 100644 --- a/src-migrate/modules/cart/components/ItemSelect.tsx +++ b/src-migrate/modules/cart/components/ItemSelect.tsx @@ -13,23 +13,23 @@ type Props = { const CartItemSelect = ({ item }: Props) => { const auth = getAuth() - const { loadCart } = useCartStore() + const { updateCartItem, cart } = useCartStore() const [isLoad, setIsLoad] = useState(false) const handleChange = async (e: React.ChangeEvent) => { - if (typeof auth !== 'object') return - - setIsLoad(true) - await upsertUserCart({ - userId: auth.id, - type: item.cart_type, - id: item.id, - qty: item.quantity, - selected: e.target.checked - }) - await loadCart(auth.id) - setIsLoad(false) + if (typeof auth !== 'object' || !cart) return + + setIsLoad(true); + const updatedCartItems = cart.products.map(cartItem => + cartItem.id === item.id + ? { ...cartItem, selected: e.target.checked } + : cartItem + ); + // Update the entire cart + const updatedCart = { ...cart, products: updatedCartItems }; + updateCartItem(updatedCart); + setIsLoad(false); } return ( diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts index 3d9a0aed..ae551846 100644 --- a/src-migrate/modules/cart/stores/useCartStore.ts +++ b/src-migrate/modules/cart/stores/useCartStore.ts @@ -1,5 +1,5 @@ import { create } from 'zustand'; -import { CartProps } from '~/types/cart'; +import { CartItem, CartProps } from '~/types/cart'; import { getUserCart } from '~/services/cart'; type State = { @@ -16,6 +16,7 @@ type State = { type Action = { loadCart: (userId: number) => Promise; + updateCartItem: (updateCart: CartProps) => void; }; export const useCartStore = create((set, get) => ({ @@ -39,6 +40,14 @@ export const useCartStore = create((set, get) => ({ const summary = computeSummary(cart); set({ summary }); }, + updateCartItem: (updatedCart) => { + const cart = get().cart; + if (!cart) return; + + set({ cart: updatedCart }); + const summary = computeSummary(updatedCart); + set({ summary }); + }, })); const computeSummary = (cart: CartProps) => { diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index f33dde09..cfb20284 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -1,6 +1,6 @@ import style from './cart.module.css'; -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import Link from 'next/link'; import { Button, Checkbox, Spinner, Tooltip } from '@chakra-ui/react'; import { toast } from 'react-hot-toast'; @@ -28,10 +28,12 @@ const CartPage = () => { const [buttonSelectNow, setButtonSelectNow] = useState(true); const [isLoad, setIsLoad] = useState(false) const [isLoadDelete, setIsLoadDelete] = useState(false) - const { loadCart, cart, summary } = useCartStore(); + const { loadCart, cart, summary, updateCartItem } = useCartStore(); const useDivvice = useDevice(); const { setRefreshCart } = useProductCartContext() const [isTop, setIsTop] = useState(true); + const [hasChanged, setHasChanged] = useState(false); + const prevCartRef = useRef(null); useEffect(() => { const handleScroll = () => { @@ -76,6 +78,7 @@ const CartPage = () => { setHasChanged(false) } + // Update the ref to the current cart state prevCartRef.current = cart ? [...cart.products] : null; }, [cart]); @@ -99,6 +102,31 @@ const CartPage = () => { return cart.products.every(item => item.selected); }, [cart]); + + useEffect(() => { + const updateCartItems = async () => { + if (typeof auth === 'object' && cart) { + const upsertPromises = cart.products.map(item => + upsertUserCart({ + userId: auth.id, + type: item.cart_type, + id: item.id, + qty: item.quantity, + selected: item.selected + }) + ); + try { + await Promise.all(upsertPromises); + await loadCart(auth.id); + } catch (error) { + console.error('Failed to update cart items:', error); + } + } + }; + + updateCartItems(); + }, [hasChanged]); + const handleCheckout = () => { router.push('/shop/checkout'); } @@ -113,7 +141,7 @@ const CartPage = () => { const handleChange = async (e: React.ChangeEvent) => { - + // Ensure that cart is not null before attempting to update if (cart) { const updatedCart = { ...cart, @@ -123,7 +151,7 @@ const CartPage = () => { })) }; - updateCartItem(updatedCart); + updateCartItem(updatedCart); // Pass only valid CartProps to updateCartItem if(hasSelectedAll){ setIsSelectedAll(false); }else{ @@ -149,7 +177,7 @@ const CartPage = () => { return ( <> -
+
Keranjang Belanja
@@ -167,7 +195,7 @@ const CartPage = () => { /> )}

- {hasSelectedAll ? "Unchek all" : "Select all"} + {hasSelectedAll ? "Uncheck all" : "Select all"}

@@ -181,7 +209,7 @@ const CartPage = () => { variant='outline' colorScheme='red' w='full' - isDisabled={!hasSelected || hasSelectNoPrice} + isDisabled={!hasSelected} onClick={handleDelete} > {isLoadDelete && } -- cgit v1.2.3 From 6bfa8b7b0c6afaec7eb3d81983d0f012953b07f2 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 11:49:54 +0700 Subject: add pop up semua promo --- .../components/elements/Navbar/NavbarDesktop.jsx | 70 ++++++++++++++++++---- src/core/components/elements/Navbar/TopBanner.jsx | 9 ++- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 7d9e4264..ff43d4a0 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -10,11 +10,12 @@ import { ChevronDownIcon, DocumentCheckIcon, HeartIcon, + ArrowUpRightIcon, } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import Image from 'next/image'; import { useRouter } from 'next/router'; -import { useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import DesktopView from '../../views/DesktopView'; import Link from '../Link/Link'; import NavbarUserDropdown from './NavbarUserDropdown'; @@ -47,6 +48,46 @@ const NavbarDesktop = () => { const { product } = useProductContext(); const { isOpen, onOpen, onClose } = useDisclosure(); + const [showPopup, setShowPopup] = useState(false); + const [isTop, setIsTop] = useState(true); + + const handleTopBannerLoad = useCallback(() => { + const showTimer = setTimeout(() => { + setShowPopup(true); + }, 500); + + const hideTimer = setTimeout(() => { + setShowPopup(false); + }, 9500); + + return () => { + clearTimeout(showTimer); + clearTimeout(hideTimer); + }; + }, []); + + useEffect(() => { + const handleScroll = () => { + setIsTop(window.scrollY < 100); + }; + + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + + useEffect(() => { + const handleScroll = () => { + setIsTop(window.scrollY < 100); + }; + + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + useEffect(() => { if (router.pathname === '/shop/product/[slug]') { setPayloadWa({ @@ -79,7 +120,7 @@ const NavbarDesktop = () => { return ( - +
@@ -204,6 +245,7 @@ const NavbarDesktop = () => {
+ { rel="noreferrer" >

Semua Promo

- {/*
- promo -
*/} - + {showPopup && router.pathname === '/' && ( +
+

+ Penawaran Terbatas +

+
+ )} + {/* {showPopup && router.pathname === '/' && ( +
+ +
+ )} */} + { +const TopBanner = ({ onLoad }) => { const topBanner = useQuery({ queryKey: 'topBanner', queryFn: async () => await odooApi('GET', '/api/v1/banner?type=top-banner'), @@ -16,6 +17,12 @@ const TopBanner = () => { const hasData = topBanner.data?.length > 0; const data = topBanner.data?.[0] || null; + useEffect(() => { + if (hasData) { + onLoad(); + } + }, [hasData, onLoad]); + return ( Date: Wed, 7 Aug 2024 13:14:27 +0700 Subject: add penwaran terbatas popup --- public/images/penawaran-terbatas.svg | 24 ++++++++++++++++++++++ .../components/elements/Navbar/NavbarDesktop.jsx | 18 +++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 public/images/penawaran-terbatas.svg diff --git a/public/images/penawaran-terbatas.svg b/public/images/penawaran-terbatas.svg new file mode 100644 index 00000000..485f01a1 --- /dev/null +++ b/public/images/penawaran-terbatas.svg @@ -0,0 +1,24 @@ + + + + + + + + + Penawaran Terbatas + + + + Penawaran Terbatas + + diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index ff43d4a0..78e7f54a 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -57,7 +57,7 @@ const NavbarDesktop = () => { }, 500); const hideTimer = setTimeout(() => { - setShowPopup(false); + // setShowPopup(false); }, 9500); return () => { @@ -256,18 +256,22 @@ const NavbarDesktop = () => { >

Semua Promo

- {showPopup && router.pathname === '/' && ( + {/* {showPopup && router.pathname === '/' && (

Penawaran Terbatas

- )} - {/* {showPopup && router.pathname === '/' && ( -
- -
)} */} + {showPopup && router.pathname === '/' && ( + penawaran terbatas + )} Date: Wed, 7 Aug 2024 15:22:39 +0700 Subject: update all promo --- public/images/penawaran-terbatas.jpg | Bin 0 -> 6802 bytes public/images/penawaran-terbatas.svg | 24 -------- .../promo/components/FlashSaleNonDisplay.tsx | 20 +++++++ src-migrate/pages/shop/promo/index.tsx | 4 ++ .../components/elements/Navbar/NavbarDesktop.jsx | 19 +++--- .../flashSale/components/FlashSaleNonDisplay.jsx | 66 +++++++++++++++++++++ 6 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 public/images/penawaran-terbatas.jpg delete mode 100644 public/images/penawaran-terbatas.svg create mode 100644 src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx create mode 100644 src/lib/flashSale/components/FlashSaleNonDisplay.jsx diff --git a/public/images/penawaran-terbatas.jpg b/public/images/penawaran-terbatas.jpg new file mode 100644 index 00000000..e43739fc Binary files /dev/null and b/public/images/penawaran-terbatas.jpg differ diff --git a/public/images/penawaran-terbatas.svg b/public/images/penawaran-terbatas.svg deleted file mode 100644 index 485f01a1..00000000 --- a/public/images/penawaran-terbatas.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - Penawaran Terbatas - - - - Penawaran Terbatas - - diff --git a/src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx b/src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx new file mode 100644 index 00000000..1c5cc86d --- /dev/null +++ b/src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx @@ -0,0 +1,20 @@ +import dynamic from "next/dynamic"; +import React from "react"; +import { FlashSaleSkeleton } from "@/lib/flashSale/skeleton/FlashSaleSkeleton"; + +const FlashSaleNonDisplay = dynamic( + () => import('@/lib/flashSale/components/FlashSaleNonDisplay'), + { + loading: () => , + } + ); + + const FlashSalePromo = ()=> { + return( + <> + + + ) + } + + export default FlashSalePromo \ No newline at end of file diff --git a/src-migrate/pages/shop/promo/index.tsx b/src-migrate/pages/shop/promo/index.tsx index febe31a4..95d8a4d5 100644 --- a/src-migrate/pages/shop/promo/index.tsx +++ b/src-migrate/pages/shop/promo/index.tsx @@ -5,6 +5,7 @@ import Hero from '~/modules/promo/components/Hero' import PromotionProgram from '~/modules/promo/components/PromotinProgram' import Voucher from '~/modules/promo/components/Voucher' import FlashSale from '../../../modules/promo/components/FlashSale' +import FlashSaleNonDisplay from '../../../modules/promo/components/FlashSaleNonDisplay' const PromoList = dynamic(() => import('../../../modules/promo/components/PromoList')); @@ -28,6 +29,9 @@ const PromoPage = () => {

+ + + diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 78e7f54a..cc5ea611 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -255,6 +255,16 @@ const NavbarDesktop = () => { rel="noreferrer" >

Semua Promo

+ {showPopup && ( + penawaran terbatas + )} {/* {showPopup && router.pathname === '/' && (
@@ -263,15 +273,6 @@ const NavbarDesktop = () => {

)} */} - {showPopup && router.pathname === '/' && ( - penawaran terbatas - )} { + const [flashSales, setFlashSales] = useState(null); + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + const loadFlashSales = async () => { + const dataFlashSales = await flashSaleApi(); + setFlashSales(dataFlashSales); + setIsLoading(false); + }; + loadFlashSales(); + }, []); + + if (isLoading) { + return ; + } + + return ( + flashSales?.length > 0 && ( +
+ {flashSales.map((flashSale, index) => ( +
+
+
+ Penawaran Terbatas +
+
+ +
+ +
+
+ ))} +
+ ) + ); +}; + +const FlashSaleProduct = ({ flashSaleId }) => { + const [products, setProducts] = useState(null); + + useEffect(() => { + const loadProducts = async () => { + const dataProducts = await productSearchApi({ + query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale_discount_f desc`, + operation: 'AND', + }); + setProducts(dataProducts.response); + }; + loadProducts(); + }, [flashSaleId]); + + return ; +}; + +export default FlashSaleNonDisplay; -- cgit v1.2.3 From 085dcb058ef4b92cea8b4044e65dd940580f3f42 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 15:26:32 +0700 Subject: merge all promotion --- public/images/penawaran-terbatas.jpg | Bin 0 -> 6802 bytes .../promo/components/FlashSaleNonDisplay.tsx | 20 ++++++ src-migrate/pages/shop/promo/index.tsx | 4 ++ .../components/elements/Footer/BasicFooter.jsx | 2 +- .../components/elements/Navbar/NavbarDesktop.jsx | 75 +++++++++++++++++---- src/core/components/elements/Navbar/TopBanner.jsx | 9 ++- .../flashSale/components/FlashSaleNonDisplay.jsx | 66 ++++++++++++++++++ src/lib/product/components/ProductCard.jsx | 4 +- 8 files changed, 163 insertions(+), 17 deletions(-) create mode 100644 public/images/penawaran-terbatas.jpg create mode 100644 src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx create mode 100644 src/lib/flashSale/components/FlashSaleNonDisplay.jsx diff --git a/public/images/penawaran-terbatas.jpg b/public/images/penawaran-terbatas.jpg new file mode 100644 index 00000000..e43739fc Binary files /dev/null and b/public/images/penawaran-terbatas.jpg differ diff --git a/src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx b/src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx new file mode 100644 index 00000000..1c5cc86d --- /dev/null +++ b/src-migrate/modules/promo/components/FlashSaleNonDisplay.tsx @@ -0,0 +1,20 @@ +import dynamic from "next/dynamic"; +import React from "react"; +import { FlashSaleSkeleton } from "@/lib/flashSale/skeleton/FlashSaleSkeleton"; + +const FlashSaleNonDisplay = dynamic( + () => import('@/lib/flashSale/components/FlashSaleNonDisplay'), + { + loading: () => , + } + ); + + const FlashSalePromo = ()=> { + return( + <> + + + ) + } + + export default FlashSalePromo \ No newline at end of file diff --git a/src-migrate/pages/shop/promo/index.tsx b/src-migrate/pages/shop/promo/index.tsx index febe31a4..95d8a4d5 100644 --- a/src-migrate/pages/shop/promo/index.tsx +++ b/src-migrate/pages/shop/promo/index.tsx @@ -5,6 +5,7 @@ import Hero from '~/modules/promo/components/Hero' import PromotionProgram from '~/modules/promo/components/PromotinProgram' import Voucher from '~/modules/promo/components/Voucher' import FlashSale from '../../../modules/promo/components/FlashSale' +import FlashSaleNonDisplay from '../../../modules/promo/components/FlashSaleNonDisplay' const PromoList = dynamic(() => import('../../../modules/promo/components/PromoList')); @@ -28,6 +29,9 @@ const PromoPage = () => {

+ + + diff --git a/src/core/components/elements/Footer/BasicFooter.jsx b/src/core/components/elements/Footer/BasicFooter.jsx index 6129143d..4beea604 100644 --- a/src/core/components/elements/Footer/BasicFooter.jsx +++ b/src/core/components/elements/Footer/BasicFooter.jsx @@ -259,7 +259,7 @@ const InformationCenter = () => (
  • - (021) 2933-8828 / 29 + (021) 2933-8828
  • diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 7d9e4264..cc5ea611 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -10,11 +10,12 @@ import { ChevronDownIcon, DocumentCheckIcon, HeartIcon, + ArrowUpRightIcon, } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import Image from 'next/image'; import { useRouter } from 'next/router'; -import { useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import DesktopView from '../../views/DesktopView'; import Link from '../Link/Link'; import NavbarUserDropdown from './NavbarUserDropdown'; @@ -47,6 +48,46 @@ const NavbarDesktop = () => { const { product } = useProductContext(); const { isOpen, onOpen, onClose } = useDisclosure(); + const [showPopup, setShowPopup] = useState(false); + const [isTop, setIsTop] = useState(true); + + const handleTopBannerLoad = useCallback(() => { + const showTimer = setTimeout(() => { + setShowPopup(true); + }, 500); + + const hideTimer = setTimeout(() => { + // setShowPopup(false); + }, 9500); + + return () => { + clearTimeout(showTimer); + clearTimeout(hideTimer); + }; + }, []); + + useEffect(() => { + const handleScroll = () => { + setIsTop(window.scrollY < 100); + }; + + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + + useEffect(() => { + const handleScroll = () => { + setIsTop(window.scrollY < 100); + }; + + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + useEffect(() => { if (router.pathname === '/shop/product/[slug]') { setPayloadWa({ @@ -79,7 +120,7 @@ const NavbarDesktop = () => { return ( - +
    @@ -204,6 +245,7 @@ const NavbarDesktop = () => {
    + { rel="noreferrer" >

    Semua Promo

    - {/*
    - promo -
    */} + {showPopup && ( + penawaran terbatas + )} - + {/* {showPopup && router.pathname === '/' && ( +
    +

    + Penawaran Terbatas +

    +
    + )} */} + { +const TopBanner = ({ onLoad }) => { const { isDesktop, isMobile } = useDevice() const topBanner = useQuery({ queryKey: 'topBanner', @@ -17,6 +18,12 @@ const TopBanner = () => { const hasData = topBanner.data?.length > 0; const data = topBanner.data?.[0] || null; + useEffect(() => { + if (hasData) { + onLoad(); + } + }, [hasData, onLoad]); + return ( { + const [flashSales, setFlashSales] = useState(null); + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + const loadFlashSales = async () => { + const dataFlashSales = await flashSaleApi(); + setFlashSales(dataFlashSales); + setIsLoading(false); + }; + loadFlashSales(); + }, []); + + if (isLoading) { + return ; + } + + return ( + flashSales?.length > 0 && ( +
    + {flashSales.map((flashSale, index) => ( +
    +
    +
    + Penawaran Terbatas +
    +
    + +
    + +
    +
    + ))} +
    + ) + ); +}; + +const FlashSaleProduct = ({ flashSaleId }) => { + const [products, setProducts] = useState(null); + + useEffect(() => { + const loadProducts = async () => { + const dataProducts = await productSearchApi({ + query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale_discount_f desc`, + operation: 'AND', + }); + setProducts(dataProducts.response); + }; + loadProducts(); + }, [flashSaleId]); + + return ; +}; + +export default FlashSaleNonDisplay; diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 94db144d..35e2a665 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -17,8 +17,8 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const [discount, setDiscount] = useState(0); let voucherPastiHemat = 0; - - if (product?.voucherPastiHemat?.length > 0) { + + if (product?.voucherPastiHemat ? product?.voucherPastiHemat.length : voucherPastiHemat > 0) { const stringVoucher = product?.voucherPastiHemat[0]; const validJsonString = stringVoucher.replace(/'/g, '"'); voucherPastiHemat = JSON.parse(validJsonString); -- cgit v1.2.3 From c08901721ea5bf61aa5dca9ada1abaf480d8a1ee Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 16:06:41 +0700 Subject: update pop up --- .../components/elements/Navbar/NavbarDesktop.jsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index cc5ea611..a09989a5 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -254,17 +254,20 @@ const NavbarDesktop = () => { target="_blank" rel="noreferrer" > -

    Semua Promo

    {showPopup && ( - penawaran terbatas +
    + penawaran terbatas +
    )} +

    Semua Promo

    {/* {showPopup && router.pathname === '/' && (
    -- cgit v1.2.3 From 43aee0ade51076a49ac998a1ae1357a12a03d31e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 16:09:50 +0700 Subject: merge all promotion --- .../components/elements/Navbar/NavbarDesktop.jsx | 22 +++++++++++++--------- src/core/components/elements/Navbar/TopBanner.jsx | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index cc5ea611..e09c13c3 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -11,6 +11,7 @@ import { DocumentCheckIcon, HeartIcon, ArrowUpRightIcon, + ArrowUpRightIcon, } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import Image from 'next/image'; @@ -254,17 +255,20 @@ const NavbarDesktop = () => { target="_blank" rel="noreferrer" > -

    Semua Promo

    {showPopup && ( - penawaran terbatas +
    + penawaran terbatas +
    )} +

    Semua Promo

    {/* {showPopup && router.pathname === '/' && (
    diff --git a/src/core/components/elements/Navbar/TopBanner.jsx b/src/core/components/elements/Navbar/TopBanner.jsx index 265dfb5e..28cfad21 100644 --- a/src/core/components/elements/Navbar/TopBanner.jsx +++ b/src/core/components/elements/Navbar/TopBanner.jsx @@ -4,6 +4,7 @@ import odooApi from '@/core/api/odooApi'; import SmoothRender from '~/components/ui/smooth-render'; import Link from '../Link/Link'; import { useEffect } from 'react'; +import { useEffect } from 'react'; import { background } from '@chakra-ui/react'; const TopBanner = ({ onLoad }) => { -- cgit v1.2.3 From 3bf7a3f59586105d4ee02a43b9c354b06083a7d3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 16:11:30 +0700 Subject: update error code --- src/core/components/elements/Navbar/NavbarDesktop.jsx | 1 - src/core/components/elements/Navbar/TopBanner.jsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index e09c13c3..a09989a5 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -11,7 +11,6 @@ import { DocumentCheckIcon, HeartIcon, ArrowUpRightIcon, - ArrowUpRightIcon, } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import Image from 'next/image'; diff --git a/src/core/components/elements/Navbar/TopBanner.jsx b/src/core/components/elements/Navbar/TopBanner.jsx index 28cfad21..265dfb5e 100644 --- a/src/core/components/elements/Navbar/TopBanner.jsx +++ b/src/core/components/elements/Navbar/TopBanner.jsx @@ -4,7 +4,6 @@ import odooApi from '@/core/api/odooApi'; import SmoothRender from '~/components/ui/smooth-render'; import Link from '../Link/Link'; import { useEffect } from 'react'; -import { useEffect } from 'react'; import { background } from '@chakra-ui/react'; const TopBanner = ({ onLoad }) => { -- cgit v1.2.3 From 0fc1ee076d3a59b406f79716c343f15301c1066a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 17:06:58 +0700 Subject: update all promotion card flashSale --- public/images/penawaran-terbatas.jpg | Bin 6802 -> 6602 bytes src-migrate/pages/shop/promo/index.tsx | 1 + src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 +- src/lib/flashSale/components/FlashSaleNonDisplay.jsx | 2 +- src/pages/api/shop/search.js | 6 ++++++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/public/images/penawaran-terbatas.jpg b/public/images/penawaran-terbatas.jpg index e43739fc..d07866e6 100644 Binary files a/public/images/penawaran-terbatas.jpg and b/public/images/penawaran-terbatas.jpg differ diff --git a/src-migrate/pages/shop/promo/index.tsx b/src-migrate/pages/shop/promo/index.tsx index 95d8a4d5..7bb5546d 100644 --- a/src-migrate/pages/shop/promo/index.tsx +++ b/src-migrate/pages/shop/promo/index.tsx @@ -32,6 +32,7 @@ const PromoPage = () => { +

    diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index a09989a5..76012694 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -263,7 +263,7 @@ const NavbarDesktop = () => { height={160} quality={100} // className={`fixed ${isTop ? 'md:top-[145px] lg:top-[160px] ' : 'lg:top-[85px] top-[80px]'} rounded-3xl md:left-1/4 lg:left-1/4 xl:left-1/4 left-2/3 w-40 h-12 p-2 z-50 transition-all duration-300 animate-pulse`} - className={`inline-block relative -top-4 transition-all duration-300 z-20 animate-pulse`} + className={`inline-block relative -top-5 transition-all duration-300 z-20 animate-pulse`} />
    )} diff --git a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx index 85807fad..8dc15b05 100644 --- a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx +++ b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx @@ -52,7 +52,7 @@ const FlashSaleProduct = ({ flashSaleId }) => { useEffect(() => { const loadProducts = async () => { const dataProducts = await productSearchApi({ - query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale_discount_f desc`, + query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale-discount-desc`, operation: 'AND', }); setProducts(dataProducts.response); diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 29471f7b..8dc72559 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -3,6 +3,7 @@ import axios from 'axios'; import camelcaseObjectDeep from 'camelcase-object-deep'; export default async function handler(req, res) { + const { q = '*', page = 1, @@ -20,6 +21,9 @@ export default async function handler(req, res) { let paramOrderBy = ''; switch (orderBy) { + case 'flashsale-discount-desc': + paramOrderBy += 'flashsale_discount_f DESC'; + break; case 'price-asc': paramOrderBy += 'price_tier1_v2_f ASC'; break; @@ -59,6 +63,7 @@ export default async function handler(req, res) { `fq=-publish_b:false, product_rating_f:[13 TO *], discount_tier1_v2_f:[1 TO *]`, ]; + if (priceFrom > 0 || priceTo > 0) { parameter.push( `fq=price_tier1_v2_f:[${priceFrom == '' ? '*' : priceFrom} TO ${ @@ -99,6 +104,7 @@ export default async function handler(req, res) { let result = await axios( process.env.SOLR_HOST + '/solr/product/select?' + parameter.join('&') ); + console.log("result",result) try { result.data.response.products = productMappingSolr( result.data.response.docs, -- cgit v1.2.3 From f2e11c985f467cfe28b6f4c8c9ae9c7fabf85d94 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 17:07:59 +0700 Subject: delete console log --- src/pages/api/shop/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 8dc72559..87d7c580 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -104,7 +104,7 @@ export default async function handler(req, res) { let result = await axios( process.env.SOLR_HOST + '/solr/product/select?' + parameter.join('&') ); - console.log("result",result) + try { result.data.response.products = productMappingSolr( result.data.response.docs, -- cgit v1.2.3 From 538f2ef24eb8c6ae21a07f27614ce1b944553283 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 17:13:30 +0700 Subject: merge all promotion --- src-migrate/pages/shop/promo/index.tsx | 1 + src/core/components/elements/Navbar/NavbarDesktop.jsx | 5 ++--- src/lib/flashSale/components/FlashSaleNonDisplay.jsx | 2 +- src/pages/api/shop/search.js | 6 ++++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src-migrate/pages/shop/promo/index.tsx b/src-migrate/pages/shop/promo/index.tsx index 95d8a4d5..7bb5546d 100644 --- a/src-migrate/pages/shop/promo/index.tsx +++ b/src-migrate/pages/shop/promo/index.tsx @@ -32,6 +32,7 @@ const PromoPage = () => { +

    diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index a09989a5..6a51a178 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -10,12 +10,11 @@ import { ChevronDownIcon, DocumentCheckIcon, HeartIcon, - ArrowUpRightIcon, } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import Image from 'next/image'; import { useRouter } from 'next/router'; -import { useCallback, useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import DesktopView from '../../views/DesktopView'; import Link from '../Link/Link'; import NavbarUserDropdown from './NavbarUserDropdown'; @@ -263,7 +262,7 @@ const NavbarDesktop = () => { height={160} quality={100} // className={`fixed ${isTop ? 'md:top-[145px] lg:top-[160px] ' : 'lg:top-[85px] top-[80px]'} rounded-3xl md:left-1/4 lg:left-1/4 xl:left-1/4 left-2/3 w-40 h-12 p-2 z-50 transition-all duration-300 animate-pulse`} - className={`inline-block relative -top-4 transition-all duration-300 z-20 animate-pulse`} + className={`inline-block relative -top-5 transition-all duration-300 z-20 animate-pulse`} />
    )} diff --git a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx index 85807fad..8dc15b05 100644 --- a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx +++ b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx @@ -52,7 +52,7 @@ const FlashSaleProduct = ({ flashSaleId }) => { useEffect(() => { const loadProducts = async () => { const dataProducts = await productSearchApi({ - query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale_discount_f desc`, + query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale-discount-desc`, operation: 'AND', }); setProducts(dataProducts.response); diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 29471f7b..87d7c580 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -3,6 +3,7 @@ import axios from 'axios'; import camelcaseObjectDeep from 'camelcase-object-deep'; export default async function handler(req, res) { + const { q = '*', page = 1, @@ -20,6 +21,9 @@ export default async function handler(req, res) { let paramOrderBy = ''; switch (orderBy) { + case 'flashsale-discount-desc': + paramOrderBy += 'flashsale_discount_f DESC'; + break; case 'price-asc': paramOrderBy += 'price_tier1_v2_f ASC'; break; @@ -59,6 +63,7 @@ export default async function handler(req, res) { `fq=-publish_b:false, product_rating_f:[13 TO *], discount_tier1_v2_f:[1 TO *]`, ]; + if (priceFrom > 0 || priceTo > 0) { parameter.push( `fq=price_tier1_v2_f:[${priceFrom == '' ? '*' : priceFrom} TO ${ @@ -99,6 +104,7 @@ export default async function handler(req, res) { let result = await axios( process.env.SOLR_HOST + '/solr/product/select?' + parameter.join('&') ); + try { result.data.response.products = productMappingSolr( result.data.response.docs, -- cgit v1.2.3 From 718babe0efd96c33ba2b8fd0cb458c57d67abe9c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 17:15:58 +0700 Subject: update position --- src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 76012694..2ddf5efe 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -263,7 +263,7 @@ const NavbarDesktop = () => { height={160} quality={100} // className={`fixed ${isTop ? 'md:top-[145px] lg:top-[160px] ' : 'lg:top-[85px] top-[80px]'} rounded-3xl md:left-1/4 lg:left-1/4 xl:left-1/4 left-2/3 w-40 h-12 p-2 z-50 transition-all duration-300 animate-pulse`} - className={`inline-block relative -top-5 transition-all duration-300 z-20 animate-pulse`} + className={`inline-block relative -top-8 transition-all duration-300 z-20 animate-pulse`} />
    )} -- cgit v1.2.3 From de3422dc076e11724d423f80c1005d5188ed4e3e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 8 Aug 2024 10:44:07 +0700 Subject: add motion --- src/core/components/layouts/BasicLayout.jsx | 75 ++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/src/core/components/layouts/BasicLayout.jsx b/src/core/components/layouts/BasicLayout.jsx index a4f3a856..4d995a3a 100644 --- a/src/core/components/layouts/BasicLayout.jsx +++ b/src/core/components/layouts/BasicLayout.jsx @@ -1,12 +1,13 @@ import dynamic from 'next/dynamic'; import Image from 'next/image'; import { useRouter } from 'next/router'; -import { useEffect, useState } from 'react'; +import { useEffect, useState, useRef } from 'react'; import { useProductContext } from '@/contexts/ProductContext'; import odooApi from '@/core/api/odooApi'; import whatsappUrl from '@/core/utils/whatsappUrl'; import Navbar from '../elements/Navbar/Navbar'; +import { AnimatePresence, motion } from 'framer-motion'; const AnimationLayout = dynamic(() => import('./AnimationLayout'), { ssr: false, @@ -19,8 +20,10 @@ const BasicLayout = ({ children }) => { const [templateWA, setTemplateWA] = useState(null); const [payloadWA, setPayloadWa] = useState(null); const [urlPath, setUrlPath] = useState(null); + const [isVisible, setIsVisible] = useState(true); const router = useRouter(); + const whatsappRef = useRef(null); const { product } = useProductContext(); useEffect(() => { @@ -58,33 +61,81 @@ const BasicLayout = ({ children }) => { recordActivity(router.pathname); }, [router.pathname]); + useEffect(() => { + const handleMouseOut = (event) => { + if (event.clientY <= 0) { + setIsVisible(false); + } else { + setIsVisible(true); + } + }; + + window.addEventListener('mouseout', handleMouseOut); + + return () => { + window.removeEventListener('mouseout', handleMouseOut); + }; + }, []); + + const getWhatsappPosition = () => { + if (whatsappRef.current) { + const rect = whatsappRef.current.getBoundingClientRect(); + return { + x: rect.left + 80, + y: rect.top + 40, + width: rect.width, + height: rect.height, + }; + } + return { x: 0, y: 0, width: 0, height: 0 }; + }; + return ( <> + {!isVisible && ( + + + + )} {children} -
    + -- cgit v1.2.3 From 7e762fee7c9125ef2ce7e1cc0942ce8d1c1cb290 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 8 Aug 2024 15:47:07 +0700 Subject: back to original --- src/core/components/layouts/BasicLayout.jsx | 77 +++++------------------------ 1 file changed, 13 insertions(+), 64 deletions(-) diff --git a/src/core/components/layouts/BasicLayout.jsx b/src/core/components/layouts/BasicLayout.jsx index 4d995a3a..ba51022d 100644 --- a/src/core/components/layouts/BasicLayout.jsx +++ b/src/core/components/layouts/BasicLayout.jsx @@ -1,13 +1,12 @@ import dynamic from 'next/dynamic'; import Image from 'next/image'; import { useRouter } from 'next/router'; -import { useEffect, useState, useRef } from 'react'; +import { useEffect, useState } from 'react'; import { useProductContext } from '@/contexts/ProductContext'; import odooApi from '@/core/api/odooApi'; import whatsappUrl from '@/core/utils/whatsappUrl'; import Navbar from '../elements/Navbar/Navbar'; -import { AnimatePresence, motion } from 'framer-motion'; const AnimationLayout = dynamic(() => import('./AnimationLayout'), { ssr: false, @@ -20,10 +19,8 @@ const BasicLayout = ({ children }) => { const [templateWA, setTemplateWA] = useState(null); const [payloadWA, setPayloadWa] = useState(null); const [urlPath, setUrlPath] = useState(null); - const [isVisible, setIsVisible] = useState(true); const router = useRouter(); - const whatsappRef = useRef(null); const { product } = useProductContext(); useEffect(() => { @@ -61,81 +58,33 @@ const BasicLayout = ({ children }) => { recordActivity(router.pathname); }, [router.pathname]); - useEffect(() => { - const handleMouseOut = (event) => { - if (event.clientY <= 0) { - setIsVisible(false); - } else { - setIsVisible(true); - } - }; - - window.addEventListener('mouseout', handleMouseOut); - - return () => { - window.removeEventListener('mouseout', handleMouseOut); - }; - }, []); - - const getWhatsappPosition = () => { - if (whatsappRef.current) { - const rect = whatsappRef.current.getBoundingClientRect(); - return { - x: rect.left + 80, - y: rect.top + 40, - width: rect.width, - height: rect.height, - }; - } - return { x: 0, y: 0, width: 0, height: 0 }; - }; - return ( <> - {!isVisible && ( - - - - )} {children} -
    + @@ -144,4 +93,4 @@ const BasicLayout = ({ children }) => { ); }; -export default BasicLayout; +export default BasicLayout; \ No newline at end of file -- cgit v1.2.3 From f39ed21b9a3f1a43898c65b8515bb420c7075eb3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 8 Aug 2024 15:50:52 +0700 Subject: add ? to avoid error log --- src-migrate/modules/product-promo/components/AddToCart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-migrate/modules/product-promo/components/AddToCart.tsx b/src-migrate/modules/product-promo/components/AddToCart.tsx index 8567dad8..3d0955e3 100644 --- a/src-migrate/modules/product-promo/components/AddToCart.tsx +++ b/src-migrate/modules/product-promo/components/AddToCart.tsx @@ -132,7 +132,7 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => { />
    - {!!product.manufacture.name ? ( + {!!product?.manufacture?.name ? ( Date: Thu, 8 Aug 2024 17:09:56 +0700 Subject: add similar product template --- .../modules/product-detail/components/ProductDetail.tsx | 2 +- .../modules/product-detail/components/SimilarBottom.tsx | 6 ++++-- src-migrate/services/product.ts | 13 ++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index fad35a7d..f5feae76 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -178,7 +178,7 @@ const ProductDetail = ({ product }: Props) => {
    - +
    diff --git a/src-migrate/modules/product-detail/components/SimilarBottom.tsx b/src-migrate/modules/product-detail/components/SimilarBottom.tsx index 40d4dd82..ab33f106 100644 --- a/src-migrate/modules/product-detail/components/SimilarBottom.tsx +++ b/src-migrate/modules/product-detail/components/SimilarBottom.tsx @@ -5,12 +5,14 @@ import { IProductDetail } from '~/types/product' type Props = { product: IProductDetail + source: string } -const SimilarBottom = ({ product }: Props) => { +const SimilarBottom = ({ product, source }: Props) => { const productSimilar = useProductSimilar({ name: product.name, - except: { productId: product.id } + except: { productId: product.id }, + source: source }) const products = productSimilar.data?.products || [] diff --git a/src-migrate/services/product.ts b/src-migrate/services/product.ts index 51667eb9..ec5435cd 100644 --- a/src-migrate/services/product.ts +++ b/src-migrate/services/product.ts @@ -21,6 +21,7 @@ export const getProductById = async ( }; export interface GetProductSimilarProps { + source?: string; name: string; except?: { productId?: number; @@ -34,18 +35,22 @@ export interface GetProductSimilarRes { num_found: number; num_found_exact: boolean; start: number; + source: string; } export const getProductSimilar = async ({ name, except, limit = 30, + source, }: GetProductSimilarProps): Promise => { let dataflashSale = null const flashSale = await odooApi('GET', '/api/v1/flashsale/header') if (flashSale && flashSale.length > 0) { const dataFlash = await productSearchApi({ - query: `fq=flashsale_id_i:${flashSale[0].pricelist_id}&fq=flashsale_price_f:[1 TO *]&limit=4`, + query: `fq=flashsale_id_i:${flashSale[0].pricelist_id}&fq=flashsale_price_f:[1 TO *]&limit=${ + source === 'bottom' ? '4' : '1' + }`, operation: 'AND' }) @@ -61,6 +66,12 @@ export const getProductSimilar = async ({ qty_sold: product.qtySold, lowestPrice: undefined })); + if (source === 'bottom') { + dataflashSale = dataflashSale.slice('2', '4') + } else { + dataflashSale = dataflashSale + } + console.log("dataflashSale",dataflashSale) } const query = [ `q=${name}`, -- cgit v1.2.3 From e33a7e612a3c2c871f6a0a84d0d04d6f6ddc357a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 9 Aug 2024 10:51:10 +0700 Subject: update template switch & delete console log --- src-migrate/hooks/useUtmSource.ts | 1 - .../product-card/components/ProductCard.tsx | 105 ++++++++++----------- .../product-detail/components/ProductDetail.tsx | 2 +- .../product-detail/components/SimilarBottom.tsx | 1 - src-migrate/services/product.ts | 13 ++- src-migrate/types/productVariant.ts | 4 + .../components/Product/ProductDesktopVariant.jsx | 17 +--- src/lib/quotation/components/Quotation.jsx | 2 - .../components/products-recomendatison.jsx | 4 - 9 files changed, 67 insertions(+), 82 deletions(-) diff --git a/src-migrate/hooks/useUtmSource.ts b/src-migrate/hooks/useUtmSource.ts index a72fae36..41a5f41c 100644 --- a/src-migrate/hooks/useUtmSource.ts +++ b/src-migrate/hooks/useUtmSource.ts @@ -7,7 +7,6 @@ const useUtmSource = () => { const [source, setSource] = useState(); useEffect(() => { - console.log(router.pathname); if (router.pathname) { setSource(UTM_SOURCE[router.pathname as keyof typeof UTM_SOURCE]); diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx index 3e34d5c3..931f8f2f 100644 --- a/src-migrate/modules/product-card/components/ProductCard.tsx +++ b/src-migrate/modules/product-card/components/ProductCard.tsx @@ -24,6 +24,9 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { const utmSource = useUtmSource() const router = useRouter(); + const ppnString = process.env.NEXT_PUBLIC_PPN; + const ppnNumber = ppnString !== undefined ? Number(ppnString) : 0; + const id = product.id.toString () const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, @@ -169,36 +172,24 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { > {product.name} -
    - {product?.flash_sale?.id > 0 ? (
    ) : - ( -
    - Rp {formatCurrency(product.lowest_price.price)} -
    - ) - } - -
    - - {product?.flash_sale?.id > 0 && - product?.lowest_price?.discountPercentage > 0 ? ( + {product?.lowest_price.discountPercentage === undefined ? ( +
    + {product?.flash_sale?.id > 0 && + product?.lowest_price.discount_percentage > 0 ? ( <> - {product?.lowest_price.discountPercentage > 0 && ( -
    -
    - {Math.floor(product?.lowest_price.discount_percentage ? product?.lowest_price.discount_percentage : product?.lowest_price.discountPercentage)}% -
    -
    - {currencyFormat(product?.lowest_price?.price)} -
    +
    +
    + {currencyFormat(product.lowest_price.price)}
    - )} - +
    + {Math.floor(product?.lowest_price.discount_percentage)}% +
    +
    - {product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount > 0 ? ( - currencyFormat(product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount) + {product?.lowest_price.price_discount > 0 ? ( + currencyFormat(product?.lowest_price.price_discount) ) : ( { )}
    -
    - {product?.stockTotal > 0 && ( + + ) : ( +
    + {product?.lowest_price.price > 0 ? ( + <> + {currencyFormat(product?.lowest_price.price)} +
    + Inc. PPN:{' '} + {currencyFormat( + product.lowest_price.price * ppnNumber + )} +
    + + ) : ( + + Call for Inquiry + + )} +
    + )} + +
    + {product?.stock_total > 0 && (
    Ready Stock
    )} {/*
    {product?.stockTotal > 5 ? '> 5' : '< 5'}
    */} - {product?.qtySold > 0 && ( + {product?.qty_sold > 0 && (
    - {sellingProductFormat(product?.qtySold) + ' Terjual'} + {sellingProductFormat(product?.qty_sold) + ' Terjual'}
    )}
    - - ) : ( -
    -
    - Inc PPN: - Rp {formatCurrency(Math.round(product.lowest_price.price * 1.11))} -
    - -
    - -
    - {product.stock_total > 0 && ( -
    - Ready Stock -
    - )} - {product.qty_sold > 0 && ( -
    - {formatToShortText(product.qty_sold)} Terjual -
    - )} -
    -
    - )} +
    + ) : ( +
    + +
    + )} +
    diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index f5feae76..de0522d5 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -37,7 +37,7 @@ const ProductDetail = ({ product }: Props) => { const router = useRouter() const auth = getAuth() const { setAskAdminUrl, askAdminUrl, activeVariantId, setIsApproval, isApproval } = useProductDetail() - + useEffect(() => { gtagProductDetail(product); },[product]) diff --git a/src-migrate/modules/product-detail/components/SimilarBottom.tsx b/src-migrate/modules/product-detail/components/SimilarBottom.tsx index ab33f106..8ff0a6bf 100644 --- a/src-migrate/modules/product-detail/components/SimilarBottom.tsx +++ b/src-migrate/modules/product-detail/components/SimilarBottom.tsx @@ -16,7 +16,6 @@ const SimilarBottom = ({ product, source }: Props) => { }) const products = productSimilar.data?.products || [] - return ( ({ + flashSale: any; + lowestPrice: any; + }) => ({ ...product, - lowest_price: product.lowestPrice, + lowest_price: { + discount_percentage: product.lowestPrice.discountPercentage, + price: product.lowestPrice.price, + price_discount: product.lowestPrice.priceDiscount, + }, flash_sale: product.flashSale, stock_total: product.stockTotal, qty_sold: product.qtySold, - lowestPrice: undefined })); if (source === 'bottom') { dataflashSale = dataflashSale.slice('2', '4') } else { dataflashSale = dataflashSale } - console.log("dataflashSale",dataflashSale) } const query = [ `q=${name}`, diff --git a/src-migrate/types/productVariant.ts b/src-migrate/types/productVariant.ts index 861b216a..5f6bded5 100644 --- a/src-migrate/types/productVariant.ts +++ b/src-migrate/types/productVariant.ts @@ -8,6 +8,10 @@ export interface IProductVariantDetail { remaining_time: number; is_flashsale: boolean; }; + categories: { + id: string; + name: string; + }[]; price: { price: number; price_discount: number; diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 882673f4..b8ec0580 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -176,7 +176,7 @@ const ProductDesktopVariant = ({ return (
    - +
    @@ -415,24 +415,11 @@ const ProductDesktopVariant = ({ Beli
    - {/*
    - -
    */}
    Produk Serupa
    -
    +
    {productSimilarInBrand && productSimilarInBrand?.map((product) => (
    diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index 8855c6c4..5f197d16 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -277,9 +277,7 @@ const Quotation = () => { estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, }; - console.log('data checkout', data); const isSuccess = await checkoutApi({ data }); - console.log('isSuccess', isSuccess); setIsLoading(false); if (isSuccess?.id) { for (const product of products) deleteItemCart({ productId: product.id }); diff --git a/src/pages/my/recomendation/components/products-recomendatison.jsx b/src/pages/my/recomendation/components/products-recomendatison.jsx index d39d2a99..a610cf0d 100644 --- a/src/pages/my/recomendation/components/products-recomendatison.jsx +++ b/src/pages/my/recomendation/components/products-recomendatison.jsx @@ -80,7 +80,6 @@ const ProductsRecomendation = ({ id }) => { } }); - console.log('ini result', searchProduct.data.response); } return resultMapping; @@ -112,7 +111,6 @@ const ProductsRecomendation = ({ id }) => { setIsLoading(false); } else { setIsLoading(false); - console.log('No excel data available'); } }; @@ -129,7 +127,6 @@ const ProductsRecomendation = ({ id }) => { const jsonData = XLSX.utils.sheet_to_json(worksheet); setExcelData(jsonData); - console.log('ini json data', jsonData); setIsLoading(false); }; @@ -152,7 +149,6 @@ const ProductsRecomendation = ({ id }) => { }; const handlingOtherRec = ({ product }) => { - console.log('ini product', product); const result = async () => await searchRecomendation({ product, index: 0, operator: 'OR' }); -- cgit v1.2.3 From bbbd7ccaab3102558dc82cbd051947b0e579360c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 9 Aug 2024 10:55:01 +0700 Subject: back to code to avoid conflict --- src-migrate/hooks/useUtmSource.ts | 1 + src/lib/quotation/components/Quotation.jsx | 2 ++ src/pages/my/recomendation/components/products-recomendatison.jsx | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src-migrate/hooks/useUtmSource.ts b/src-migrate/hooks/useUtmSource.ts index 41a5f41c..a72fae36 100644 --- a/src-migrate/hooks/useUtmSource.ts +++ b/src-migrate/hooks/useUtmSource.ts @@ -7,6 +7,7 @@ const useUtmSource = () => { const [source, setSource] = useState(); useEffect(() => { + console.log(router.pathname); if (router.pathname) { setSource(UTM_SOURCE[router.pathname as keyof typeof UTM_SOURCE]); diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index 5f197d16..8855c6c4 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -277,7 +277,9 @@ const Quotation = () => { estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, }; + console.log('data checkout', data); const isSuccess = await checkoutApi({ data }); + console.log('isSuccess', isSuccess); setIsLoading(false); if (isSuccess?.id) { for (const product of products) deleteItemCart({ productId: product.id }); diff --git a/src/pages/my/recomendation/components/products-recomendatison.jsx b/src/pages/my/recomendation/components/products-recomendatison.jsx index a610cf0d..d39d2a99 100644 --- a/src/pages/my/recomendation/components/products-recomendatison.jsx +++ b/src/pages/my/recomendation/components/products-recomendatison.jsx @@ -80,6 +80,7 @@ const ProductsRecomendation = ({ id }) => { } }); + console.log('ini result', searchProduct.data.response); } return resultMapping; @@ -111,6 +112,7 @@ const ProductsRecomendation = ({ id }) => { setIsLoading(false); } else { setIsLoading(false); + console.log('No excel data available'); } }; @@ -127,6 +129,7 @@ const ProductsRecomendation = ({ id }) => { const jsonData = XLSX.utils.sheet_to_json(worksheet); setExcelData(jsonData); + console.log('ini json data', jsonData); setIsLoading(false); }; @@ -149,6 +152,7 @@ const ProductsRecomendation = ({ id }) => { }; const handlingOtherRec = ({ product }) => { + console.log('ini product', product); const result = async () => await searchRecomendation({ product, index: 0, operator: 'OR' }); -- cgit v1.2.3 From 8dd5502ca3ed4f2d74f74ea396b9424bd1390e5e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 9 Aug 2024 14:35:55 +0700 Subject: uptade code to avoid error --- src/core/components/elements/Navbar/TopBanner.jsx | 2 +- src/lib/category/components/PopularBrand.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/components/elements/Navbar/TopBanner.jsx b/src/core/components/elements/Navbar/TopBanner.jsx index 302db5c4..b035eea4 100644 --- a/src/core/components/elements/Navbar/TopBanner.jsx +++ b/src/core/components/elements/Navbar/TopBanner.jsx @@ -5,7 +5,7 @@ import SmoothRender from '~/components/ui/smooth-render'; import Link from '../Link/Link'; import { useEffect } from 'react'; -const TopBanner = ({ onLoad }) => { +const TopBanner = ({ onLoad = () => {} }) => { const topBanner = useQuery({ queryKey: 'topBanner', queryFn: async () => await odooApi('GET', '/api/v1/banner?type=top-banner'), diff --git a/src/lib/category/components/PopularBrand.jsx b/src/lib/category/components/PopularBrand.jsx index dca731e8..09c0f8a1 100644 --- a/src/lib/category/components/PopularBrand.jsx +++ b/src/lib/category/components/PopularBrand.jsx @@ -17,7 +17,7 @@ const PopularBrand = ({ category }) => { const fetchTopBrands = async () => { try { - const items = await fetchPromoItemsSolr(`category_id_ids:(${category.categoryDataIds.join(' OR ')})`); + const items = await fetchPromoItemsSolr(`category_id_ids:(${category?.categoryDataIds?.join(' OR ')})`); // console.log("id",items) // Fungsi untuk deduplikasi dan mengambil 12 nama brand teratas const getTop12UniqueBrands = (prod) => { -- cgit v1.2.3 From dec5fa876bffd4010febc7a16fa9ed20633cb42c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 9 Aug 2024 14:45:09 +0700 Subject: add handling to avoid error --- src/core/components/elements/Navbar/TopBanner.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/components/elements/Navbar/TopBanner.jsx b/src/core/components/elements/Navbar/TopBanner.jsx index 7bc8fb6a..6cce6b03 100644 --- a/src/core/components/elements/Navbar/TopBanner.jsx +++ b/src/core/components/elements/Navbar/TopBanner.jsx @@ -6,7 +6,7 @@ import SmoothRender from '~/components/ui/smooth-render'; import Link from '../Link/Link'; import { useEffect } from 'react'; -const TopBanner = ({ onLoad }) => { +const TopBanner = ({ onLoad = () => {} }) => { const topBanner = useQuery({ queryKey: 'topBanner', queryFn: async () => await odooApi('GET', '/api/v1/banner?type=top-banner'), -- cgit v1.2.3 From 544f0321f069254b64ea080d11724ab3e4a92bce Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 14 Aug 2024 11:34:38 +0700 Subject: update button lanjutkan transaksi & status quotation logic after upload po --- src/lib/transaction/api/checkoutPoApi.js | 4 ++-- src/lib/transaction/components/Transaction.jsx | 29 +++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/lib/transaction/api/checkoutPoApi.js b/src/lib/transaction/api/checkoutPoApi.js index 04421368..af41d277 100644 --- a/src/lib/transaction/api/checkoutPoApi.js +++ b/src/lib/transaction/api/checkoutPoApi.js @@ -1,11 +1,11 @@ import odooApi from '@/core/api/odooApi' import { getAuth } from '@/core/utils/auth' -const checkoutPoApi = async ({ id }) => { +const checkoutPoApi = async ({ id, status }) => { const auth = getAuth() const dataCheckout = await odooApi( 'POST', - `/api/v1/partner/${auth?.partnerId}/sale_order/${id}/checkout` + `/api/v1/partner/${auth?.partnerId}/sale_order/${id}/checkout`,{status} ) return dataCheckout } diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 85f6163b..88f11fd4 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -5,6 +5,8 @@ import useTransaction from '../hooks/useTransaction'; import TransactionStatusBadge from './TransactionStatusBadge'; import Divider from '@/core/components/elements/Divider/Divider'; import { useEffect, useMemo, useRef, useState } from 'react'; +import { Button, Tooltip } from '@chakra-ui/react'; +import clsxm from '~/libs/clsxm'; import ImageNext from 'next/image'; import { downloadPurchaseOrder, @@ -107,7 +109,7 @@ const Transaction = ({ id }) => { toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); return; } - await checkoutPoApi({ id }); + await checkoutPoApi({ id, status: true }); toast.success('Berhasil melanjutkan pesanan'); transaction.refetch(); }; @@ -563,10 +565,27 @@ const Transaction = ({ id }) => { )} {transaction.data?.status == 'draft' && !auth?.feature.soApproval && ( - - )} +
    + + + + +
    + )} {transaction.data?.status != 'draft' && !auth?.feature.soApproval && (