From 949a03f9a12b17fad85ecc58baad6352ba98d04d Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 27 Mar 2023 13:41:19 +0700 Subject: fix dark mode --- .../product/components/ProductFilterDesktop.jsx | 54 ++++++++------------- src/lib/product/components/ProductSearch.jsx | 56 ++++++---------------- 2 files changed, 34 insertions(+), 76 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index 276a7cc9..e430ac58 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -1,9 +1,8 @@ -import BottomPopup from '@/core/components/elements/Popup/BottomPopup' import { useRouter } from 'next/router' import { useState } from 'react' import _ from 'lodash' import { toQuery } from 'lodash-contrib' -import { Accordion, Badge, Checkbox, Label, TextInput } from 'flowbite-react' +import { Accordion, Checkbox, Label, TextInput } from 'flowbite-react' const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = null }) => { const router = useRouter() @@ -51,29 +50,22 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu return ( <> - + Kategori - -
+ +
{categories.map((category, index) => ( -
+
- - {/*
250
*/} +
))}
@@ -82,24 +74,20 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu {!defaultBrand && ( <> - Brand - -
+ Brand + +
{brands.map((brand, index) => ( -
+
- - {/*
250
*/} +
))}
@@ -108,7 +96,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu )} - Harga + Harga
-
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 3078eac5..b5d7c974 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -10,7 +10,6 @@ import useActive from '@/core/hooks/useActive' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' import NextImage from 'next/image' -import { ChevronDownIcon } from '@heroicons/react/24/outline' import ProductFilterDesktop from './ProductFilterDesktop' import { useRouter } from 'next/router' @@ -43,7 +42,6 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { ) const [open, setOpen] = useState(1) - const [order, setOrder] = useState(query?.orderBy) const handleOpen = (value) => { setOpen(open === value ? 0 : value) @@ -55,15 +53,15 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { { value: 'stock', label: 'Ready Stock' } ] - const handleOrderBy = (e) => { + const handleOrderBy = (e) => { let params = { ...router.query, - orderBy: e.target.value - } - params = _.pickBy(params, _.identity) - params = toQuery(params) - router.push(`${prefixUrl}?${params}`) - } + orderBy: e.target.value + } + params = _.pickBy(params, _.identity) + params = toQuery(params) + router.push(`${prefixUrl}?${params}`) + } useEffect(() => { if (!products) { @@ -109,21 +107,13 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { )}
-
{products && - products.map((product) => ( - - ))} + products.map((product) => )}
{ )}
- {/*
- -
*/}
@@ -211,12 +193,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
{products && - products.map((product) => ( - - ))} + products.map((product) => )}
@@ -229,10 +206,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
Barang yang anda cari tidak ada?{' '} - + Hubungi Kami -- cgit v1.2.3 From 7ed2913450713655d2e962846d795dc6b4091de4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 27 Mar 2023 15:17:59 +0700 Subject: cart --- src/lib/address/components/Addresses.jsx | 2 +- src/lib/cart/components/Cart.jsx | 13 +++++++++++-- src/lib/category/components/Category.jsx | 6 +++--- src/lib/invoice/components/Invoice.jsx | 9 +-------- src/lib/product/components/Product/ProductDesktop.jsx | 8 ++++++-- src/lib/product/components/ProductFilterDesktop.jsx | 2 -- src/lib/transaction/components/Transaction.jsx | 6 +++--- 7 files changed, 25 insertions(+), 21 deletions(-) (limited to 'src/lib') 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 = () => {

Daftar Alamat

- + Tambah Alamat
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) => (
{category.name} @@ -42,7 +42,7 @@ const Category = () => { {category.childs.map((child1Category) => (
{child1Category.name} @@ -50,7 +50,7 @@ const Category = () => {
{child1Category.childs.map((child2Category) => ( 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 }) => {
Purchase Order
- :{' '} - + : {invoice?.data?.purchaseOrderName || '-'}
Ketentuan Pembayaran
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) ) : ( - + Hubungi kami untuk dapatkan harga terbaik,  klik disini @@ -261,7 +261,11 @@ const VariantPrice = ({ id }) => { {' '} )} - {currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount)} + {variantPrice?.data?.priceExcludeAfterDiscount > 0 ? ( + currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount) + ) : ( + Call for price + )} ) } 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 }) => { @@ -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 @@ -547,7 +547,7 @@ const SectionContent = ({ address }) => { const DescriptionRow = ({ children, label }) => (
{label} - {children} + {children}
) -- cgit v1.2.3 From a040418bdddd5fcaf8a8d67e0a66ea92fd16ee24 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 27 Mar 2023 17:03:28 +0700 Subject: - --- src/lib/cart/components/Cart.jsx | 4 ++-- src/lib/checkout/components/Checkout.jsx | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index d646420c..7ebee14b 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -93,11 +93,11 @@ const Cart = () => { quantity -= value break case 'BLUR': - if (value != '') return + if (value != '' && value > 0) return quantity = 1 break default: - quantity = value + quantity = value != '' && value < 1 ? 1 : value break } productsToUpdate[productIndex].quantity = quantity diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 57d217a7..048bb24e 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -19,6 +19,7 @@ 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() @@ -77,11 +78,21 @@ const Checkout = () => { } const dataProducts = await CartApi({ variantIds }) - const dataProductsQuantity = _.map(dataProducts, (o) => ({ - ...o, - quantity: query.quantity ? query.quantity : getItemCart({ productId: o.id }).quantity - })) - setProducts(dataProductsQuantity) + const productsWithQuantity = dataProducts.map(async (product) => { + const productPrice = await variantPriceApi({ id: product.id }) + return { + ...product, + price: { + price: productPrice.priceExclude, + discountPercentage: productPrice.discount, + priceDiscount: productPrice.priceExcludeAfterDiscount + }, + quantity: query.quantity ? query.quantity : getItemCart({ productId: product.id }).quantity + } + }) + Promise.all(productsWithQuantity).then((resolvedProducts) => { + setProducts(resolvedProducts) + }) } loadProducts() }, [router]) @@ -439,7 +450,7 @@ const Checkout = () => {

Ukuran dokumen PO Maksimal 5MB


- +