From 39078f7b6978daaf062d1911b08d0207205526ad Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 9 Oct 2023 11:32:36 +0700 Subject: change rounded --- src/lib/product/components/ProductCard.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 91c1f40e..3b96ac32 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -38,7 +38,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
-
+
{product?.lowestPrice.discountPercentage}% -- cgit v1.2.3 From d47446d97b052f8298bb948ad070fdcbeaaa61a3 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 9 Oct 2023 11:48:28 +0700 Subject: call for price --- src/lib/product/api/productSimilarApi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/product/api/productSimilarApi.js b/src/lib/product/api/productSimilarApi.js index a008ce5d..ecd6724a 100644 --- a/src/lib/product/api/productSimilarApi.js +++ b/src/lib/product/api/productSimilarApi.js @@ -19,7 +19,7 @@ const productSimilarApi = async ({ query, source }) => { } } const dataProductSimilar = await axios( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=${query}&page=1&orderBy=popular-weekly&operation=OR` + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=${query}&page=1&orderBy=popular-weekly&operation=OR&priceFrom=1` ) if (dataflashSale) { dataProductSimilar.data.response.products = [ -- cgit v1.2.3 From 23f67959168cd0126582c44f2a5b1bfdc45b268a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 10:22:11 +0700 Subject: Add breadcrumb on detail product, search, brand, category page --- src/lib/brand/components/Brand.jsx | 4 +- src/lib/brand/components/Breadcrumb.jsx | 40 ++++++++++++ src/lib/category/components/Breadcrumb.jsx | 56 +++++++++++++++++ src/lib/category/components/Category.jsx | 2 +- src/lib/product/components/Product/Breadcrumb.jsx | 69 +++++++++++++++++++++ src/lib/product/components/Product/Product.jsx | 38 +++++------- .../product/components/Product/ProductDesktop.jsx | 71 +++++++++++----------- .../product/components/Product/ProductMobile.jsx | 2 + src/lib/product/components/ProductSearch.jsx | 4 +- .../promotinProgram/components/PromotionType.jsx | 2 +- 10 files changed, 225 insertions(+), 63 deletions(-) create mode 100644 src/lib/brand/components/Breadcrumb.jsx create mode 100644 src/lib/category/components/Breadcrumb.jsx create mode 100644 src/lib/product/components/Product/Breadcrumb.jsx (limited to 'src/lib') diff --git a/src/lib/brand/components/Brand.jsx b/src/lib/brand/components/Brand.jsx index 3c411969..3985b888 100644 --- a/src/lib/brand/components/Brand.jsx +++ b/src/lib/brand/components/Brand.jsx @@ -84,7 +84,7 @@ const Brand = ({ id }) => { -
+
{brand.isLoading && } {brand.data?.banners?.length == 0 && ( @@ -117,6 +117,7 @@ const Brand = ({ id }) => { ))} +
Produk dari brand:
{brand?.data?.logo && ( @@ -137,7 +138,6 @@ const Brand = ({ id }) => { )}
-
diff --git a/src/lib/brand/components/Breadcrumb.jsx b/src/lib/brand/components/Breadcrumb.jsx new file mode 100644 index 00000000..0fec2dad --- /dev/null +++ b/src/lib/brand/components/Breadcrumb.jsx @@ -0,0 +1,40 @@ +import { Breadcrumb as ChakraBreadcrumb, BreadcrumbItem, BreadcrumbLink } from '@chakra-ui/react' +import Link from 'next/link' +import React from 'react' + +/** + * Renders a breadcrumb component with links to navigate through different pages. + * + * @param {Object} props - The props object containing the brand name. + * @param {string} props.brandName - The name of the brand to display in the breadcrumb. + * @return {JSX.Element} The rendered breadcrumb component. + */ +const Breadcrumb = ({ brandName }) => { + return ( +
+ + + + Home + + + + + + Brands + + + + + {brandName} + + +
+ ) +} + +export default Breadcrumb diff --git a/src/lib/category/components/Breadcrumb.jsx b/src/lib/category/components/Breadcrumb.jsx new file mode 100644 index 00000000..127904ee --- /dev/null +++ b/src/lib/category/components/Breadcrumb.jsx @@ -0,0 +1,56 @@ +import odooApi from '@/core/api/odooApi' +import { createSlug } from '@/core/utils/slug' +import { + Breadcrumb as ChakraBreadcrumb, + BreadcrumbItem, + BreadcrumbLink, + Skeleton +} from '@chakra-ui/react' +import Link from 'next/link' +import React from 'react' +import { useQuery } from 'react-query' + +/** + * Render a breadcrumb component. + * + * @param {object} categoryId - The ID of the category. + * @return {JSX.Element} The breadcrumb component. + */ +const Breadcrumb = ({ categoryId }) => { + const breadcrumbs = useQuery( + `category-breadcrumbs/${categoryId}`, + async () => await odooApi('GET', `/api/v1/category/${categoryId}/category-breadcrumb`) + ) + + return ( +
+ + + + + Home + + + + {breadcrumbs.data?.map((category, index) => ( + + {index === breadcrumbs.data.length - 1 ? ( + {category.name} + ) : ( + + {category.name} + + )} + + ))} + + +
+ ) +} + +export default Breadcrumb diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx index af696d42..e6ea5acf 100644 --- a/src/lib/category/components/Category.jsx +++ b/src/lib/category/components/Category.jsx @@ -30,7 +30,7 @@ const Category = () => { return (
- {categories.map((category) => ( + {categories?.map((category) => (
{ + const categories = useQuery( + `detail/categories/${productId}`, + async () => await odooApi('GET', `/api/v1/product/${productId}/category-breadcrumb`), + { + enabled: !!productId + } + ) + + return ( + + + + + Home + + + + {categories.data?.map((category) => ( + + + {category.name} + + + ))} + + + {productName} + + + + ) +} + +export default Breadcrumb diff --git a/src/lib/product/components/Product/Product.jsx b/src/lib/product/components/Product/Product.jsx index 54490c26..6e983c2e 100644 --- a/src/lib/product/components/Product/Product.jsx +++ b/src/lib/product/components/Product/Product.jsx @@ -36,29 +36,21 @@ const Product = ({ product, isVariant = false }) => { } }, [product, isVariant]) - if (isVariant == true) { - return ( - <> - - - - ) - } else { - return ( - <> - - - - ) - } + return isVariant == true ? ( + <> + + + + ) : ( + <> + + + + ) } export default Product diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 47e98c1a..ceb0cad7 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -24,6 +24,7 @@ import ColumnsSLA from './ColumnsSLA' import { useProductCartContext } from '@/contexts/ProductCartContext' import { Box, Skeleton, Tooltip } from '@chakra-ui/react' import { Info } from 'lucide-react' +import Breadcrumb from './Breadcrumb' const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { const router = useRouter() @@ -199,47 +200,49 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { return (
+
- {product?.flashSale?.remainingTime > 0 && lowestPrice?.price.discountPercentage > 0 && ( -
-
- -
-
-
-
- - {Math.floor(product.lowestPrice.discountPercentage)}% - -
-
- - - {product?.flashSale?.tag != 'false' || product?.flashSale?.tag - ? product?.flashSale?.tag - : 'FLASH SALE'} - -
-
- + {product?.flashSale?.remainingTime > 0 && + lowestPrice?.price.discountPercentage > 0 && ( +
+
+ +
+
+
+
+ + {Math.floor(product.lowestPrice.discountPercentage)}% + +
+
+ + + {product?.flashSale?.tag != 'false' || product?.flashSale?.tag + ? product?.flashSale?.tag + : 'FLASH SALE'} + +
+
+ +
-
- )} + )} {product.name} { const router = useRouter() @@ -160,6 +161,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { return ( +
{product?.flashSale?.remainingTime > 0 && activeVariant?.price.discountPercentage > 0 && (
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index df9aa91b..f6987051 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -117,7 +117,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { <> {productSearch.isLoading && } -
+

Produk

@@ -178,7 +178,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { -
+
{ const programs = await getPromotionProgram({ id }) - if (programs.length > 0) { + if (programs?.length > 0) { setPromotionList(programs) setActiveTitle(programs?.[0].type.value) } -- cgit v1.2.3 From 5a2cc16003e1fbd6a31e24388f6471c9dd7e062d Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 14:07:58 +0700 Subject: Fix description and brand banner skeleton --- src/lib/brand/components/Brand.jsx | 121 ++++++++++++--------- .../product/components/Product/ProductDesktop.jsx | 2 +- 2 files changed, 68 insertions(+), 55 deletions(-) (limited to 'src/lib') diff --git a/src/lib/brand/components/Brand.jsx b/src/lib/brand/components/Brand.jsx index 3985b888..4afbcb3e 100644 --- a/src/lib/brand/components/Brand.jsx +++ b/src/lib/brand/components/Brand.jsx @@ -6,10 +6,10 @@ import { Pagination, Autoplay } from 'swiper' import 'swiper/css' import 'swiper/css/pagination' import 'swiper/css/autoplay' -import Divider from '@/core/components/elements/Divider/Divider' -import ImageSkeleton from '@/core/components/elements/Skeleton/ImageSkeleton' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' +import { Skeleton } from '@chakra-ui/react' +import classNames from 'classnames' const swiperBanner = { pagination: { dynamicBullets: true }, @@ -28,65 +28,77 @@ const Brand = ({ id }) => { <>
- {brand.isLoading && } - {brand.data?.banners?.length == 0 && ( - Brand - Indoteknik - )} - {brand.data && ( - <> - - {brand.data?.banners?.map((banner, index) => ( - + + {brand.data?.banners?.length == 0 && ( + Brand - Indoteknik + )} + + {brand.data && ( + <> + + {brand.data?.banners?.map((banner, index) => ( + + {`Brand + + ))} + +
+
Produk dari brand:
+ {brand?.data?.logo && ( {`Brand - - ))} - -
-
Produk dari brand:
- {brand?.data?.logo && ( - {brand?.data?.name} - )} - {!brand?.data?.logo && ( -
- {brand?.data?.name} -
- )} -
- - )} + )} + {!brand?.data?.logo && ( +
+ {brand?.data?.name} +
+ )} +
+ + )} +
-
-
- {brand.isLoading && } + {brand.data?.banners?.length == 0 && ( { className='w-full h-auto' /> )} + {brand.data && ( <> {
)} -
+
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index ceb0cad7..855c9f75 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -393,7 +393,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { ))}
-
+
Date: Wed, 3 Apr 2024 10:31:14 +0700 Subject: Add voucher shipping feature --- src/lib/checkout/api/checkoutApi.js | 34 ++--- src/lib/checkout/api/getVoucher.js | 37 ++--- src/lib/checkout/components/Checkout.jsx | 224 ++++++++++++++++++++++++++----- 3 files changed, 224 insertions(+), 71 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/api/checkoutApi.js b/src/lib/checkout/api/checkoutApi.js index 24f1868a..fd982fff 100644 --- a/src/lib/checkout/api/checkoutApi.js +++ b/src/lib/checkout/api/checkoutApi.js @@ -1,28 +1,20 @@ -import odooApi from '@/core/api/odooApi' -import { getAuth } from '@/core/utils/auth' +import odooApi from '@/core/api/odooApi'; +import { getAuth } from '@/core/utils/auth'; export const checkoutApi = async ({ data }) => { - const auth = getAuth() + const auth = getAuth(); const dataCheckout = await odooApi( 'POST', `/api/v1/partner/${auth.partnerId}/sale_order/checkout`, data - ) - return dataCheckout -} + ); + return dataCheckout; +}; -export const getProductsCheckout = async (voucher, query) => { - const id = getAuth()?.id - let products - if(voucher && query){ - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?voucher=${voucher}&source=buy`) - }else if (voucher){ - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?voucher=${voucher}`) - }else if (query) { - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?source=buy`) - }else{ - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout`) - } - - return products -} +export const getProductsCheckout = async (query) => { + const queryParam = new URLSearchParams(query); + const userId = getAuth()?.id; + const url = `/api/v1/user/${userId}/sale_order/checkout?${queryParam.toString()}`; + const result = await odooApi('GET', url); + return result; +}; diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js index 07cf376e..54c8cce5 100644 --- a/src/lib/checkout/api/getVoucher.js +++ b/src/lib/checkout/api/getVoucher.js @@ -1,21 +1,24 @@ -import odooApi from '@/core/api/odooApi' +import odooApi from '@/core/api/odooApi'; -export const getVoucher = async (id, source) => { - let dataVoucher = null - if(source){ - dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?source=${source}`) - }else { - dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher`) - } - return dataVoucher -} +export const getVoucher = async (id, query) => { + const queryParam = new URLSearchParams(query); + const url = `/api/v1/user/${id}/voucher?${queryParam.toString()}`; + const dataVoucher = await odooApi('GET', url); + return dataVoucher; +}; export const findVoucher = async (code, id, source) => { - let dataVoucher = null - if(source){ - dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?code=${code}&source=${source}`) - }else{ - dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?code=${code}`) + let dataVoucher = null; + if (source) { + dataVoucher = await odooApi( + 'GET', + `/api/v1/user/${id}/voucher?code=${code}&source=${source}` + ); + } else { + dataVoucher = await odooApi( + 'GET', + `/api/v1/user/${id}/voucher?code=${code}` + ); } - return dataVoucher -} + return dataVoucher; +}; diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 52edbd05..042fc258 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -43,9 +43,16 @@ const Checkout = () => { const auth = useAuth(); const [activeVoucher, SetActiveVoucher] = useState(null); - - const { data: cartCheckout } = useQuery('cartCheckout-' + activeVoucher, () => - getProductsCheckout(activeVoucher, query) + const [activeVoucherShipping, setActiveVoucherShipping] = useState(null); + + const { data: cartCheckout } = useQuery( + ['cartCheckout', activeVoucher, activeVoucherShipping], + () => + getProductsCheckout({ + source: query, + voucher: activeVoucher, + voucher_shipping: activeVoucherShipping, + }) ); const [selectedAddress, setSelectedAddress] = useState({ @@ -103,6 +110,7 @@ const Checkout = () => { const [bottomPopupTnC, SetBottomPopupTnC] = useState(null); const [itemTnC, setItemTnC] = useState(null); const [listVouchers, SetListVoucher] = useState(null); + const [listVoucherShippings, SetListVoucherShipping] = useState(null); const [discountVoucher, SetDiscountVoucher] = useState(0); const [codeVoucher, SetCodeVoucher] = useState(null); const [findCodeVoucher, SetFindVoucher] = useState(null); @@ -117,13 +125,23 @@ const Checkout = () => { const voucher = async () => { if (!listVouchers) { try { - let dataVoucher = await getVoucher(auth?.id, query); + setLoadingVoucher(true); + let dataVoucher = await getVoucher(auth?.id, { + source: query, + }); SetListVoucher(dataVoucher); + + let dataVoucherShipping = await getVoucher(auth?.id, { + source: query, + type: 'shipping', + }); + SetListVoucherShipping(dataVoucherShipping); } finally { setLoadingVoucher(false); } } }; + const VoucherCode = async (code) => { let dataVoucher = await findVoucher(code, auth.id, query); if (dataVoucher.length <= 0) { @@ -333,6 +351,7 @@ const Checkout = () => { estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, voucher: activeVoucher, + voucher_shipping: activeVoucherShipping, type: 'sale_order', }; @@ -419,6 +438,11 @@ const Checkout = () => { return false; }, [products]); + const voucherShippingAmt = cartCheckout?.discountVoucherShipping || 0; + const discShippingAmt = Math.min(biayaKirim, voucherShippingAmt); + + const finalShippingAmt = biayaKirim - discShippingAmt; + return ( <> {
)} -
-
+
+ + {listVoucherShippings && listVoucherShippings?.length > 0 && ( +
+

Promo Gratis Ongkir

+ {listVoucherShippings?.map((item) => ( +
+
+ {item.canApply && ( + + )} + {!item.canApply && ( + + )} + +
+ {item.canApply === false && ( +
+ )} +
+ {item.name} +
+
+
+
+

{item.name}

+
+ + {item.description}{' '} + +
+
+
+ +
+
+
+
+

+ Kode Voucher :{' '} + + {item.code} + +

+

+ {activeVoucher === item.code && ( + + Voucher digunakan{' '} + + )} +

+
+
+ +
+
+ Berakhir dalam{' '} + + {item.remainingTime} + {' '} + lagi,{' '} +
+
handlingTnC(item)} + > + Baca S&K +
+
+
+
+
+
+

+
+
+
+ ))} +
+ )} + +
+ +
{!loadingVoucher && listVouchers?.length === 0 ? (
@@ -714,14 +875,7 @@ const Checkout = () => {
-

- {/* {item.canApply === false - ? 'Tambah ' + - currencyFormat(item.differenceToApply) + - ' untuk pakai promo ini' - : 'Potensi potongan sebesar ' + - currencyFormat(hitungDiscountVoucher(item.code))} */} -

+

@@ -887,14 +1041,18 @@ const Checkout = () => {
- Biaya Kirim

{etdFix}

-
-
- {currencyFormat( - Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 - )} + Biaya Kirim

{etdFix}

+
{currencyFormat(biayaKirim)}
+ {activeVoucherShipping && voucherShippingAmt && ( +
+
Diskon Kirim
+
+ - {currencyFormat(discShippingAmt)} +
+
+ )}
)} @@ -913,10 +1071,7 @@ const Checkout = () => {
Grand Total
- {currencyFormat( - cartCheckout?.grandTotal + - Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 - )} + {currencyFormat(cartCheckout?.grandTotal + finalShippingAmt)}
)} @@ -926,7 +1081,7 @@ const Checkout = () => {
)} @@ -1209,8 +1368,7 @@ const Checkout = () => {
Grand Total
{currencyFormat( - cartCheckout?.grandTotal + - Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 + cartCheckout?.grandTotal + finalShippingAmt )}
-- cgit v1.2.3 From 7afd73bde637528e9427124b6e9842a026f823f6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 21 Jun 2024 16:46:24 +0700 Subject: remove console log --- src/lib/product/components/ProductFilterDesktop.jsx | 1 - src/lib/product/components/ProductSearch.jsx | 2 -- 2 files changed, 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index b4afebc2..b9be7c15 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -21,7 +21,6 @@ import Image from '@/core/components/elements/Image/Image' import { formatCurrency } from '@/core/utils/formatValue' const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = null }) => { - console.log("prefixUrl",prefixUrl) const router = useRouter() const { query } = router const [order, setOrder] = useState(query?.orderBy) diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index ec0077c2..08b64c13 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -130,7 +130,6 @@ const ProductSearch = ({ brands.push({ brand, qty }); } } - console.log("daftar brand",brands) const categories = []; for ( @@ -145,7 +144,6 @@ const ProductSearch = ({ categories.push({ name, qty }); } } - console.log("daftar kategori",categories) const orderOptions = [ { value: 'price-asc', label: 'Harga Terendah' }, -- cgit v1.2.3 From 01bea5fe1b68fee2d673274b44295db6fc665e29 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 24 Jun 2024 14:36:56 +0700 Subject: ubah button lihat semua --- src/lib/home/components/PromotionProgram.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/home/components/PromotionProgram.jsx b/src/lib/home/components/PromotionProgram.jsx index 98bc7c7f..66216d19 100644 --- a/src/lib/home/components/PromotionProgram.jsx +++ b/src/lib/home/components/PromotionProgram.jsx @@ -12,9 +12,7 @@ const BannerSection = () => {
Promo Tersedia
{isDesktop && ( - + Lihat Semua )} -- cgit v1.2.3 From dc204e9cdbcf7faf81dba825db608be2c918589d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 9 Jul 2024 16:31:30 +0700 Subject: { + const dataCheckout = await odooApi('POST', `/api/v1/sale_order/${idSo}/reject/${idProduct}`, { + reason_reject: reason + }); + return dataCheckout +} +export default rejectProductApi \ No newline at end of file diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 9b11f5bb..03c94ded 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -33,13 +33,17 @@ import useAuth from '@/core/hooks/useAuth'; import StepApproval from './stepper'; import aprpoveApi from '../api/approveApi'; import rejectApi from '../api/rejectApi'; +import rejectProductApi from '../api/rejectProductApi'; +import { useRouter } from 'next/router'; const Transaction = ({ id }) => { + const router = useRouter() + const [isModalOpen, setIsModalOpen] = useState(false); + const [selectedProduct, setSelectedProduct] = useState(null); + const [reason, setReason] = useState(''); const auth = useAuth(); const { transaction } = useTransaction({ id }); - const statusApprovalWeb = transaction.data?.approvalStep - const { queryAirwayBill } = useAirwayBill({ orderId: id }); const [airwayBillPopup, setAirwayBillPopup] = useState(null); @@ -151,6 +155,38 @@ const Transaction = ({ id }) => { setIdAWB(null); }; + const openModal = (product) => { + setSelectedProduct(product); + setIsModalOpen(true); + }; + + const closeModal = () => { + setIsModalOpen(false); + setSelectedProduct(null); + setReason(''); + }; + + const handleRejectProduct = async () => { + try{ + if (!reason.trim()) { + toast.error('Masukkan alasan terlebih dahulu'); + return; + }else{ + let idSo = transaction?.data.id + let idProduct = selectedProduct?.id + await rejectProductApi({ idSo, idProduct, reason}); + closeModal(); + toast.success("Produk berhasil di reaject") + setTimeout(() => { + window.location.reload(); + }, 1500); + } + }catch(error){ + toast.error('Gagal reject produk. Silakan coba lagi.'); + } + }; + + return ( transaction.data?.name && ( <> @@ -566,6 +602,7 @@ const Transaction = ({ id }) => { Jumlah Harga Subtotal + @@ -620,10 +657,61 @@ const Transaction = ({ id }) => {
{currencyFormat(product.price.priceDiscount)}
{currencyFormat(product.price.subtotal)} + {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */} + {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/")) && ( + + + + )} + {/* {transaction.data.isReaject && ( + + + + )} */} ))} + {isModalOpen && ( +
+
+

Berikan Alasan

+ +
+ + +
+
+
+ )}
diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index 9f1b5733..c629c987 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -1,16 +1,25 @@ import { useRouter } from 'next/router' import { toast } from 'react-hot-toast' - +import useAuth from '@/core/hooks/useAuth'; import Image from '@/core/components/elements/Image/Image' import Link from '@/core/components/elements/Link/Link' import { createSlug } from '@/core/utils/slug' import currencyFormat from '@/core/utils/currencyFormat' import { updateItemCart } from '@/core/utils/cart' import whatsappUrl from '@/core/utils/whatsappUrl' +import {useState } from 'react'; +import rejectProductApi from '../../../lib/transaction/api/rejectProductApi' +// import {useTransaction} from 'C:\Users\Indoteknik\next-indoteknik\src\lib\transaction\hooks\useTransaction.js' +import useTransaction from '../../../lib/transaction/hooks/useTransaction'; const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { const router = useRouter() - + const id = router.query.id + const auth = useAuth(); + const { transaction } = useTransaction({id}); + const [isModalOpen, setIsModalOpen] = useState(false); + const [selectedProduct, setSelectedProduct] = useState(null); + const [reason, setReason] = useState(''); const addItemToCart = () => { toast.success('Berhasil menambahkan ke keranjang', { duration: 1500 }) updateItemCart({ @@ -19,11 +28,42 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { }) return } - + const checkoutItem = () => { router.push(`/shop/checkout?product_id=${product.id}&qty=${product.quantity}`) } - + + const openModal = (product) => { + setSelectedProduct(product); + setIsModalOpen(true); + }; + + const closeModal = () => { + setIsModalOpen(false); + setSelectedProduct(null); + setReason(''); + }; + + const handleRejectProduct = async () => { + try { + if (!reason.trim()) { + toast.error('Masukkan alasan terlebih dahulu'); + return; + }else{ + let idSo = transaction?.data.id + let idProduct = selectedProduct.id + await rejectProductApi({ idSo, idProduct, reason}); + closeModal(); + toast.success("Produk berhasil di reject") + setTimeout(() => { + window.location.reload(); + }, 1500); + } + } catch (error) { + toast.error('Gagal reject produk. Silakan coba lagi.'); + } + }; + const Card = () => (
@@ -91,14 +131,59 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { > Tambah Keranjang - + {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */} + {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/")) && ( + + + + )} + {/* {transaction.data.isReaject && ( + + + + )} */} + {isModalOpen && ( +
+
+

Berikan Alasan

+ +
+ + +
+
+
+ )}
+ )} ) -- cgit v1.2.3 From e3d0de0ba20eee9d53e95c5525907b099d2b5b04 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 10 Jul 2024 14:20:29 +0700 Subject: update reaject button & component position --- src/lib/transaction/components/Transaction.jsx | 316 ++++++++++++++++--------- src/lib/variant/components/VariantCard.jsx | 31 +-- 2 files changed, 217 insertions(+), 130 deletions(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 03c94ded..8e7cede0 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -143,6 +143,15 @@ const Transaction = ({ id }) => { [transaction.data] ); + const memoizeVariantGroupCardReject = useMemo( + () => ( +
+ +
+ ), + [transaction.data] + ); + if (transaction.isLoading) { return (
@@ -176,7 +185,7 @@ const Transaction = ({ id }) => { let idProduct = selectedProduct?.id await rejectProductApi({ idSo, idProduct, reason}); closeModal(); - toast.success("Produk berhasil di reaject") + toast.success("Produk berhasil di reject") setTimeout(() => { window.location.reload(); }, 1500); @@ -329,6 +338,37 @@ const Transaction = ({ id }) => { +
+

Invoice

+
+ {transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{invoice?.name}

+
+ {invoice.amountResidual > 0 ? ( +
Belum Lunas
+ ) : ( +
Lunas
+ )} +

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ +
+ + ))} + {transaction.data?.invoices?.length === 0 && ( +
Belum ada invoice
+ )} +
+
+ + + {!auth?.feature.soApproval && (
@@ -354,8 +394,20 @@ const Transaction = ({ id }) => {
Detail Produk
+ {transaction?.data?.products.length > 0? ( +
+ {memoizeVariantGroupCard} +
+ ) : ( +
Semua produk telah di reject
+ )} - {memoizeVariantGroupCard} + {transaction?.data?.productsRejectLine.length > 0 && ( +
+
Detail Produk Reject
+ {memoizeVariantGroupCardReject} +
+ )} @@ -363,37 +415,6 @@ const Transaction = ({ id }) => { -
-

Invoice

-
- {transaction.data?.invoices?.map((invoice, index) => ( - -
-
-

{invoice?.name}

-
- {invoice.amountResidual > 0 ? ( -
Belum Lunas
- ) : ( -
Lunas
- )} -

- {currencyFormat(invoice.amountTotal)} -

-
-
- -
- - ))} - {transaction.data?.invoices?.length === 0 && ( -
Belum ada invoice
- )} -
-
- - -
{transaction.data?.status == 'draft' && auth?.feature.soApproval && (
@@ -561,51 +582,83 @@ const Transaction = ({ id }) => { />
- -
- Pengiriman -
-
- {transaction?.data?.pickings?.map((airway) => ( - + ))} +
+
+
+
Invoice
+ {transaction.data?.invoices?.length === 0 && ( +
Belum ada invoice
+ )} +
+ {transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{invoice?.name}

+
+ {invoice.amountResidual > 0 ? ( +
Belum Lunas
+ ) : ( +
Lunas
+ )} +

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ +
+ + ))}
- - ))} +
- {transaction?.data?.pickings.length == 0 && ( -
Belum ada pengiriman
- )} -
+
Rincian Pembelian
- - - - - {/* */} - - - - - - - + {transaction?.data?.products?.length > 0? ( +
Nama ProdukDiskonJumlahHargaSubtotal
+ + + + {/* */} + + + + + + + {transaction?.data?.products?.map((product) => ( )} - {/* {transaction.data.isReaject && ( - - )} */} ))}
Nama ProdukDiskonJumlahHargaSubtotal
@@ -668,21 +721,14 @@ const Transaction = ({ id }) => { - -
+ ) : ( +
Semua produk telah di reject
+ )} + {isModalOpen && (
Subtotal
@@ -738,33 +785,84 @@ const Transaction = ({ id }) => {
+ ))} -
Invoice
-
- {transaction.data?.invoices?.map((invoice, index) => ( - -
-
-

{invoice?.name}

-
- {invoice.amountResidual > 0 ? ( -
Belum Lunas
- ) : ( -
Lunas
- )} -

- {currencyFormat(invoice.amountTotal)} -

-
-
- -
- - ))} -
- {transaction.data?.invoices?.length === 0 && ( -
Belum ada invoice
+ + + {transaction?.data?.productsRejectLine.length > 0 && ( +
+ Rincian Produk Reject +
+ )} + {transaction?.data?.productsRejectLine.length > 0 && ( + + + + + {/* */} + + + + + + + {transaction?.data?.productsRejectLine?.map((product) => ( + + + {/* */} + + + + + ))} + +
Nama ProdukDiskonJumlahHargaSubtotal
+ + {product?.name} + +
+ + {product?.parent?.name} + +
+ {product?.code}{' '} + {product?.attributes.length > 0 + ? `| ${product?.attributes.join(', ')}` + : ''} +
+
+
+ {product.price.discountPercentage > 0 + ? `${product.price.discountPercentage}%` + : ''} + {product.quantity} + {/* {product.price.discountPercentage > 0 && ( +
+ {currencyFormat(product.price.price)} +
+ )} */} +
{currencyFormat(product.price.priceDiscount)}
+
{currencyFormat(product.quantity * product.price.priceDiscount)}
)} +
diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index c629c987..5d95ee70 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -122,7 +122,7 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { - {buyMore && ( + {buyMore && (!transaction?.data?.productsRejectLine.some(pr => pr.id === product.id)) && (
{/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */} {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/")) && ( - - - - )} - {/* {transaction.data.isReaject && ( - - - - )} */} + !transaction?.data?.productsRejectLine.some(pr => pr.id === product.id) && ( + + ) + )} {isModalOpen && (
{ const router = useRouter() -- cgit v1.2.3 From 91fae67a9fdece78f0d0fbf4230472577b6260c6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 11 Jul 2024 14:58:55 +0700 Subject: add key && update reject button by status quotation && add image reject --- src/lib/transaction/components/Transaction.jsx | 149 +++++++++++++------------ 1 file changed, 79 insertions(+), 70 deletions(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 8e7cede0..b099ffa7 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -1,4 +1,6 @@ import Spinner from '@/core/components/elements/Spinner/Spinner'; +import NextImage from 'next/image'; +import rejectImage from "../../../../public/images/reject.png" import useTransaction from '../hooks/useTransaction'; import TransactionStatusBadge from './TransactionStatusBadge'; import Divider from '@/core/components/elements/Divider/Divider'; @@ -646,85 +648,85 @@ const Transaction = ({ id }) => {
Rincian Pembelian
- {transaction?.data?.products?.length > 0? ( - - - - - {/* */} - - - - - - - - {transaction?.data?.products?.map((product) => ( - - + {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */} + {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/")) && transaction.data?.status == 'draft' && ( + + )} + + ))} + +
Nama ProdukDiskonJumlahHargaSubtotal
- - {product?.name} - -
+ {transaction?.data?.products?.length > 0? ( + + + + + {/* */} + + + + + + + + {transaction?.data?.products?.map((product) => ( + + - {/* */} - - - - {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */} - {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/")) && ( + + {/* */} + - )} - - ))} - -
Nama ProdukDiskonJumlahHargaSubtotal
- {product?.parent?.name} + {product?.name} -
- {product?.code}{' '} - {product?.attributes.length > 0 - ? `| ${product?.attributes.join(', ')}` - : ''} -
- -
- {product.price.discountPercentage > 0 - ? `${product.price.discountPercentage}%` - : ''} - {product.quantity} - {/* {product.price.discountPercentage > 0 && ( -
- {currencyFormat(product.price.price)} +
+ + {product?.parent?.name} + +
+ {product?.code}{' '} + {product?.attributes.length > 0 + ? `| ${product?.attributes.join(', ')}` + : ''} +
- )} */} -
{currencyFormat(product.price.priceDiscount)}
-
{currencyFormat(product.price.subtotal)} + {product.price.discountPercentage > 0 + ? `${product.price.discountPercentage}%` + : ''} + {product.quantity} - + {/* {product.price.discountPercentage > 0 && ( +
+ {currencyFormat(product.price.price)} +
+ )} */} +
{currencyFormat(product.price.priceDiscount)}
+
{currencyFormat(product.price.subtotal)} + +
) : (
Semua produk telah di reject
)} @@ -856,13 +858,20 @@ const Transaction = ({ id }) => { )} */}
{currencyFormat(product.price.priceDiscount)}
- {currencyFormat(product.quantity * product.price.priceDiscount)} + + + ))} )} - +
-- cgit v1.2.3 From 44895db5a27a87e6f6f91d4d3fda33ff444f82f0 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 11 Jul 2024 15:21:10 +0700 Subject: marge conflik --- src/lib/checkout/components/Checkout.jsx | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 4355c7bd..3c2b8a09 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -1391,13 +1391,10 @@ const Checkout = () => {
Grand Total
-<<<<<<< HEAD {currencyFormat(grandTotal)} -======= {currencyFormat( cartCheckout?.grandTotal + finalShippingAmt )} ->>>>>>> dev/voucher-shipment
)} -- cgit v1.2.3 From 1b9aeada3b663128f7c221342143cdb687b6e71f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 11 Jul 2024 15:26:16 +0700 Subject: add key on map --- src/lib/transaction/components/Transaction.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index b099ffa7..97b8a507 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -762,7 +762,7 @@ const Transaction = ({ id }) => { )} {transaction?.data?.products?.map((product) => ( -
+
Subtotal
-- cgit v1.2.3 From 721067120c2756554829070b3fa10de7f04ae705 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 12 Jul 2024 11:34:23 +0700 Subject: update input note --- src/lib/quotation/components/Quotation.jsx | 35 ++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index 8855c6c4..19419f61 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -67,17 +67,19 @@ const Quotation = () => { const [selectedExpedisiService, setselectedExpedisiService] = useState(null); const [etd, setEtd] = useState(null); const [etdFix, setEtdFix] = useState(null); - + const [isApproval, setIsApproval] = useState(false); - + const expedisiValidation = useRef(null); - + const [selectedAddress, setSelectedAddress] = useState({ shipping: null, invoicing: null, }); - + const [addresses, setAddresses] = useState(null); + + const [note_websiteText, setselectedNote_websiteText] = useState(null); useEffect(() => { if (!auth) return; @@ -262,6 +264,12 @@ const Quotation = () => { } if (!products || products.length == 0) return; + + if (auth?.feature?.soApproval && !note_websiteText.trim()) { + toast.error('Note harus diisi karena fitur soApproval aktif.'); + return; + } + setIsLoading(true); const productOrder = products.map((product) => ({ product_id: product.id, @@ -276,6 +284,7 @@ const Quotation = () => { carrier_id: selectedCarrierId, estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, + note_website : note_websiteText, }; console.log('data checkout', data); const isSuccess = await checkoutApi({ data }); @@ -291,6 +300,8 @@ const Quotation = () => { const taxTotal = (totalAmount - totalDiscountAmount) * 0.11; + console.log("note_websiteText",note_websiteText) + return ( <> @@ -576,6 +587,22 @@ const Quotation = () => { yang berlaku

+
+
+ +
+
Note
+
+