diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/components/elements/Popup/BottomPopup.jsx | 6 | ||||
| -rw-r--r-- | src/lib/address/components/Addresses.jsx | 2 | ||||
| -rw-r--r-- | src/lib/cart/components/Cart.jsx | 17 | ||||
| -rw-r--r-- | src/lib/category/components/Category.jsx | 6 | ||||
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 23 | ||||
| -rw-r--r-- | src/lib/invoice/components/Invoice.jsx | 9 | ||||
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktop.jsx | 8 | ||||
| -rw-r--r-- | src/lib/product/components/ProductFilterDesktop.jsx | 56 | ||||
| -rw-r--r-- | src/lib/product/components/ProductSearch.jsx | 56 | ||||
| -rw-r--r-- | src/lib/transaction/components/Transaction.jsx | 6 |
10 files changed, 81 insertions, 108 deletions
diff --git a/src/core/components/elements/Popup/BottomPopup.jsx b/src/core/components/elements/Popup/BottomPopup.jsx index c244330c..5828d222 100644 --- a/src/core/components/elements/Popup/BottomPopup.jsx +++ b/src/core/components/elements/Popup/BottomPopup.jsx @@ -48,9 +48,9 @@ const BottomPopup = ({ children, active = false, title, close }) => { <DesktopView> <motion.div - initial={{ bottom: '35%', opacity: 0 }} - animate={{ bottom: '30%', opacity: 1 }} - exit={{ bottom: '25%', opacity: 0 }} + initial={{ bottom: '40%', opacity: 0 }} + animate={{ bottom: '35%', opacity: 1 }} + exit={{ bottom: '30%', opacity: 0 }} transition={transition} className='fixed left-1/2 -translate-x-1/2 w-2/5 border border-gray_r-6 rounded-xl z-[60] p-4 pt-0 bg-white' > 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..7ebee14b 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]) @@ -84,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/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/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 = () => { <p className='text-caption-2 text-gray_r-11 mt-2'>Ukuran dokumen PO Maksimal 5MB</p> <hr className='my-4 border-gray_r-6' /> - + <button className='w-full btn-yellow mt-4' onClick={checkout} 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, <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 276a7cc9..ce6c12ed 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() @@ -33,8 +32,6 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu } } - console.log('branddddd', defaultBrand) - const handleSubmit = () => { let params = { q: router.query.q, @@ -51,29 +48,22 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu return ( <> - <Accordion - flush={true} - alwaysOpen={true} - > + <Accordion flush={true} alwaysOpen={true}> <Accordion.Panel> <Accordion.Title>Kategori</Accordion.Title> - <Accordion.Content className='overflow-auto max-h-[150px]'> - <div - className='flex flex-col gap-4 scroll-snap' - id='checkbox' - > + <Accordion.Content className='overflow-auto max-h-[200px]'> + <div className='flex flex-col gap-4 scroll-snap' id='checkbox'> {categories.map((category, index) => ( - <div - className='flex items-center gap-2' - key={index} - > + <div className='flex items-center gap-2' key={index}> <Checkbox + id={`categoryOption${index}`} checked={categoryValues.includes(category)} onChange={handleCategorysChange} value={category} /> - <Label htmlFor='accept'> {category} </Label> - {/* <div className='badge-solid-red'>250</div> */} + <Label htmlFor={`categoryOption${index}`} className='dark:text-gray_r-12/80'> + {category} + </Label> </div> ))} </div> @@ -82,24 +72,20 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu <Accordion.Panel> {!defaultBrand && ( <> - <Accordion.Title >Brand</Accordion.Title> - <Accordion.Content className='overflow-auto max-h-[150px]'> - <div - className='flex flex-col gap-4 scroll-snap' - id='checkbox' - > + <Accordion.Title>Brand</Accordion.Title> + <Accordion.Content className='overflow-auto max-h-[200px]'> + <div className='flex flex-col gap-4 scroll-snap' id='checkbox'> {brands.map((brand, index) => ( - <div - className='flex items-center gap-2' - key={index} - > + <div className='flex items-center gap-2' key={index}> <Checkbox + id={`brandOption${index}`} checked={brandValues.includes(brand)} onChange={handleBrandsChange} value={brand} /> - <Label htmlFor='accept'> {brand} </Label> - {/* <div className='badge-solid-red'>250</div> */} + <Label htmlFor={`brandOption${index}`} className='dark:text-gray_r-12/80'> + {brand} + </Label> </div> ))} </div> @@ -108,7 +94,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu )} </Accordion.Panel> <Accordion.Panel> - <Accordion.Title> Harga </Accordion.Title> + <Accordion.Title>Harga</Accordion.Title> <Accordion.Content> <div className='mb-3'> <TextInput @@ -132,11 +118,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu </Accordion.Panel> </Accordion> <div className='p-5'> - <button - type='button' - className='btn-solid-red w-full mt-6' - onClick={handleSubmit} - > + <button type='button' className='btn-solid-red w-full mt-6' onClick={handleSubmit}> Terapkan </button> </div> 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 }) => { )} </div> - <button - className='btn-light mb-6 py-2 px-5' - onClick={popup.activate} - > + <button className='btn-light mb-6 py-2 px-5' onClick={popup.activate}> Filter </button> <div className='grid grid-cols-2 gap-3'> {products && - products.map((product) => ( - <ProductCard - product={product} - key={product.id} - /> - ))} + products.map((product) => <ProductCard product={product} key={product.id} />)} </div> <Pagination @@ -184,17 +174,6 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { )} </div> <div className='justify-end flex '> - {/* <div> - <select - name='jumlah-baris' - className='form-input mt-2' - > - <option value=''>Jumlah Baris</option> - {orderOptions.map((option, index) => ( - <option value={option.value}> {option.label} </option> - ))} - </select> - </div> */} <div className='ml-3'> <select name='urutan' @@ -203,7 +182,10 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { > <option value=''>Urutkan</option> {orderOptions.map((option, index) => ( - <option value={option.value}> {option.label} </option> + <option key={index} value={option.value}> + {' '} + {option.label}{' '} + </option> ))} </select> </div> @@ -211,12 +193,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { </div> <div className='grid grid-cols-5 gap-x-3 gap-y-6'> {products && - products.map((product) => ( - <ProductCard - product={product} - key={product.id} - /> - ))} + products.map((product) => <ProductCard product={product} key={product.id} />)} </div> <div className='flex justify-between items-center mt-6 mb-2'> <div className='pt-2 pb-6 flex items-center gap-x-3'> @@ -229,10 +206,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { <div className='text-gray_r-12/90'> <span> Barang yang anda cari tidak ada?{' '} - <a - href='#' - className='text-red_r-9' - > + <a href='#' className='text-red_r-9'> Hubungi Kami </a> </span> 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> ) |
