summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-03-27 15:17:59 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-03-27 15:17:59 +0700
commit7ed2913450713655d2e962846d795dc6b4091de4 (patch)
treef3f38ecde8dfc3514d6edc66a6f41f13868918bc /src/lib
parent949a03f9a12b17fad85ecc58baad6352ba98d04d (diff)
cart
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/address/components/Addresses.jsx2
-rw-r--r--src/lib/cart/components/Cart.jsx13
-rw-r--r--src/lib/category/components/Category.jsx6
-rw-r--r--src/lib/invoice/components/Invoice.jsx9
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx8
-rw-r--r--src/lib/product/components/ProductFilterDesktop.jsx2
-rw-r--r--src/lib/transaction/components/Transaction.jsx6
7 files changed, 25 insertions, 21 deletions
diff --git a/src/lib/address/components/Addresses.jsx b/src/lib/address/components/Addresses.jsx
index a2adecb1..db338983 100644
--- a/src/lib/address/components/Addresses.jsx
+++ b/src/lib/address/components/Addresses.jsx
@@ -61,7 +61,7 @@ const Addresses = () => {
<div className='w-9/12 p-4 bg-white border border-gray_r-6 rounded'>
<div className='flex items-center mb-6'>
<h1 className='text-title-sm font-semibold'>Daftar Alamat</h1>
- <Link href='/my/address/create' className='btn-solid-red py-2 px-3 text-gray_r-1 h-fit ml-auto'>
+ <Link href='/my/address/create' className='btn-solid-red py-2 px-3 !text-gray_r-1 h-fit ml-auto'>
Tambah Alamat
</Link>
</div>
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx
index 8cd6df96..d646420c 100644
--- a/src/lib/cart/components/Cart.jsx
+++ b/src/lib/cart/components/Cart.jsx
@@ -14,6 +14,7 @@ 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()
@@ -28,16 +29,24 @@ const Cart = () => {
useEffect(() => {
if (cart.data && !products) {
- const productsWithQuantity = cart.data.map((product) => {
+ const productsWithQuantity = cart.data.map(async (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
}
})
- setProducts(productsWithQuantity)
+ Promise.all(productsWithQuantity).then((resolvedProducts) => {
+ setProducts(resolvedProducts)
+ })
}
}, [cart, products])
diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx
index 5ba45cc7..9f34362c 100644
--- a/src/lib/category/components/Category.jsx
+++ b/src/lib/category/components/Category.jsx
@@ -32,7 +32,7 @@ const Category = () => {
{categories.map((category) => (
<div key={category.id}>
<Link
- href='/'
+ href={`/shop/search?category=${category.name}`}
className='category-mega-box__parent'
>
{category.name}
@@ -42,7 +42,7 @@ const Category = () => {
{category.childs.map((child1Category) => (
<div key={child1Category.id}>
<Link
- href='/'
+ href={`/shop/search?category=${child1Category.name}`}
className='category-mega-box__child-one mb-4'
>
{child1Category.name}
@@ -50,7 +50,7 @@ const Category = () => {
<div className='flex flex-col gap-y-3'>
{child1Category.childs.map((child2Category) => (
<Link
- href='/'
+ href={`/shop/search?category=${child2Category.name}`}
className='category-mega-box__child-two'
key={child2Category.id}
>
diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx
index 355f36e5..211d1ae1 100644
--- a/src/lib/invoice/components/Invoice.jsx
+++ b/src/lib/invoice/components/Invoice.jsx
@@ -153,14 +153,7 @@ const Invoice = ({ id }) => {
<div>Purchase Order</div>
<div>
- :{' '}
- <button
- type='button'
- className='inline-block text-red_r-11'
- onClick={() => downloadInvoice(invoice.data)}
- >
- Download
- </button>
+ : {invoice?.data?.purchaseOrderName || '-'}
</div>
<div>Ketentuan Pembayaran</div>
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 663d5a74..2f73d124 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -125,7 +125,7 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
{productPrice?.data?.priceExcludeAfterDiscount > 0 ? (
currencyFormat(productPrice?.data?.priceExcludeAfterDiscount)
) : (
- <span className='text-gray_r-11 leading-6 font-normal'>
+ <span className='text-gray_r-12/90 font-normal text-h-sm'>
Hubungi kami untuk dapatkan harga terbaik,&nbsp;
<a href='https://wa.me/' className='text-red_r-11 underline'>
klik disini
@@ -261,7 +261,11 @@ const VariantPrice = ({ id }) => {
</span>{' '}
</>
)}
- {currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount)}
+ {variantPrice?.data?.priceExcludeAfterDiscount > 0 ? (
+ currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount)
+ ) : (
+ <a href='https://wa.me/' className='text-red_r-11'>Call for price</a>
+ )}
</>
)
}
diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx
index e430ac58..ce6c12ed 100644
--- a/src/lib/product/components/ProductFilterDesktop.jsx
+++ b/src/lib/product/components/ProductFilterDesktop.jsx
@@ -32,8 +32,6 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu
}
}
- console.log('branddddd', defaultBrand)
-
const handleSubmit = () => {
let params = {
q: router.query.q,
diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 104a7f2d..b921eb0d 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -260,7 +260,7 @@ const Transaction = ({ id }) => {
<button
className='btn-light w-full mt-4'
disabled={transaction.data?.status != 'draft'}
- onClick={downloadQuotation}
+ onClick={() => downloadQuotation(transaction.data)}
>
Download Quotation
</button>
@@ -292,7 +292,7 @@ const Transaction = ({ id }) => {
type='button'
className='btn-solid-red px-3 py-2'
disabled={transaction.data?.status != 'draft'}
- onClick={downloadQuotation}
+ onClick={() => downloadQuotation(transaction.data)}
>
Download
</button>
@@ -547,7 +547,7 @@ const SectionContent = ({ address }) => {
const DescriptionRow = ({ children, label }) => (
<div className='grid grid-cols-2'>
<span className='text-gray_r-11'>{label}</span>
- <span className='text-right'>{children}</span>
+ <span className='text-right break-all leading-6'>{children}</span>
</div>
)