summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/components/elements/Navbar/NavbarDesktop.jsx2
-rw-r--r--src/lib/cart/components/Cart.jsx13
-rw-r--r--src/lib/checkout/components/Checkout.jsx16
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx46
4 files changed, 22 insertions, 55 deletions
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 306b6e83..380b0a16 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -22,7 +22,7 @@ const NavbarDesktop = () => {
return (
<DesktopView>
- <div className='py-3 bg-yellow_r-10/60'>
+ <div className='py-3 bg-yellow_r-10/80'>
<div className='container mx-auto flex justify-between'>
<Link href='/' className='!text-gray_r-12'>
Tentang Indoteknik.com
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx
index 8d995103..8400857d 100644
--- a/src/lib/cart/components/Cart.jsx
+++ b/src/lib/cart/components/Cart.jsx
@@ -14,7 +14,6 @@ import Spinner from '@/core/components/elements/Spinner/Spinner'
import Alert from '@/core/components/elements/Alert/Alert'
import MobileView from '@/core/components/views/MobileView'
import DesktopView from '@/core/components/views/DesktopView'
-import variantPriceApi from '@/lib/variant/api/variantPriceApi'
const Cart = () => {
const router = useRouter()
@@ -29,24 +28,16 @@ const Cart = () => {
useEffect(() => {
if (cart.data && !products) {
- const productsWithQuantity = cart.data.map(async (product) => {
+ const productsWithQuantity = cart.data.map((product) => {
const productInCart = getItemCart({ productId: product.id })
if (!productInCart) return
- const productPrice = await variantPriceApi({ id: product.id })
return {
...product,
- price: {
- price: productPrice.priceExclude,
- discountPercentage: productPrice.discount,
- priceDiscount: productPrice.priceExcludeAfterDiscount
- },
quantity: productInCart.quantity,
selected: productInCart.selected
}
})
- Promise.all(productsWithQuantity).then((resolvedProducts) => {
- setProducts(resolvedProducts)
- })
+ setProducts(productsWithQuantity)
}
}, [cart, products])
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index ffb33eb7..ac751ff4 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -19,7 +19,6 @@ import axios from 'axios'
import Image from '@/core/components/elements/Image/Image'
import MobileView from '@/core/components/views/MobileView'
import DesktopView from '@/core/components/views/DesktopView'
-import variantPriceApi from '@/lib/variant/api/variantPriceApi'
const Checkout = () => {
const router = useRouter()
@@ -59,7 +58,6 @@ const Checkout = () => {
})
}, [addresses])
- const [paymentMethod, setPaymentMethod] = useState('')
const [products, setProducts] = useState(null)
const [totalAmount, setTotalAmount] = useState(0)
const [totalDiscountAmount, setTotalDiscountAmount] = useState(0)
@@ -78,25 +76,15 @@ const Checkout = () => {
}
const dataProducts = await CartApi({ variantIds })
- const productsWithQuantity = dataProducts?.map(async (product) => {
- const productPrice = await variantPriceApi({ id: product.id })
+ const productsWithQuantity = dataProducts?.map((product) => {
return {
...product,
- price: {
- price: productPrice.priceExclude,
- discountPercentage: productPrice.discount,
- priceDiscount: productPrice.priceExcludeAfterDiscount
- },
quantity: query.quantity
? query.quantity
: getItemCart({ productId: product.id }).quantity
}
})
- if (productsWithQuantity) {
- Promise.all(productsWithQuantity).then((resolvedProducts) => {
- setProducts(resolvedProducts)
- })
- }
+ setProducts(productsWithQuantity)
}
loadProducts()
}, [router])
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 0866bffa..c7554242 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -8,7 +8,6 @@ import LazyLoad from 'react-lazy-load'
import ProductSimilar from '../ProductSimilar'
import { toast } from 'react-hot-toast'
import { updateItemCart } from '@/core/utils/cart'
-import useVariantPrice from '@/lib/variant/hooks/useVariantPrice'
import useProductPrice from '../../hooks/useProductPrice'
import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton'
import { useRouter } from 'next/router'
@@ -193,7 +192,23 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
<td>{variant.code}</td>
<td>{variant.attributes.join(', ') || '-'}</td>
<td>
- <VariantPrice id={variant.id} />
+ {variant.price.discountPercentage > 0 && variant.price.priceDiscount > 0 && (
+ <>
+ <div className='line-through text-caption-1 text-gray_r-11 mb-1'>
+ {currencyFormat(variant.price.price)}
+ </div>{' '}
+ </>
+ )}
+ <div>
+ {variant.price.priceDiscount > 0 ? (
+ currencyFormat(variant.price.priceDiscount)
+ ) : (
+ <a href='https://wa.me/' className='text-red_r-11'>
+ Call for price
+ </a>
+ )}
+ </div>
+ {/* <VariantPrice id={variant.id} /> */}
</td>
<td>
<input
@@ -269,33 +284,6 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
)
}
-const VariantPrice = ({ id }) => {
- const { variantPrice } = useVariantPrice({ id })
-
- if (variantPrice.isLoading) return <PriceSkeleton />
-
- return (
- <>
- {variantPrice?.data?.discount > 0 && variantPrice?.data?.priceExcludeAfterDiscount > 0 && (
- <>
- <div className='line-through text-caption-1 text-gray_r-11 mb-1'>
- {currencyFormat(variantPrice?.data?.priceExclude)}
- </div>{' '}
- </>
- )}
- <div>
- {variantPrice?.data?.priceExcludeAfterDiscount > 0 ? (
- currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount)
- ) : (
- <a href='https://wa.me/' className='text-red_r-11'>
- Call for price
- </a>
- )}
- </div>
- </>
- )
-}
-
const informationTabOptions = [
{ value: 'description', label: 'Deskripsi' },
{ value: 'information', label: 'Info Penting' }