From 3f070a917666b5838fb433fa5d5e93d9753eb6fb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 1 Aug 2025 09:11:12 +0700 Subject: export xls&csv --- src/lib/home/api/mediaBrandApi.js | 8 +++ src/lib/home/components/MediaBrand.jsx | 90 +++++++++++++++++++++++++ src/lib/transaction/components/Transactions.jsx | 16 ++++- 3 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 src/lib/home/api/mediaBrandApi.js create mode 100644 src/lib/home/components/MediaBrand.jsx (limited to 'src') diff --git a/src/lib/home/api/mediaBrandApi.js b/src/lib/home/api/mediaBrandApi.js new file mode 100644 index 00000000..0e3200e0 --- /dev/null +++ b/src/lib/home/api/mediaBrandApi.js @@ -0,0 +1,8 @@ +import odooApi from '@/core/api/odooApi' + +const preferredBrandApi = async () => { + const dataPreferredBrands = await odooApi('GET', '/api/v1/manufacture?level=prioritas') + return dataPreferredBrands +} + +export default preferredBrandApi diff --git a/src/lib/home/components/MediaBrand.jsx b/src/lib/home/components/MediaBrand.jsx new file mode 100644 index 00000000..b7a30503 --- /dev/null +++ b/src/lib/home/components/MediaBrand.jsx @@ -0,0 +1,90 @@ +import { Swiper, SwiperSlide } from 'swiper/react'; +import { Navigation, Pagination, Autoplay } from 'swiper'; +import { useCallback, useEffect, useState } from 'react'; +import usePreferredBrand from '../hooks/usePreferredBrand'; +import PreferredBrandSkeleton from './Skeleton/PreferredBrandSkeleton'; +import BrandCard from '@/lib/brand/components/BrandCard'; +import useDevice from '@/core/hooks/useDevice'; +import Link from '@/core/components/elements/Link/Link'; +import axios from 'axios'; + +const PreferredBrand = () => { + let query = ''; + let params = 'prioritas'; + const [isLoading, setIsLoading] = useState(true); + const [startWith, setStartWith] = useState(null); + const [manufactures, setManufactures] = useState([]); + + const loadBrand = useCallback(async () => { + setIsLoading(true); + const name = startWith ? `${startWith}*` : ''; + const result = await axios( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/preferredBrand?rows=20` + ); + setIsLoading(false); + setManufactures((manufactures) => [...result.data]); + }, [startWith]); + + const toggleStartWith = (alphabet) => { + setManufactures([]); + if (alphabet == startWith) { + setStartWith(null); + return; + } + setStartWith(alphabet); + }; + + useEffect(() => { + loadBrand(); + }, []); + + // const { preferredBrands } = usePreferredBrand(query) + const { isMobile, isDesktop } = useDevice(); + const swiperBanner = { + modules: [Navigation, Pagination, Autoplay], + autoplay: { + delay: 4000, + disableOnInteraction: false, + }, + loop: true, + className: 'h-[70px] md:h-[100px] w-full', + slidesPerView: isMobile ? 4 : 8, + spaceBetween: isMobile ? 12 : 0, + pagination: { + dynamicBullets: true, + dynamicMainBullets: isMobile ? 6 : 8, + clickable: true, + }, + }; + const preferredBrandsData = manufactures ? manufactures.slice(0, 20) : []; + return ( +
+
+

+ + Brand Pilihan + +

+ {isDesktop && ( + + Lihat Semua + + )} +
+
+ {manufactures.isLoading && } + {!manufactures.isLoading && ( + + {preferredBrandsData.map((manufacture) => ( + + + + ))} + + )} +
+
+ ); +}; + +export default PreferredBrand; diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index acb925da..c1515bc5 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -127,6 +127,16 @@ const Transactions = ({ context = '' }) => { { id: 'cancel', label: 'Pesanan Dibatalkan' }, ]; + const contextLabelMap = { + draft: 'Pending Quotation', + waiting: 'Pesanan Diproses', + sale: 'Pesanan Dikemas', + partial_shipping: 'Dikirim Sebagian', + shipping: 'Pesanan Dikirim', + done: 'Pesanan Selesai', + cancel: 'Pesanan Dibatalkan', + }; + const sortes = [ { id: 'none', label: 'Urutkan' }, { id: 'asc', label: 'dari yang terkecil' }, @@ -199,7 +209,7 @@ const Transactions = ({ context = '' }) => { 'Created By': saleOrder.address.customer?.name || '-', Salesperson: saleOrder.sales, Total: currencyFormat(saleOrder.amountTotal), - Status: saleOrder.status, + Status: contextLabelMap[saleOrder.status] || saleOrder.status, }; if (siteFilter) { row['Site'] = siteFilter; @@ -245,7 +255,7 @@ const Transactions = ({ context = '' }) => { saleOrder.address.customer?.name || '-', saleOrder.sales, currencyFormat(saleOrder.amountTotal), - saleOrder.status, + contextLabelMap[saleOrder.status] || saleOrder.status, ]; if (siteFilter) { @@ -273,7 +283,7 @@ const Transactions = ({ context = '' }) => { name: q, offset: (pageNew - 1) * limitNew, limit: limitNew, - context: contextMap[statusNew], // gunakan contextMap + context: contextNew[statusNew] || 'all', sort: sortNew, startDate: state[0]?.startDate ? state[0].startDate.toLocaleDateString('id-ID') -- cgit v1.2.3