From d1c0e083ac8f64dfaa8505fc11e30728dbd5a58d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 19 Aug 2024 09:36:24 +0700 Subject: update voucher pasti hemat avoid failed --- src/lib/product/components/ProductCard.jsx | 2 +- src/utils/solrMapping.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 35e2a665..b5bb147c 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -16,7 +16,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const utmSource = useUtmSource(); const [discount, setDiscount] = useState(0); - let voucherPastiHemat = 0; + let voucherPastiHemat = product?.voucherPastiHemat ? 0 : product.newVoucherPastiHemat; if (product?.voucherPastiHemat ? product?.voucherPastiHemat.length : voucherPastiHemat > 0) { const stringVoucher = product?.voucherPastiHemat[0]; diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js index d4694eb2..ff851f6c 100644 --- a/src/utils/solrMapping.js +++ b/src/utils/solrMapping.js @@ -38,6 +38,7 @@ export const productMappingSolr = (products, pricelist) => { qtySold: product?.qty_sold_f || 0, isTkdn:product?.tkdn_b || false, isSni:product?.sni_b || false, + newVoucherPastiHemat: [], voucherPastiHemat:product?.voucher_pastihemat || [] }; @@ -56,6 +57,14 @@ export const productMappingSolr = (products, pricelist) => { name: product.category_name_s || '', }, ]; + productMapped.newVoucherPastiHemat = [ + { + min_purchase: product.min_purchase_f || 0, + discount_type: product.discount_type_s || '', + discount_amount: product.discount_amount_f || 0, + max_discount: product.max_discount_f || 0, + }, + ]; return productMapped; }); }; -- cgit v1.2.3 From 45162d053721911e74bdeac09d2d1f1eaff44f1b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 23 Sep 2024 16:44:13 +0700 Subject: update code, false code --- src/lib/home/api/categoryManagementApi.js | 78 +++++----- src/lib/home/components/CategoryDynamic.jsx | 135 +++++++++++------ src/lib/home/components/CategoryDynamicMobile.jsx | 174 +++++++++++++--------- 3 files changed, 234 insertions(+), 153 deletions(-) (limited to 'src') diff --git a/src/lib/home/api/categoryManagementApi.js b/src/lib/home/api/categoryManagementApi.js index 0aeb2aac..2ff4fdfc 100644 --- a/src/lib/home/api/categoryManagementApi.js +++ b/src/lib/home/api/categoryManagementApi.js @@ -1,40 +1,44 @@ export const fetchCategoryManagementSolr = async () => { - let sort ='sort=sequence_i asc'; - try { - const response = await fetch(`/solr/category_management/query?q=*:*&q.op=OR&indent=true&${sort}&&rows=20`); - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - const data = await response.json(); - const promotions = await map(data.response.docs); - return promotions; - } catch (error) { - console.error("Error fetching promotion data:", error); - return []; + let sort = 'sort=sequence_i asc'; + try { + const response = await fetch( + `/solr/category_management/query?q=*:*&q.op=OR&indent=true&${sort}&&rows=20` + ); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + const promotions = await map(data.response.docs); + return promotions; + } catch (error) { + console.error('Error fetching promotion data:', error); + return []; + } +}; + +const map = async (promotions) => { + return promotions.map((promotion) => { + let parsedCategories = promotion.categories.map((category) => { + // Parse string JSON utama + let parsedCategory = JSON.parse(category); + + // Parse setiap elemen di child_frontend_id_i jika ada + if (parsedCategory.child_frontend_id_i) { + parsedCategory.child_frontend_id_i = + parsedCategory.child_frontend_id_i.map((child) => JSON.parse(child)); } + + return parsedCategory; + }); + let productMapped = { + id: promotion.id, + name: promotion.name_s, + image: promotion.image_s, + sequence: promotion.sequence_i, + numFound: promotion.numFound_i, + categories: parsedCategories, + category_id: promotion.category_id_i, }; - - const map = async (promotions) => { - return promotions.map((promotion) =>{ - let parsedCategories = promotion.categories.map(category => { - // Parse string JSON utama - let parsedCategory = JSON.parse(category); - - // Parse setiap elemen di child_frontend_id_i jika ada - if (parsedCategory.child_frontend_id_i) { - parsedCategory.child_frontend_id_i = parsedCategory.child_frontend_id_i.map(child => JSON.parse(child)); - } - - return parsedCategory; - }); - let productMapped = { - id: promotion.id, - name: promotion.name_s, - image: promotion.image_s, - sequence: promotion.sequence_i, - numFound: promotion.numFound_i, - categories: parsedCategories - }; - return productMapped; - }) - }; \ No newline at end of file + return productMapped; + }); +}; diff --git a/src/lib/home/components/CategoryDynamic.jsx b/src/lib/home/components/CategoryDynamic.jsx index ca104ada..da2faf3d 100644 --- a/src/lib/home/components/CategoryDynamic.jsx +++ b/src/lib/home/components/CategoryDynamic.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState, useCallback } from 'react'; -import {fetchCategoryManagementSolr} from '../api/categoryManagementApi' +import { fetchCategoryManagementSolr } from '../api/categoryManagementApi'; import NextImage from 'next/image'; -import Link from "next/link"; +import Link from 'next/link'; import { createSlug } from '@/core/utils/slug'; import odooApi from '@/core/api/odooApi'; import { Skeleton } from '@chakra-ui/react'; @@ -12,35 +12,34 @@ import 'swiper/css/pagination'; import { Navigation, Pagination, Autoplay } from 'swiper'; const CategoryDynamic = () => { - - const [categoryManagement, setCategoryManagement] = useState([]) - const [isLoading, setIsLoading] = useState(false) + const [categoryManagement, setCategoryManagement] = useState([]); + const [isLoading, setIsLoading] = useState(false); const loadBrand = useCallback(async () => { - setIsLoading(true) + setIsLoading(true); const items = await fetchCategoryManagementSolr(); - - setIsLoading(false) - setCategoryManagement(items) - }, []) + + setIsLoading(false); + setCategoryManagement(items); + }, []); useEffect(() => { - loadBrand() - }, [loadBrand]) - + loadBrand(); + }, [loadBrand]); + // const [categoryData, setCategoryData] = useState({}); // const [subCategoryData, setSubCategoryData] = useState({}); - + // useEffect(() => { // const fetchCategoryData = async () => { // if (categoryManagement && categoryManagement.data) { // const updatedCategoryData = {}; // const updatedSubCategoryData = {}; - + // for (const category of categoryManagement.data) { // const countLevel1 = await odooApi('GET', `/api/v1/category/numFound?parent_id=${category.categoryIdI}`); - + // updatedCategoryData[category.categoryIdI] = countLevel1?.numFound; - + // for (const subCategory of countLevel1?.children) { // updatedSubCategoryData[subCategory.id] = subCategory?.numFound; // } @@ -55,34 +54,46 @@ const CategoryDynamic = () => { // }, [categoryManagement.isLoading]); const swiperBanner = { - modules: [Pagination, ], - classNames:'mySwiper', + modules: [Pagination], + classNames: 'mySwiper', slidesPerView: 3, - spaceBetween:10, + spaceBetween: 10, pagination: { dynamicBullets: true, clickable: true, - } + }, }; - + return (
- {categoryManagement && categoryManagement?.map((category) => { + {categoryManagement && + categoryManagement?.map((category) => { + console.log('category', category); // const countLevel1 = categoryData[category.categoryIdI] || 0; return (
-
{category.name}
+
+ {category.name} +
{/*

{countLevel1} Produk tersedia

*/} - Lihat Semua + + Lihat Semua +
- + {/* Swiper for SubCategories */} - + {category.categories.map((subCategory) => { // const countLevel2 = subCategoryData[subCategory.idLevel2] || 0; @@ -92,39 +103,69 @@ const CategoryDynamic = () => {
-
{subCategory?.name}
+
+ {subCategory?.name} +
{/*

{countLevel2} Produk tersedia

*/} - Lihat Semua + + Lihat Semua +
- {subCategory.child_frontend_id_i.map((childCategory) => ( -
- - -
-
{childCategory.name}
-
- -
- ))} + {subCategory.child_frontend_id_i.map( + (childCategory) => ( +
+ + +
+
+ {childCategory.name} +
+
+ +
+ ) + )}
diff --git a/src/lib/home/components/CategoryDynamicMobile.jsx b/src/lib/home/components/CategoryDynamicMobile.jsx index 1061f3e4..af151df2 100644 --- a/src/lib/home/components/CategoryDynamicMobile.jsx +++ b/src/lib/home/components/CategoryDynamicMobile.jsx @@ -1,38 +1,41 @@ import React, { useEffect, useState, useCallback } from 'react'; import NextImage from 'next/image'; -import Link from "next/link"; +import Link from 'next/link'; import { createSlug } from '@/core/utils/slug'; import { Swiper, SwiperSlide } from 'swiper/react'; import 'swiper/css'; -import {fetchCategoryManagementSolr} from '../api/categoryManagementApi' +import { fetchCategoryManagementSolr } from '../api/categoryManagementApi'; const CategoryDynamicMobile = () => { const [selectedCategory, setSelectedCategory] = useState({}); - const [categoryManagement, setCategoryManagement] = useState([]) - const [isLoading, setIsLoading] = useState(false) + const [categoryManagement, setCategoryManagement] = useState([]); + const [isLoading, setIsLoading] = useState(false); const loadBrand = useCallback(async () => { - setIsLoading(true) + setIsLoading(true); const items = await fetchCategoryManagementSolr(); - - setIsLoading(false) - setCategoryManagement(items) - }, []) + + setIsLoading(false); + setCategoryManagement(items); + }, []); useEffect(() => { - loadBrand() - }, [loadBrand]) + loadBrand(); + }, [loadBrand]); useEffect(() => { const loadPromo = async () => { try { if (categoryManagement?.length > 0) { - const initialSelections = categoryManagement.reduce((acc, category) => { - if (category.categories.length > 0) { - acc[category.id] = category.categories[0].id_level_2; - } - return acc; - }, {}); + const initialSelections = categoryManagement.reduce( + (acc, category) => { + if (category.categories.length > 0) { + acc[category.id] = category.categories[0].id_level_2; + } + return acc; + }, + {} + ); setSelectedCategory(initialSelections); } } catch (loadError) { @@ -44,69 +47,102 @@ const CategoryDynamicMobile = () => { }, [categoryManagement]); const handleCategoryLevel2Click = (categoryIdI, idLevel2) => { - setSelectedCategory(prev => ({ + setSelectedCategory((prev) => ({ ...prev, - [categoryIdI]: idLevel2 + [categoryIdI]: idLevel2, })); }; - + return (
- {categoryManagement && categoryManagement?.map((category) => ( -
-
-
{category?.name}
- Lihat Semua -
- - {category.categories.map((index) => ( - -
handleCategoryLevel2Click(category.id, index?.id_level_2)} - className={`border flex justify-start items-center max-w-48 max-h-16 rounded ${selectedCategory[category.id] === index?.id_level_2 ? 'bg-red-50 border-red-500 text-red-500' : 'border-gray-200 text-gray-900'}`} - > -
-
- -
-
{index?.name}
-
-
-
-
-
- ))} -
-
-
+ {categoryManagement && + categoryManagement?.map((category) => ( +
+
+
+ {category?.name} +
+ + Lihat Semua + +
+ {category.categories.map((index) => ( - selectedCategory[category.id] === index?.id_level_2 && index?.child_frontend_id_i.map((x) => ( -
- - -
-
{x?.name}
+ +
+ handleCategoryLevel2Click(category.id, index?.id_level_2) + } + className={`border flex justify-start items-center max-w-48 max-h-16 rounded ${ + selectedCategory[category.id] === index?.id_level_2 + ? 'bg-red-50 border-red-500 text-red-500' + : 'border-gray-200 text-gray-900' + }`} + > +
+
+ +
+
+ {index?.name} +
+
- +
- )) +
))} + +
+
+ {category.categories.map( + (index) => + selectedCategory[category.id] === index?.id_level_2 && + index?.child_frontend_id_i.map((x) => ( +
+ + +
+
+ {x?.name} +
+
+ +
+ )) + )} +
-
- ))} + ))}
); }; -- cgit v1.2.3 From 7d89c0280f1801db49b373a4691215833e6e7f92 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 23 Sep 2024 16:52:50 +0700 Subject: delete console log --- src/lib/home/components/CategoryDynamic.jsx | 1 - src/lib/product/components/ProductSearch.jsx | 121 +++++++++++++-------------- 2 files changed, 59 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/lib/home/components/CategoryDynamic.jsx b/src/lib/home/components/CategoryDynamic.jsx index da2faf3d..79092c9d 100644 --- a/src/lib/home/components/CategoryDynamic.jsx +++ b/src/lib/home/components/CategoryDynamic.jsx @@ -68,7 +68,6 @@ const CategoryDynamic = () => {
{categoryManagement && categoryManagement?.map((category) => { - console.log('category', category); // const countLevel1 = categoryData[category.categoryIdI] || 0; return ( diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 1edc31c9..26114acf 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -28,7 +28,7 @@ import SideBanner from '~/modules/side-banner'; import FooterBanner from '~/modules/footer-banner'; import CategorySection from './CategorySection'; import LobSectionCategory from './LobSectionCategory'; -import { getIdFromSlug } from '@/core/utils/slug' +import { getIdFromSlug } from '@/core/utils/slug'; import { data } from 'autoprefixer'; const ProductSearch = ({ @@ -45,35 +45,40 @@ const ProductSearch = ({ const [orderBy, setOrderBy] = useState(router.query?.orderBy); const [finalQuery, setFinalQuery] = useState({}); const [queryFinal, setQueryFinal] = useState({}); - const [dataCategoriesProduct, setDataCategoriesProduct] = useState([]) - const [dataCategoriesLob, setDataCategoriesLob] = useState([]) - const categoryId = getIdFromSlug(prefixUrl) - const [data, setData] = useState([]) + const [dataCategoriesProduct, setDataCategoriesProduct] = useState([]); + const [dataCategoriesLob, setDataCategoriesLob] = useState([]); + const categoryId = getIdFromSlug(prefixUrl); + const [data, setData] = useState([]); const [dataLob, setDataLob] = useState([]); if (defaultBrand) query.brand = defaultBrand.toLowerCase(); - const dataIdCategories = [] + const dataIdCategories = []; useEffect(() => { - if(prefixUrl.includes('category')){ + if (prefixUrl.includes('category')) { const loadProduct = async () => { - const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${categoryId}`); + const getCategoriesId = await odooApi( + 'GET', + `/api/v1/category/numFound?parent_id=${categoryId}` + ); if (getCategoriesId) { setDataCategoriesProduct(getCategoriesId); } }; loadProduct(); - }else if(prefixUrl.includes('lob')){ + } else if (prefixUrl.includes('lob')) { const loadProduct = async () => { - const lobData = await odooApi('GET', `/api/v1/lob_homepage/${categoryId}/category_id`); - + const lobData = await odooApi( + 'GET', + `/api/v1/lob_homepage/${categoryId}/category_id` + ); + if (lobData) { setDataLob(lobData); } }; loadProduct(); - } }, [categoryId]); - + const collectIds = (category) => { const ids = []; function recurse(cat) { @@ -88,45 +93,40 @@ const ProductSearch = ({ return ids; }; useEffect(() => { - if(prefixUrl.includes('category')){ + if (prefixUrl.includes('category')) { const ids = collectIds(dataCategoriesProduct); const newQuery = { fq: `category_id_ids:(${ids.join(' OR ')})`, - page : router.query.page? router.query.page : 1, - brand : router.query.brand? router.query.brand : '', - category : router.query.category? router.query.category : '', - priceFrom : router.query.priceFrom? router.query.priceFrom : '', - priceTo : router.query.priceTo? router.query.priceTo : '', - limit : router.query.limit? router.query.limit : '', - orderBy : router.query.orderBy? router.query.orderBy : '' + page: router.query.page ? router.query.page : 1, + brand: router.query.brand ? router.query.brand : '', + category: router.query.category ? router.query.category : '', + priceFrom: router.query.priceFrom ? router.query.priceFrom : '', + priceTo: router.query.priceTo ? router.query.priceTo : '', + limit: router.query.limit ? router.query.limit : '', + orderBy: router.query.orderBy ? router.query.orderBy : '', }; setFinalQuery(newQuery); - } else if (prefixUrl.includes('lob')){ - + } else if (prefixUrl.includes('lob')) { const fetchCategoryData = async () => { if (dataLob[0]?.categoryIds) { - for (const cate of dataLob[0].categoryIds) { - - dataIdCategories.push(cate.childId) + dataIdCategories.push(cate.childId); } - - + const mergedArray = dataIdCategories.flat(); - + const newQuery = { fq: `category_id_ids:(${mergedArray.join(' OR ')})`, - category : router.query.category? router.query.category : '', - page : router.query.page? router.query.page : 1, - brand : router.query.brand? router.query.brand : '', - priceFrom : router.query.priceFrom? router.query.priceFrom : '', - priceTo : router.query.priceTo? router.query.priceTo : '', - limit : router.query.limit? router.query.limit : '', - orderBy : router.query.orderBy? router.query.orderBy : '' + category: router.query.category ? router.query.category : '', + page: router.query.page ? router.query.page : 1, + brand: router.query.brand ? router.query.brand : '', + priceFrom: router.query.priceFrom ? router.query.priceFrom : '', + priceTo: router.query.priceTo ? router.query.priceTo : '', + limit: router.query.limit ? router.query.limit : '', + orderBy: router.query.orderBy ? router.query.orderBy : '', }; - + setFinalQuery(newQuery); - } }; fetchCategoryData(); @@ -139,7 +139,7 @@ const ProductSearch = ({ } else { setQueryFinal({ ...query, q, limit, orderBy }); } - }, [prefixUrl,dataCategoriesProduct, query, finalQuery]); + }, [prefixUrl, dataCategoriesProduct, query, finalQuery]); const { productSearch } = useProductSearch({ query: queryFinal, @@ -162,7 +162,7 @@ const ProductSearch = ({ const [categoryValues, setCategory] = useState( router.query?.category?.split(',') || router.query?.category?.split(',') ); - + const [priceFrom, setPriceFrom] = useState(router.query?.priceFrom || null); const [priceTo, setPriceTo] = useState(router.query?.priceTo || null); @@ -170,8 +170,8 @@ const ProductSearch = ({ const productStart = productSearch.data?.responseHeader.params.start; const productRows = limit; const productFound = productSearch.data?.response.numFound; - const [dataCategories, setDataCategories] = useState([]) - + const [dataCategories, setDataCategories] = useState([]); + useEffect(() => { if (productFound == 0 && query.q && !spellings) { searchSpellApi({ query: query.q }).then((response) => { @@ -201,7 +201,7 @@ const ProductSearch = ({ }); } }, [productFound, query, spellings]); - let id = [] + let id = []; useEffect(() => { const checkIfBrand = async () => { const brand = await axios( @@ -218,21 +218,21 @@ const ProductSearch = ({ checkIfBrand(); } }, [q]); - + useEffect(() => { - if(prefixUrl.includes('category')){ + if (prefixUrl.includes('category')) { const loadCategories = async () => { - const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`) - if(getCategories){ - setDataCategories(getCategories) - } - } - loadCategories() + const getCategories = await odooApi( + 'GET', + `/api/v1/category/child?parent_id=${categoryId}` + ); + if (getCategories) { + setDataCategories(getCategories); + } + }; + loadCategories(); } - }, []) - - - + }, []); const brands = []; for ( @@ -248,7 +248,6 @@ const ProductSearch = ({ brands.push({ brand, qty }); } } - const categories = []; for ( @@ -263,7 +262,6 @@ const ProductSearch = ({ categories.push({ name, qty }); } } - const orderOptions = [ { value: '', label: 'Pilih Filter' }, @@ -382,7 +380,6 @@ const ProductSearch = ({ const isNotReadyStockPage = router.asPath !== '/shop/search?orderBy=stock'; - console.log('is spelling', spellings); return ( <> @@ -443,8 +440,8 @@ const ProductSearch = ({ SpellingComponent )}
- - + + {productFound > 0 && (
@@ -536,8 +533,8 @@ const ProductSearch = ({
- - + + {bannerPromotionHeader && bannerPromotionHeader?.image && (
Date: Tue, 24 Sep 2024 09:40:23 +0700 Subject: update bug cart count mobile --- src/core/components/elements/Appbar/Appbar.jsx | 65 ++++++++++++++++---------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/core/components/elements/Appbar/Appbar.jsx b/src/core/components/elements/Appbar/Appbar.jsx index 16bccbd5..e9abe657 100644 --- a/src/core/components/elements/Appbar/Appbar.jsx +++ b/src/core/components/elements/Appbar/Appbar.jsx @@ -1,8 +1,16 @@ -import { useRouter } from 'next/router' -import Link from '../Link/Link' -import { HomeIcon, Bars3Icon, ShoppingCartIcon, ChevronLeftIcon } from '@heroicons/react/24/outline' -import { useEffect, useState } from 'react' -import { getCart, getCountCart } from '@/core/utils/cart' +import { useRouter } from 'next/router'; +import Link from '../Link/Link'; +import { + HomeIcon, + Bars3Icon, + ShoppingCartIcon, + ChevronLeftIcon, +} from '@heroicons/react/24/outline'; +import { useEffect, useState } from 'react'; +import { getCart, getCountCart } from '@/core/utils/cart'; +import useTransactions from '@/lib/transaction/hooks/useTransactions'; +import { useCartStore } from '~/modules/cart/stores/useCartStore'; +import useAuth from '@/core/hooks/useAuth'; /** * The AppBar component is a navigation component used to display a header or toolbar @@ -13,26 +21,31 @@ import { getCart, getCountCart } from '@/core/utils/cart' * @returns {JSX.Element} - Rendered AppBar component. */ const AppBar = ({ title }) => { - const router = useRouter() - - const [cartCount, setCartCount] = useState(0) - + const router = useRouter(); + const auth = useAuth(); + const { cart } = useCartStore(); + const query = { + context: 'quotation', + site: auth?.webRole === null && auth?.site ? auth.site : null, + }; + const [cartCount, setCartCount] = useState(0); + const { transactions } = useTransactions({ query }); useEffect(() => { const handleCartChange = () => { const cart = async () => { - const listCart = await getCountCart() - setCartCount(listCart) - } - cart() - } - handleCartChange() + const listCart = await getCountCart(); + setCartCount(listCart); + }; + cart(); + }; + handleCartChange(); - window.addEventListener('localStorageChange', handleCartChange) + window.addEventListener('localStorageChange', handleCartChange); return () => { - window.removeEventListener('localStorageChange', handleCartChange) - } - }, []) + window.removeEventListener('localStorageChange', handleCartChange); + }; + }, [transactions.data, cart]); return (
- ) -} + ); +}; -export default AppBar +export default AppBar; -- cgit v1.2.3 From 36601aba6017aeef16f89351eb487238402ab52e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 24 Sep 2024 16:12:50 +0700 Subject: update Perapihan Tag --- .../components/elements/Footer/BasicFooter.jsx | 8 +- .../components/elements/Navbar/NavbarDesktop.jsx | 95 +++---- src/lib/home/components/BannerSection.jsx | 20 +- src/lib/home/components/CategoryDynamic.jsx | 15 +- src/lib/home/components/CategoryDynamicMobile.jsx | 14 +- src/lib/home/components/CategoryHomeId.jsx | 18 +- src/lib/home/components/CategoryPilihan.jsx | 265 +++++++++++--------- src/lib/home/components/PromotionProgram.jsx | 118 ++++----- src/lib/home/components/ServiceList.jsx | 34 ++- src/lib/quotation/components/Quotationheader.jsx | 131 +++++++--- src/lib/review/components/CustomerReviews.jsx | 37 +-- src/lib/tracking-order/component/TrackingOrder.jsx | 272 +++++++++++---------- src/pages/my/profile.jsx | 69 +++--- 13 files changed, 630 insertions(+), 466 deletions(-) (limited to 'src') diff --git a/src/core/components/elements/Footer/BasicFooter.jsx b/src/core/components/elements/Footer/BasicFooter.jsx index 8f024d86..4688b15b 100644 --- a/src/core/components/elements/Footer/BasicFooter.jsx +++ b/src/core/components/elements/Footer/BasicFooter.jsx @@ -175,7 +175,7 @@ const CustomerGuide = () => (
Bantuan & Panduan
    -
  • +
  • Metode Pembayaran @@ -395,7 +395,7 @@ const Payments = () => ( alt='Metode Pembayaran - Indoteknik' width={512} height={512} - quality={100} + quality={85} className='w-full' />
@@ -409,7 +409,7 @@ const Shippings = () => ( alt='Jasa Pengiriman - Indoteknik' width={512} height={512} - quality={100} + quality={85} className='w-full' />
@@ -423,7 +423,7 @@ const Secures = () => ( alt='Keamanan Belanja - Indoteknik' width={512} height={512} - quality={100} + quality={85} className='w-full' />
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 2a51c41f..d480aa8d 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -5,7 +5,7 @@ import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; import IndoteknikLogo from '@/images/logo.png'; import Cardheader from '@/lib/cart/components/Cartheader'; -import Quotationheader from "../../../../../src/lib/quotation/components/Quotationheader.jsx" +import Quotationheader from '../../../../../src/lib/quotation/components/Quotationheader.jsx'; import Category from '@/lib/category/components/Category'; import { useProductCartContext } from '@/contexts/ProductCartContext'; import { @@ -30,7 +30,7 @@ import { MenuList, useDisclosure, } from '@chakra-ui/react'; -import style from "./style/NavbarDesktop.module.css"; +import style from './style/NavbarDesktop.module.css'; import useTransactions from '@/lib/transaction/hooks/useTransactions'; import { useCartStore } from '~/modules/cart/stores/useCartStore'; @@ -43,7 +43,7 @@ const NavbarDesktop = () => { const [cartCount, setCartCount] = useState(0); const [quotationCount, setQuotationCount] = useState(0); - const [pendingTransactions, setPendingTransactions] = useState([]) + const [pendingTransactions, setPendingTransactions] = useState([]); const [templateWA, setTemplateWA] = useState(null); const [payloadWA, setPayloadWa] = useState(null); const [urlPath, setUrlPath] = useState(null); @@ -52,14 +52,17 @@ const NavbarDesktop = () => { const { product } = useProductContext(); const { isOpen, onOpen, onClose } = useDisclosure(); - + const query = { context: 'quotation', - site: - (auth?.webRole === null && auth?.site ? auth.site : null), + site: auth?.webRole === null && auth?.site ? auth.site : null, }; - - const { transactions } = useTransactions({ query }); + let transactions = null; + + if (auth) { + transactions = useTransactions({ query }); + } + const data = transactions?.data?.saleOrders.filter( (transaction) => transaction.status === 'draft' ); @@ -106,9 +109,8 @@ const NavbarDesktop = () => { useEffect(() => { setPendingTransactions(data); - }, [transactions.data]); - - + }, [transactions?.data]); + useEffect(() => { if (router.pathname === '/shop/product/[slug]') { setPayloadWa({ @@ -117,11 +119,11 @@ const NavbarDesktop = () => { url: createSlug('/shop/product/', product?.name, product?.id, true), }); setTemplateWA('product'); - + setUrlPath(router.asPath); } }, [product, router]); - + useEffect(() => { const handleCartChange = () => { const cart = async () => { @@ -130,14 +132,14 @@ const NavbarDesktop = () => { }; cart(); }; - handleCartChange(); - + handleCartChange(); + window.addEventListener('localStorageChange', handleCartChange); - + return () => { window.removeEventListener('localStorageChange', handleCartChange); }; - }, [transactions.data, cart]); + }, [transactions?.data, cart]); useEffect(() => { const handleQuotationChange = () => { @@ -154,7 +156,7 @@ const NavbarDesktop = () => { window.removeEventListener('localStorageChange', handleQuotationChange); }; }, [pendingTransactions]); - + return ( @@ -174,7 +176,7 @@ const NavbarDesktop = () => { >
Fitur Layanan
- +
{
- + @@ -271,29 +276,30 @@ const NavbarDesktop = () => {
- - - {showPopup && ( -
+ {showPopup && ( +
penawaran terbatas + src='/images/penawaran-terbatas.jpg' + alt='penawaran terbatas' + width={1440} + height={160} + quality={85} + // className={`fixed ${isTop ? 'md:top-[145px] lg:top-[160px] ' : 'lg:top-[85px] top-[80px]'} rounded-3xl md:left-1/4 lg:left-1/4 xl:left-1/4 left-2/3 w-40 h-12 p-2 z-50 transition-all duration-300 animate-pulse`} + className={`inline-block relative -top-8 transition-all duration-300 z-20 animate-pulse`} + />
- )} - Semua Promo + )} + + Semua Promo + {/* {showPopup && router.pathname === '/' && (
@@ -302,17 +308,18 @@ const NavbarDesktop = () => {

)} */} - - Semua Brand + + Semua Brand + { target='_blank' rel='noreferrer' > - Ready Stock + + Ready Stock + { target='_blank' rel='noreferrer noopener' > - Blog Indoteknik + + Blog Indoteknik + {/* { - const fetchBannerSection = async () => await bannerSectionApi() - const bannerSection = useQuery('bannerSection', fetchBannerSection) + const fetchBannerSection = async () => await bannerSectionApi(); + const bannerSection = useQuery('bannerSection', fetchBannerSection); return ( bannerSection.data && @@ -17,7 +17,7 @@ const BannerSection = () => { {banner.name} { ))}
) - ) -} + ); +}; -export default BannerSection +export default BannerSection; diff --git a/src/lib/home/components/CategoryDynamic.jsx b/src/lib/home/components/CategoryDynamic.jsx index 79092c9d..49a9a93f 100644 --- a/src/lib/home/components/CategoryDynamic.jsx +++ b/src/lib/home/components/CategoryDynamic.jsx @@ -3,13 +3,12 @@ import { fetchCategoryManagementSolr } from '../api/categoryManagementApi'; import NextImage from 'next/image'; import Link from 'next/link'; import { createSlug } from '@/core/utils/slug'; -import odooApi from '@/core/api/odooApi'; import { Skeleton } from '@chakra-ui/react'; import { Swiper, SwiperSlide } from 'swiper/react'; import 'swiper/css'; import 'swiper/css/navigation'; import 'swiper/css/pagination'; -import { Navigation, Pagination, Autoplay } from 'swiper'; +import { Pagination } from 'swiper'; const CategoryDynamic = () => { const [categoryManagement, setCategoryManagement] = useState([]); @@ -73,9 +72,9 @@ const CategoryDynamic = () => {
-
+

{category.name} -

+ {/*

{countLevel1} Produk tersedia

*/} @@ -113,9 +112,9 @@ const CategoryDynamic = () => { className='object-fit p-4' />
-
+

{subCategory?.name} -

+ {/*

{countLevel2} Produk tersedia @@ -157,9 +156,9 @@ const CategoryDynamic = () => { height={40} />

-
+

{childCategory.name} -

+
diff --git a/src/lib/home/components/CategoryDynamicMobile.jsx b/src/lib/home/components/CategoryDynamicMobile.jsx index af151df2..4a8f13cf 100644 --- a/src/lib/home/components/CategoryDynamicMobile.jsx +++ b/src/lib/home/components/CategoryDynamicMobile.jsx @@ -59,9 +59,9 @@ const CategoryDynamicMobile = () => { categoryManagement?.map((category) => (
-
- {category?.name} -
+

+ {category.name} +

{ className='' />
-
+

{index?.name} -

+
@@ -131,9 +131,9 @@ const CategoryDynamicMobile = () => { className='p-2' />
-
+

{x?.name} -

+
diff --git a/src/lib/home/components/CategoryHomeId.jsx b/src/lib/home/components/CategoryHomeId.jsx index 71428e27..9f436dac 100644 --- a/src/lib/home/components/CategoryHomeId.jsx +++ b/src/lib/home/components/CategoryHomeId.jsx @@ -1,13 +1,15 @@ -import { LazyLoadComponent } from 'react-lazy-load-image-component' -import useCategoryHomeId from '../hooks/useCategoryHomeId' -import CategoryHome from './CategoryHome' +import { LazyLoadComponent } from 'react-lazy-load-image-component'; +import useCategoryHomeId from '../hooks/useCategoryHomeId'; +import CategoryHome from './CategoryHome'; const CategoryHomeId = () => { - const { categoryHomeIds } = useCategoryHomeId() + const { categoryHomeIds } = useCategoryHomeId(); return (
-
Kategori Pilihan
+

+ Kategori Pilihan +

{categoryHomeIds.data?.map((id) => ( @@ -16,7 +18,7 @@ const CategoryHomeId = () => { ))}
- ) -} + ); +}; -export default CategoryHomeId +export default CategoryHomeId; diff --git a/src/lib/home/components/CategoryPilihan.jsx b/src/lib/home/components/CategoryPilihan.jsx index 6dbf771e..2e5ca721 100644 --- a/src/lib/home/components/CategoryPilihan.jsx +++ b/src/lib/home/components/CategoryPilihan.jsx @@ -1,123 +1,168 @@ -import Image from 'next/image' -import useCategoryHome from '../hooks/useCategoryHome' -import Link from '@/core/components/elements/Link/Link' -import { createSlug } from '@/core/utils/slug' +import Image from 'next/image'; +import useCategoryHome from '../hooks/useCategoryHome'; +import Link from '@/core/components/elements/Link/Link'; +import { createSlug } from '@/core/utils/slug'; import { useEffect, useState } from 'react'; import { bannerApi } from '../../../api/bannerApi'; -const { useQuery } = require('react-query') +const { useQuery } = require('react-query'); import { HeroBannerSkeleton } from '../../../components/skeleton/BannerSkeleton'; import useCategoryPilihan from '../hooks/useCategoryPilihan'; -import useDevice from '@/core/hooks/useDevice' +import useDevice from '@/core/hooks/useDevice'; import { Swiper, SwiperSlide } from 'swiper/react'; import 'swiper/css'; const CategoryPilihan = ({ id, categories }) => { - const { isDesktop, isMobile } = useDevice() - const { categoryPilihan } = useCategoryPilihan(); - const heroBanner = useQuery('categoryPilihan', bannerApi({ type: 'banner-category-list' })); - return ( - categoryPilihan.length > 0 && ( -
- {isDesktop && ( -
-
-
LOB Kategori Pilihan
-

200 Rb+ Produk Unggulan & 800+ Brand Rekomendasi tersedia!

-
- {heroBanner.data && - heroBanner.data?.length > 0 && ( -
- - {heroBanner.data[0].name} - -
- )} -
- {categoryPilihan?.data?.map((category) => ( -
-
-
-
- {category?.name} -
-

{category?.industries}

-
-
-
- - Lihat semua - -
-
- ))} + const { isDesktop, isMobile } = useDevice(); + const { categoryPilihan } = useCategoryPilihan(); + const heroBanner = useQuery( + 'categoryPilihan', + bannerApi({ type: 'banner-category-list' }) + ); + return ( + categoryPilihan.length > 0 && ( +
+ {isDesktop && ( +
+
+
+ LOB Kategori Pilihan +
+

+ 200 Rb+ Produk Unggulan & 800+ Brand Rekomendasi tersedia! +

+
+ {heroBanner.data && heroBanner.data?.length > 0 && ( +
+ + {heroBanner.data[0].name} + +
+ )} +
+ {categoryPilihan?.data?.map((category) => ( +
+
+
+
+ {category?.name} +
+

+ {category?.industries} +

+
+
+ + Lihat semua + +
- )} - {isMobile && ( -
-
-
LOB Kategori Pilihan
- {/*

200 Rb+ Produk Unggulan & 800+ Brand Rekomendasi tersedia!

*/} + ))} +
+
+ )} + {isMobile && ( +
+
+
+ LOB Kategori Pilihan +
+ {/*

200 Rb+ Produk Unggulan & 800+ Brand Rekomendasi tersedia!

*/} +
+
+ {heroBanner.data && heroBanner.data?.length > 0 && ( +
+ + {heroBanner.data[0].name} + +
+ )} +
+ + {categoryPilihan?.data?.map((category) => ( + +
+
+
+
+ {category?.name} +
+

+ {category?.industries} +

+
-
- {heroBanner.data && - heroBanner.data?.length > 0 && ( -
- - {heroBanner.data[0].name} - -
- )} +
+ + Lihat semua +
- - {categoryPilihan?.data?.map((category) => ( - -
-
-
-
- {category?.name} -
-

{category?.industries}

-
-
-
- - Lihat semua - -
-
-
- ))} - -
- -
- )} -
- - ) - ) -} +
+ + ))} + +
+ )} +
+ ) + ); +}; -export default CategoryPilihan +export default CategoryPilihan; diff --git a/src/lib/home/components/PromotionProgram.jsx b/src/lib/home/components/PromotionProgram.jsx index ae8d5d6f..ae06bd4d 100644 --- a/src/lib/home/components/PromotionProgram.jsx +++ b/src/lib/home/components/PromotionProgram.jsx @@ -1,13 +1,16 @@ -import Link from '@/core/components/elements/Link/Link' -import Image from 'next/image' +import Link from '@/core/components/elements/Link/Link'; +import Image from 'next/image'; import { bannerApi } from '@/api/bannerApi'; -import useDevice from '@/core/hooks/useDevice' +import useDevice from '@/core/hooks/useDevice'; import { Swiper, SwiperSlide } from 'swiper/react'; -import BannerPromoSkeleton from '../components/Skeleton/BannerPromoSkeleton'; -const { useQuery } = require('react-query') +import BannerPromoSkeleton from '../components/Skeleton/BannerPromoSkeleton'; +const { useQuery } = require('react-query'); const BannerSection = () => { - const promotionProgram = useQuery('promotionProgram', bannerApi({ type: 'banner-promotion' })); - const { isMobile, isDesktop } = useDevice() + const promotionProgram = useQuery( + 'promotionProgram', + bannerApi({ type: 'banner-promotion' }) + ); + const { isMobile, isDesktop } = useDevice(); if (promotionProgram.isLoading) { return ; @@ -16,60 +19,65 @@ const BannerSection = () => { return (
-

Promo Tersedia

+

+ {' '} + + Promo Tersedia + +

{isDesktop && ( - Lihat Semua - + Lihat Semua + )} {isMobile && ( - - Lihat Semua - - )} -
- {isDesktop && (promotionProgram.data && - promotionProgram.data?.length > 0 && ( -
- {promotionProgram.data?.map((banner) => ( - - {banner.name} + + Lihat Semua - ))} + )}
- - ))} + {isDesktop && + promotionProgram.data && + promotionProgram.data?.length > 0 && ( +
+ {promotionProgram.data?.map((banner) => ( + + {banner.name} + + ))} +
+ )} -{isMobile && ( - - - {promotionProgram.data?.map((banner) => ( - - - {banner.name} - - - ))} - - - )} + {isMobile && ( + + {promotionProgram.data?.map((banner) => ( + + + {banner.name} + + + ))} + + )}
- - ) -} + ); +}; -export default BannerSection +export default BannerSection; diff --git a/src/lib/home/components/ServiceList.jsx b/src/lib/home/components/ServiceList.jsx index b8799d7d..5b16915d 100644 --- a/src/lib/home/components/ServiceList.jsx +++ b/src/lib/home/components/ServiceList.jsx @@ -1,5 +1,5 @@ -import Image from 'next/image' -import Link from '@/core/components/elements/Link/Link' +import Image from 'next/image'; +import Link from '@/core/components/elements/Link/Link'; const ServiceList = () => { return ( @@ -14,14 +14,16 @@ const ServiceList = () => {
-

One Stop Solution

+

+ One Stop Solution +

Temukan Solusi Lengkap Anda dalam Satu Tempat.

@@ -37,14 +39,16 @@ const ServiceList = () => {
-

Garansi Resmi

+

+ Garansi Resmi +

Garansi Keaslian Barang dan Jaminan Purna Jual.

@@ -60,14 +64,16 @@ const ServiceList = () => {
-

Pembayaran Tempo

+

+ Pembayaran Tempo +

Lebih mudah mengatur pembelian dengan pembayaran tempo.

@@ -83,14 +89,16 @@ const ServiceList = () => {
-

Faktur Pajak

+

+ Faktur Pajak +

Dapat Faktur pajak untuk setiap transaksi dengan indoteknik.com

@@ -99,7 +107,7 @@ const ServiceList = () => {
- ) -} + ); +}; -export default ServiceList +export default ServiceList; diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx index 4529c977..cb7684ed 100644 --- a/src/lib/quotation/components/Quotationheader.jsx +++ b/src/lib/quotation/components/Quotationheader.jsx @@ -19,14 +19,22 @@ const Quotationheader = (quotationCount) => { context: 'quotation', site: auth?.webRole === null && auth?.site ? auth.site : null, }; - + const router = useRouter(); const [subTotal, setSubTotal] = useState(null); const [buttonLoading, SetButtonTerapkan] = useState(false); const itemLoading = [1, 2, 3]; const [countQuotation, setCountQuotation] = useState(null); - const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation } = - useProductCartContext(); + const { + productCart, + setProductCart, + refreshCart, + setRefreshCart, + isLoading, + setIsloading, + productQuotation, + setProductQuotation, + } = useProductCartContext(); const [isHovered, setIsHovered] = useState(false); const [isTop, setIsTop] = useState(true); @@ -49,34 +57,44 @@ const Quotationheader = (quotationCount) => { refreshCartf(); } }; - let { transactions } = useTransactions({ query }); + let transactions = null; + + if (auth) { + transactions = useTransactions({ query }); + } const refreshCartf = useCallback(async () => { setIsloading(true); - let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft'); + let pendingTransactions = transactions?.data?.saleOrders.filter( + (transaction) => transaction.status === 'draft' + ); setProductQuotation(pendingTransactions); - setCountQuotation(pendingTransactions?.length ? pendingTransactions?.length : pendingTransactions?.length); + setCountQuotation( + pendingTransactions?.length + ? pendingTransactions?.length + : pendingTransactions?.length + ); setIsloading(false); }, [setProductQuotation, setIsloading]); useEffect(() => { - if (!qotation) return + if (!qotation) return; - let calculateTotalDiscountAmount = 0 + let calculateTotalDiscountAmount = 0; for (const product of qotation) { - // if (qotation.quantity == '') continue - calculateTotalDiscountAmount += product.amountUntaxed + // if (qotation.quantity == '') continue + calculateTotalDiscountAmount += product.amountUntaxed; } - let subTotal = calculateTotalDiscountAmount - setSubTotal(subTotal) - }, [qotation]) + let subTotal = calculateTotalDiscountAmount; + setSubTotal(subTotal); + }, [qotation]); useEffect(() => { if (refreshCart) { refreshCartf(); } setRefreshCart(false); - }, [ refreshCartf, setRefreshCart]); + }, [refreshCartf, setRefreshCart]); useEffect(() => { setCountQuotation(quotationCount.quotationCount); @@ -95,7 +113,10 @@ const Quotationheader = (quotationCount) => { const handleCheckout = async () => { SetButtonTerapkan(true); - let checkoutAll = await odooApi('POST', `/api/v1/user/${auth.id}/cart/select-all`); + let checkoutAll = await odooApi( + 'POST', + `/api/v1/user/${auth.id}/cart/select-all` + ); router.push('/my/quotations'); }; @@ -150,7 +171,9 @@ const Quotationheader = (quotationCount) => { className='w-full max-w-md p-2 bg-white border border-gray-200 rounded-lg shadow overflow-hidden' >
-
Daftar Quotation
+
+ Daftar Quotation +

@@ -158,7 +181,10 @@ const Quotationheader = (quotationCount) => {

Silahkan{' '} - + Login {' '} Untuk Melihat Daftar Quotation Anda @@ -167,7 +193,11 @@ const Quotationheader = (quotationCount) => { )} {isLoading && itemLoading.map((item) => ( -

+
@@ -189,43 +219,70 @@ const Quotationheader = (quotationCount) => { )} {auth && qotation.length > 0 && !isLoading && ( <> -
    +
      {qotation && qotation?.map((product, index) => ( <>
    • - + className='hover:border-red-500' + >
      -

      Sales :

      -

      {product.sales}

      +

      + Sales :{' '} +

      +

      + {product.sales} +

      -

      Status :

      -

      Pending Quotation

      +

      + Status : +

      +

      + Pending Quotation +

      -

      No. Transaksi

      -

      {product.name}

      +

      + No. Transaksi +

      +

      + {' '} + {product.name} +

      -

      No. Purchase Order

      -

      {product.purchaseOrderName ? product.purchaseOrderName : '-'}

      +

      + No. Purchase Order +

      +

      + {' '} + {product.purchaseOrderName + ? product.purchaseOrderName + : '-'} +

      {/*
      */}
      -

      Total

      -

      {currencyFormat(product.amountUntaxed)}

      +

      + Total +

      +

      + {currencyFormat(product.amountUntaxed)} +

      - +
    • @@ -238,8 +295,12 @@ const Quotationheader = (quotationCount) => { {auth && qotation.length > 0 && !isLoading && ( <>
      - Subtotal Sebelum PPN : - {currencyFormat(subTotal)} + + Subtotal Sebelum PPN :{' '} + + + {currencyFormat(subTotal)} +
      -
      - - {/* Display the API error message */} - {apiError &&
      {apiError}
      } - +
      + + +
      + {errors.email?.message} +
      -
- ) -} +
+
+ +
+ + {/* Display the API error message */} + {apiError &&
{apiError}
} + +
+
+ ); +}; const validationSchema = Yup.object().shape({ - email: Yup.string().email('Format harus seperti contoh@email.com').required('Harus di-isi'), - id: Yup.string().required('Harus di-isi'), -}) + email: Yup.string() + .email('Format harus seperti contoh@email.com') + .required('Harus di-isi'), + id: Yup.string().required('Harus di-isi'), +}); const defaultValues = { - email: '', - id: '' -} + email: '', + id: '', +}; -export default TrackingOrder +export default TrackingOrder; diff --git a/src/pages/my/profile.jsx b/src/pages/my/profile.jsx index 25c3a608..7cf1bcbb 100644 --- a/src/pages/my/profile.jsx +++ b/src/pages/my/profile.jsx @@ -1,41 +1,44 @@ -import Divider from '@/core/components/elements/Divider/Divider' -import AppLayout from '@/core/components/layouts/AppLayout' -import BasicLayout from '@/core/components/layouts/BasicLayout' -import DesktopView from '@/core/components/views/DesktopView' -import MobileView from '@/core/components/views/MobileView' -import useAuth from '@/core/hooks/useAuth' -import CompanyProfile from '@/lib/auth/components/CompanyProfile' -import IsAuth from '@/lib/auth/components/IsAuth' -import Menu from '@/lib/auth/components/Menu' -import PersonalProfile from '@/lib/auth/components/PersonalProfile' +import Divider from '@/core/components/elements/Divider/Divider'; +import AppLayout from '@/core/components/layouts/AppLayout'; +import BasicLayout from '@/core/components/layouts/BasicLayout'; +import DesktopView from '@/core/components/views/DesktopView'; +import MobileView from '@/core/components/views/MobileView'; +import useAuth from '@/core/hooks/useAuth'; +import CompanyProfile from '@/lib/auth/components/CompanyProfile'; +import IsAuth from '@/lib/auth/components/IsAuth'; +import Menu from '@/lib/auth/components/Menu'; +import PersonalProfile from '@/lib/auth/components/PersonalProfile'; +import Seo from '@/core/components/Seo'; export default function Profile() { - const auth = useAuth() + const auth = useAuth(); return ( - - - - - - {auth?.parentId && } - - - - - -
-
- -
-
+ <> + + + + {auth?.parentId && } + + -
-
-
-
-
- ) + + +
+
+ +
+
+ + + {auth?.parentId && } +
+
+
+
+ + + ); } -- cgit v1.2.3 From 6448a83e088b68195e9b94036d3e8e2184ae701c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 24 Sep 2024 16:54:37 +0700 Subject: update code --- src/lib/brand/components/BrandCard.jsx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/lib/brand/components/BrandCard.jsx b/src/lib/brand/components/BrandCard.jsx index 2d78d956..ebd41a67 100644 --- a/src/lib/brand/components/BrandCard.jsx +++ b/src/lib/brand/components/BrandCard.jsx @@ -1,10 +1,10 @@ -import Image from '~/components/ui/image' -import Link from '@/core/components/elements/Link/Link' -import useDevice from '@/core/hooks/useDevice' -import { createSlug } from '@/core/utils/slug' +import NextImage from 'next/image'; +import Link from '@/core/components/elements/Link/Link'; +import useDevice from '@/core/hooks/useDevice'; +import { createSlug } from '@/core/utils/slug'; const BrandCard = ({ brand }) => { - const { isMobile } = useDevice() + const { isMobile } = useDevice(); return ( { }`} > {brand.logo && ( - {brand.name} )} {!brand.logo && ( - + {brand.name} )} - ) -} + ); +}; -export default BrandCard +export default BrandCard; -- cgit v1.2.3 From 2e7b5789f013c121b48edcb3589d094a2b636c59 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 25 Sep 2024 09:14:54 +0700 Subject: back to code --- src/core/components/elements/Navbar/NavbarDesktop.jsx | 12 ++++-------- src/lib/quotation/components/Quotationheader.jsx | 6 +----- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index d480aa8d..eebfbcd5 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -57,12 +57,8 @@ const NavbarDesktop = () => { context: 'quotation', site: auth?.webRole === null && auth?.site ? auth.site : null, }; - let transactions = null; - - if (auth) { - transactions = useTransactions({ query }); - } + const { transactions } = useTransactions({ query }); const data = transactions?.data?.saleOrders.filter( (transaction) => transaction.status === 'draft' ); @@ -109,7 +105,7 @@ const NavbarDesktop = () => { useEffect(() => { setPendingTransactions(data); - }, [transactions?.data]); + }, [transactions.data]); useEffect(() => { if (router.pathname === '/shop/product/[slug]') { @@ -139,7 +135,7 @@ const NavbarDesktop = () => { return () => { window.removeEventListener('localStorageChange', handleCartChange); }; - }, [transactions?.data, cart]); + }, [transactions.data, cart]); useEffect(() => { const handleQuotationChange = () => { @@ -291,7 +287,7 @@ const NavbarDesktop = () => { alt='penawaran terbatas' width={1440} height={160} - quality={85} + quality={100} // className={`fixed ${isTop ? 'md:top-[145px] lg:top-[160px] ' : 'lg:top-[85px] top-[80px]'} rounded-3xl md:left-1/4 lg:left-1/4 xl:left-1/4 left-2/3 w-40 h-12 p-2 z-50 transition-all duration-300 animate-pulse`} className={`inline-block relative -top-8 transition-all duration-300 z-20 animate-pulse`} /> diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx index cb7684ed..d94a55de 100644 --- a/src/lib/quotation/components/Quotationheader.jsx +++ b/src/lib/quotation/components/Quotationheader.jsx @@ -57,11 +57,7 @@ const Quotationheader = (quotationCount) => { refreshCartf(); } }; - let transactions = null; - - if (auth) { - transactions = useTransactions({ query }); - } + let { transactions } = useTransactions({ query }); const refreshCartf = useCallback(async () => { setIsloading(true); -- cgit v1.2.3 From ea200698d878a54171857421cf20845998b3a228 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 25 Sep 2024 14:34:12 +0700 Subject: change code name --- src/lib/product/components/ProductCard.jsx | 61 +++++++++++++++--------------- src/utils/solrMapping.js | 8 ++-- 2 files changed, 34 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 10c06775..d3b50302 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -16,13 +16,8 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const utmSource = useUtmSource(); const [discount, setDiscount] = useState(0); - let voucherPastiHemat = product?.voucherPastiHemat ? 0 : product.newVoucherPastiHemat; - - if (product?.voucherPastiHemat ? product?.voucherPastiHemat.length : voucherPastiHemat > 0) { - const stringVoucher = product?.voucherPastiHemat[0]; - const validJsonString = stringVoucher.replace(/'/g, '"'); - voucherPastiHemat = JSON.parse(validJsonString); - } + let voucherPastiHemat = 0; + voucherPastiHemat = product?.newVoucherPastiHemat[0]; const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, @@ -48,18 +43,18 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const hitungDiscountVoucher = () => { let countDiscount = 0; - if (voucherPastiHemat.discount_type === 'percentage') { + if (voucherPastiHemat.discountType === 'percentage') { countDiscount = product?.lowestPrice.priceDiscount * - (voucherPastiHemat.discount_amount / 100); + (voucherPastiHemat.discountAmount / 100); if ( - voucherPastiHemat.max_discount > 0 && - countDiscount > voucherPastiHemat.max_discount + voucherPastiHemat.maxDiscount > 0 && + countDiscount > voucherPastiHemat.maxDiscount ) { - countDiscount = voucherPastiHemat.max_discount; + countDiscount = voucherPastiHemat.maxDiscount; } } else { - countDiscount = voucherPastiHemat.discount_amount; + countDiscount = voucherPastiHemat.discountAmount; } setDiscount(countDiscount); @@ -147,20 +142,24 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
- {product?.manufacture?.name ? ( - - {product.manufacture.name} - - ) : ( -
-
- )} - {product?.isInBu && ( - - pickup now - - - - )} + {product?.manufacture?.name ? ( + + {product.manufacture.name} + + ) : ( +
-
+ )} + {product?.isInBu && ( + + pickup now + + )}
{
)} {product?.manufacture?.name ? ( -
+
- {product.manufacture.name} - - {/* {product?.is_in_bu && ( + {product.manufacture.name} + + {/* {product?.is_in_bu && (
Click & Pickup diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js index fad1263a..f73e966a 100644 --- a/src/utils/solrMapping.js +++ b/src/utils/solrMapping.js @@ -85,10 +85,10 @@ export const productMappingSolr = (products, pricelist) => { ]; productMapped.newVoucherPastiHemat = [ { - min_purchase: product.min_purchase_f || 0, - discount_type: product.discount_type_s || '', - discount_amount: product.discount_amount_f || 0, - max_discount: product.max_discount_f || 0, + min_purchase: product.voucher_min_purchase_f || 0, + discount_type: product.voucher_discount_type_s || '', + discount_amount: product.voucher_discount_amount_f || 0, + max_discount: product.voucher_max_discount_f || 0, }, ]; return productMapped; -- cgit v1.2.3 From 0cf4e527dd7565261349d9485a82695379427892 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 26 Sep 2024 10:06:58 +0700 Subject: bug ga bisa pilih alamat di quotation --- src/lib/quotation/components/Quotation.jsx | 107 +++++++++++++++-------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index 0ad042de..cf0ad41f 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -39,12 +39,12 @@ const { getProductsCheckout } = require('@/lib/checkout/api/checkoutApi'); const Quotation = () => { const router = useRouter(); const auth = useAuth(); - + const { data: cartCheckout } = useQuery('cartCheckout', () => getProductsCheckout() -); + ); -const { setRefreshCart } = useProductCartContext(); + const { setRefreshCart } = useProductCartContext(); const SELF_PICKUP_ID = 32; const [products, setProducts] = useState(null); @@ -69,18 +69,18 @@ const { setRefreshCart } = useProductCartContext(); 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(''); useEffect(() => { @@ -99,6 +99,9 @@ const { setRefreshCart } = useProductCartContext(); if (!addresses) return; const matchAddress = (key) => { + if (key === 'invoicing') { + key = 'invoice'; + } const addressToMatch = getItemAddress(key); const foundAddress = addresses.filter( (address) => address.id == addressToMatch @@ -271,7 +274,7 @@ const { setRefreshCart } = useProductCartContext(); toast.error('Maaf, Note wajib dimasukkan.'); return; } - + setIsLoading(true); const productOrder = products.map((product) => ({ product_id: product.id, @@ -286,11 +289,10 @@ const { setRefreshCart } = useProductCartContext(); carrier_id: selectedCarrierId, estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, - note_website : note_websiteText, + note_website: note_websiteText, }; - + const isSuccess = await checkoutApi({ data }); - ; setIsLoading(false); if (isSuccess?.id) { for (const product of products) deleteItemCart({ productId: product.id }); @@ -298,7 +300,7 @@ const { setRefreshCart } = useProductCartContext(); setRefreshCart(true); return; } - + toast.error('Gagal melakukan transaksi, terjadi kesalahan internal'); }; @@ -455,25 +457,26 @@ const { setRefreshCart } = useProductCartContext(); {' '} yang berlaku

-
- -
-
Note
- {isApproval && ( -
*harus diisi
- )} -
-
-