From 77a5ab2d7dd9967e41d9c365e6e5dd45a2d32db2 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 13:31:19 +0700 Subject: bugs fix voucher --- src/lib/checkout/api/getVoucher.js | 18 ++++++++++++++---- src/lib/checkout/components/Checkout.jsx | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js index 57d8acf5..07cf376e 100644 --- a/src/lib/checkout/api/getVoucher.js +++ b/src/lib/checkout/api/getVoucher.js @@ -1,11 +1,21 @@ import odooApi from '@/core/api/odooApi' -export const getVoucher = async (id) => { - const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher`) +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 findVoucher = async (code, id) => { - const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?code=${code}`) +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}`) + } return dataVoucher } diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 53ac63e1..c6ea73f2 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -107,7 +107,7 @@ const Checkout = () => { const voucher = async () => { if (!listVouchers) { try { - let dataVoucher = await getVoucher(auth?.id) + let dataVoucher = await getVoucher(auth?.id, query) SetListVoucher(dataVoucher) } finally { setLoadingVoucher(false) @@ -115,7 +115,7 @@ const Checkout = () => { } } const VoucherCode = async (code) => { - let dataVoucher = await findVoucher(code, auth.id) + let dataVoucher = await findVoucher(code, auth.id, query) if (dataVoucher.length <= 0) { SetFindVoucher(1) return @@ -427,7 +427,7 @@ const Checkout = () => {
- {!loadingVoucher && listVouchers.length === 0 ? ( + {!loadingVoucher && listVouchers?.length === 0 ? (

Tidak ada voucher tersedia

-- cgit v1.2.3 From f862f6426c28fb9245d13fb7386a88b209639d64 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 13:55:14 +0700 Subject: change url blog --- src/core/components/elements/Navbar/NavbarDesktop.jsx | 4 +++- src/core/components/elements/Sidebar/Sidebar.jsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index ea4b03ae..1f5204cd 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -162,8 +162,10 @@ const NavbarDesktop = () => { Ready Stock Blog Indoteknik diff --git a/src/core/components/elements/Sidebar/Sidebar.jsx b/src/core/components/elements/Sidebar/Sidebar.jsx index 7ea8f7c4..f0bcb7b7 100644 --- a/src/core/components/elements/Sidebar/Sidebar.jsx +++ b/src/core/components/elements/Sidebar/Sidebar.jsx @@ -120,7 +120,7 @@ const Sidebar = ({ active, close }) => { Semua Brand - + Blog Indoteknik -- cgit v1.2.3 From 16fed2e7d00252f5df3f9b5bdf0a5a2b2a094f76 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 8 Aug 2023 10:39:34 +0700 Subject: Improve home page performance --- src/components/skeleton/BannerSkeleton.jsx | 1 - .../components/elements/Navbar/NavbarDesktop.jsx | 5 ++- src/core/components/elements/Navbar/Search.jsx | 30 +++++++++--------- src/core/components/elements/Navbar/TopBanner.jsx | 5 +++ .../elements/Skeleton/TopBannerSkeleton.jsx | 19 ++++++++++++ src/core/components/layouts/BasicLayout.jsx | 1 - src/lib/flashSale/components/FlashSale.jsx | 13 +++++++- src/lib/flashSale/skeleton/FlashSaleSkeleton.jsx | 36 ++++++++++++++++++++++ .../components/Skeleton/PreferredBrandSkeleton.jsx | 22 +++++++------ src/lib/product/components/ProductCard.jsx | 2 +- src/pages/_app.jsx | 1 + src/pages/index.jsx | 36 ++++++++++------------ 12 files changed, 122 insertions(+), 49 deletions(-) create mode 100644 src/core/components/elements/Skeleton/TopBannerSkeleton.jsx create mode 100644 src/lib/flashSale/skeleton/FlashSaleSkeleton.jsx (limited to 'src') diff --git a/src/components/skeleton/BannerSkeleton.jsx b/src/components/skeleton/BannerSkeleton.jsx index 7cb3952d..da86aef9 100644 --- a/src/components/skeleton/BannerSkeleton.jsx +++ b/src/components/skeleton/BannerSkeleton.jsx @@ -1,7 +1,6 @@ import useDevice from '@/core/hooks/useDevice' import classNames from 'classnames' import Skeleton from 'react-loading-skeleton' -import 'react-loading-skeleton/dist/skeleton.css' const HeroBannerSkeleton = () => { const { isDesktop, isMobile } = useDevice() diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 1f5204cd..acd2d1ee 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -14,14 +14,17 @@ import { useEffect, useState } from 'react' import useAuth from '@/core/hooks/useAuth' import NavbarUserDropdown from './NavbarUserDropdown' import { getCountCart } from '@/core/utils/cart' -import TopBanner from './TopBanner' import whatsappUrl from '@/core/utils/whatsappUrl' import { useRouter } from 'next/router' import { getAuth } from '@/core/utils/auth' import { createSlug, getIdFromSlug } from '@/core/utils/slug' import productApi from '@/lib/product/api/productApi' +import { TopBannerSkeleton } from '../Skeleton/TopBannerSkeleton' const Search = dynamic(() => import('./Search')) +const TopBanner = dynamic(() => import('./TopBanner'), { + loading: () => +}) const NavbarDesktop = () => { const [isOpenCategory, setIsOpenCategory] = useState(false) diff --git a/src/core/components/elements/Navbar/Search.jsx b/src/core/components/elements/Navbar/Search.jsx index 47a9c235..f4a8ab3a 100644 --- a/src/core/components/elements/Navbar/Search.jsx +++ b/src/core/components/elements/Navbar/Search.jsx @@ -64,21 +64,21 @@ const Search = () => { - {suggestions.length > 0 && ( - <> -
- {suggestions.map((suggestion, index) => ( - - {suggestion.term} - - ))} -
- - )} +
0 ? 'block' : 'hidden' + }`} + > + {suggestions.map((suggestion, index) => ( + + {suggestion.term} + + ))} +
) diff --git a/src/core/components/elements/Navbar/TopBanner.jsx b/src/core/components/elements/Navbar/TopBanner.jsx index 9efd0a8d..dca2e930 100644 --- a/src/core/components/elements/Navbar/TopBanner.jsx +++ b/src/core/components/elements/Navbar/TopBanner.jsx @@ -2,11 +2,16 @@ import odooApi from '@/core/api/odooApi' import { useQuery } from 'react-query' import Image from 'next/image' import Link from '../Link/Link' +import { TopBannerSkeleton } from '../Skeleton/TopBannerSkeleton' const TopBanner = () => { const fetchTopBanner = async () => await odooApi('GET', '/api/v1/banner?type=top-banner') const topBanner = useQuery('topBanner', fetchTopBanner) + if (topBanner.isLoading) { + return + } + return ( topBanner.isFetched && topBanner.data?.length > 0 && ( diff --git a/src/core/components/elements/Skeleton/TopBannerSkeleton.jsx b/src/core/components/elements/Skeleton/TopBannerSkeleton.jsx new file mode 100644 index 00000000..f7d2e748 --- /dev/null +++ b/src/core/components/elements/Skeleton/TopBannerSkeleton.jsx @@ -0,0 +1,19 @@ +import useDevice from '@/core/hooks/useDevice' +import classNames from 'classnames' +import Skeleton from 'react-loading-skeleton' + +const TopBannerSkeleton = () => { + const { isDesktop, isMobile } = useDevice() + + const deviceClassName = { + 'h-10': isDesktop, + 'h-2.5': isMobile + } + const combinedClassName = classNames(deviceClassName) + + return ( + + ) +} + +export { TopBannerSkeleton } diff --git a/src/core/components/layouts/BasicLayout.jsx b/src/core/components/layouts/BasicLayout.jsx index 073303fe..554f587d 100644 --- a/src/core/components/layouts/BasicLayout.jsx +++ b/src/core/components/layouts/BasicLayout.jsx @@ -46,7 +46,6 @@ const BasicLayout = ({ children }) => { } getProduct() setTemplateWA('product') - } }, []) return ( diff --git a/src/lib/flashSale/components/FlashSale.jsx b/src/lib/flashSale/components/FlashSale.jsx index e4a4a25c..87545d8d 100644 --- a/src/lib/flashSale/components/FlashSale.jsx +++ b/src/lib/flashSale/components/FlashSale.jsx @@ -1,21 +1,28 @@ import { useEffect, useState } from 'react' import flashSaleApi from '../api/flashSaleApi' -import Image from '@/core/components/elements/Image/Image' +import Image from 'next/image' import CountDown from '@/core/components/elements/CountDown/CountDown' import productSearchApi from '@/lib/product/api/productSearchApi' import ProductSlider from '@/lib/product/components/ProductSlider' +import { FlashSaleSkeleton } from '../skeleton/FlashSaleSkeleton' const FlashSale = () => { const [flashSales, setFlashSales] = useState(null) + const [isLoading, setIsLoading] = useState(true) useEffect(() => { const loadFlashSales = async () => { const dataFlashSales = await flashSaleApi() setFlashSales(dataFlashSales) + setIsLoading(false) } loadFlashSales() }, []) + if (isLoading) { + return + } + return ( flashSales?.length > 0 && (
@@ -30,11 +37,15 @@ const FlashSale = () => { {flashSale.name} {flashSale.name} diff --git a/src/lib/flashSale/skeleton/FlashSaleSkeleton.jsx b/src/lib/flashSale/skeleton/FlashSaleSkeleton.jsx new file mode 100644 index 00000000..e9a200d9 --- /dev/null +++ b/src/lib/flashSale/skeleton/FlashSaleSkeleton.jsx @@ -0,0 +1,36 @@ +import useDevice from '@/core/hooks/useDevice' +import PopularProductSkeleton from '@/lib/home/components/Skeleton/PopularProductSkeleton' +import Skeleton from 'react-loading-skeleton' + +const FlashSaleSkeleton = () => { + return ( +
+ +
+ +
+ +
+ ) +} + +const TitleSkeleton = () => { + return ( +
+ +
+ + + + +
+
+ ) +} + +const BannerSkeleton = () => { + const { isDesktop } = useDevice() + return +} + +export { FlashSaleSkeleton, TitleSkeleton, BannerSkeleton } diff --git a/src/lib/home/components/Skeleton/PreferredBrandSkeleton.jsx b/src/lib/home/components/Skeleton/PreferredBrandSkeleton.jsx index 00589342..bd783053 100644 --- a/src/lib/home/components/Skeleton/PreferredBrandSkeleton.jsx +++ b/src/lib/home/components/Skeleton/PreferredBrandSkeleton.jsx @@ -1,12 +1,16 @@ -import BrandSkeleton from '@/core/components/elements/Skeleton/BrandSkeleton' +import useDevice from '@/core/hooks/useDevice' +import Skeleton from 'react-loading-skeleton' -const PreferredBrandSkeleton = () => ( -
- - - - -
-) +const PreferredBrandSkeleton = () => { + const { isDesktop } = useDevice() + + return ( +
+ {Array.from({ length: isDesktop ? 8 : 4 }, (_, index) => ( + + ))} +
+ ) +} export default PreferredBrandSkeleton diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index a8964310..51a369c4 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -12,7 +12,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { return ( -
+
import('@/core/components/layouts/BasicLayout')) const HeroBanner = dynamic(() => import('@/components/ui/HeroBanner'), { @@ -19,9 +21,13 @@ const PopularProduct = dynamic(() => import('@/components/ui/PopularProduct'), { loading: () => }) -const PreferredBrand = dynamic(() => import('@/lib/home/components/PreferredBrand')) +const PreferredBrand = dynamic(() => import('@/lib/home/components/PreferredBrand'), { + loading: () => +}) -const FlashSale = dynamic(() => import('@/lib/flashSale/components/FlashSale')) +const FlashSale = dynamic(() => import('@/lib/flashSale/components/FlashSale'), { + loading: () => +}) const BannerSection = dynamic(() => import('@/lib/home/components/BannerSection')) const CategoryHomeId = dynamic(() => import('@/lib/home/components/CategoryHomeId')) const CustomerReviews = dynamic(() => import('@/lib/review/components/CustomerReviews')) @@ -66,22 +72,12 @@ export default function Home() {
- - - - - - - - - - - - - - - - + + + + + +
@@ -98,8 +94,8 @@ export default function Home() { - - + + -- cgit v1.2.3 From eadb2ba5872fc2e9a756948d9bbfa17f0958690a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 8 Aug 2023 10:44:25 +0700 Subject: Update product card height --- src/lib/product/components/ProductCard.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 51a369c4..13fe07fd 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -12,7 +12,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { return ( -
+