diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/ui/HeroBanner.jsx | 14 | ||||
| -rw-r--r-- | src/components/ui/HeroBannerSecondary.jsx | 12 | ||||
| -rw-r--r-- | src/core/components/elements/Navbar/NavbarDesktop.jsx | 30 | ||||
| -rw-r--r-- | src/lib/address/components/EditAddress.jsx | 37 | ||||
| -rw-r--r-- | src/lib/transaction/api/transactionsApi.js | 3 | ||||
| -rw-r--r-- | src/pages/index.jsx | 16 |
6 files changed, 61 insertions, 51 deletions
diff --git a/src/components/ui/HeroBanner.jsx b/src/components/ui/HeroBanner.jsx index 9a62465d..64838b85 100644 --- a/src/components/ui/HeroBanner.jsx +++ b/src/components/ui/HeroBanner.jsx @@ -39,16 +39,28 @@ const HeroBanner = () => { pagination: { dynamicBullets: false, clickable: true }, }; + const customLoader = ({ src }) => { + return src; // Loader yang mengembalikan URL gambar asli + }; + const BannerComponent = useMemo(() => { - return heroBanner.data?.map((banner, index) => ( + if (!heroBanner.data) return null; + + return heroBanner.data.map((banner, index) => ( <SwiperSlide key={index}> <Link href={banner.url} className='w-full h-auto'> <Image + loader={customLoader} src={banner.image} alt={banner.name} width={1152} height={768} className='w-full h-auto' + priority={index === 0} + loading={index === 0 ? 'eager' : 'lazy'} + placeholder="blur" + blurDataURL="/images/indoteknik-placeholder.png" + sizes="(max-width: 768px) 100vw, 50vw" /> </Link> </SwiperSlide> diff --git a/src/components/ui/HeroBannerSecondary.jsx b/src/components/ui/HeroBannerSecondary.jsx index b1023990..a7b32a4a 100644 --- a/src/components/ui/HeroBannerSecondary.jsx +++ b/src/components/ui/HeroBannerSecondary.jsx @@ -18,18 +18,22 @@ const HeroBannerSecondary = () => { if (heroBannerSecondary.isLoading) return <HeroBannerSkeleton /> return ( - heroBannerSecondary.data && ( - <Link href={heroBannerSecondary.data[randomIndex].url} className='h-full'> + heroBannerSecondary.data && randomIndex !== null && ( + <Link href={heroBannerSecondary.data[randomIndex].url} className="h-full"> <Image src={heroBannerSecondary.data[randomIndex].image} width={512} height={1024} alt={heroBannerSecondary.data[randomIndex].name} - className='object-cover object-center h-full' + className="object-cover object-center h-full" + loading="lazy" + placeholder="blur" + blurDataURL="/images/indoteknik-placeholder.png" + sizes="(max-width: 768px) 100vw, 50vw" /> </Link> ) - ) + ); } export default HeroBannerSecondary diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index eebfbcd5..04cf76d1 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -5,34 +5,28 @@ 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 Category from '@/lib/category/components/Category'; -import { useProductCartContext } from '@/contexts/ProductCartContext'; +import useTransactions from '@/lib/transaction/hooks/useTransactions'; +import { + Menu, + MenuButton, + MenuItem, + MenuList, + useDisclosure +} from '@chakra-ui/react'; import { ChevronDownIcon, - DocumentCheckIcon, - HeartIcon, - ArrowUpRightIcon, + HeartIcon } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; -import Image from 'next/image'; +import { default as Image, default as NextImage } from 'next/image'; import { useRouter } from 'next/router'; import { useCallback, useEffect, useState } from 'react'; +import { useCartStore } from '~/modules/cart/stores/useCartStore'; +import Quotationheader from '../../../../../src/lib/quotation/components/Quotationheader.jsx'; import DesktopView from '../../views/DesktopView'; import Link from '../Link/Link'; import NavbarUserDropdown from './NavbarUserDropdown'; -import NextImage from 'next/image'; -import { - Button, - Menu, - MenuButton, - MenuItem, - MenuList, - useDisclosure, -} from '@chakra-ui/react'; -import style from './style/NavbarDesktop.module.css'; -import useTransactions from '@/lib/transaction/hooks/useTransactions'; -import { useCartStore } from '~/modules/cart/stores/useCartStore'; const Search = dynamic(() => import('./Search'), { ssr: false }); const TopBanner = dynamic(() => import('./TopBanner'), { ssr: false }); diff --git a/src/lib/address/components/EditAddress.jsx b/src/lib/address/components/EditAddress.jsx index ff6b1f12..182c8a31 100644 --- a/src/lib/address/components/EditAddress.jsx +++ b/src/lib/address/components/EditAddress.jsx @@ -45,7 +45,7 @@ const EditAddress = ({ id, defaultValues }) => { setValue('business_name', dataProfile.name); }; if (auth) loadProfile(); - }, [auth, setValue]); + }, [auth?.parentId]); useEffect(() => { const loadCities = async () => { @@ -111,30 +111,29 @@ const EditAddress = ({ id, defaultValues }) => { district_id: values.district, sub_district_id: values.subDistrict, }; + if (!auth.company) { + data.alamat_lengkap_text = values.street; + } const address = await editAddressApi({ id, data }); let dataAlamat; let isUpdated = true; - if (auth?.partnerId == id) { - dataAlamat = { - id_user: auth.partnerId, - company_type_id: values.companyType, - industry_id: values.industry, - tax_name: values.taxName, - alamat_lengkap_text: values.alamat_wajib_pajak, - street: values.street, - business_name: values.business_name, - name: values.business_name, - npwp: values.npwp, - }; - isUpdated = await odooApi( - 'PUT', - `/api/v1/partner/${auth.parentId}`, - dataAlamat - ); + if (auth.company) { + if (auth?.partnerId == id) { + dataAlamat = { + id_user: auth.partnerId, + alamat_lengkap_text: values.alamat_wajib_pajak, + street: values.street, + }; + isUpdated = await odooApi( + 'PUT', + `/api/v1/partner/${auth.parentId}`, + dataAlamat + ); + } } // if (isUpdated?.id) { - if (address?.id && isUpdated?.id) { + if (address?.id && auth.company ? isUpdated?.id : true) { toast.success('Berhasil mengubah alamat'); router.back(); } else { diff --git a/src/lib/transaction/api/transactionsApi.js b/src/lib/transaction/api/transactionsApi.js index f4e36e6f..5ea2b5b0 100644 --- a/src/lib/transaction/api/transactionsApi.js +++ b/src/lib/transaction/api/transactionsApi.js @@ -3,6 +3,9 @@ import { getAuth } from '@/core/utils/auth' const transactionsApi = async ({ query }) => { const auth = getAuth() + if (!auth) { + return null + } const dataTransactions = await odooApi( 'GET', `/api/v1/partner/${auth.partnerId}/sale_order?${query}` diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 6077c192..ac925b4e 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,21 +1,19 @@ -import dynamic from 'next/dynamic'; -import { useEffect, useRef, useState } from 'react'; import { HeroBannerSkeleton } from '@/components/skeleton/BannerSkeleton'; import { PopularProductSkeleton } from '@/components/skeleton/PopularProductSkeleton'; +import odooApi from '@/core/api/odooApi'; import Seo from '@/core/components/Seo'; import DelayRender from '@/core/components/elements/DelayRender/DelayRender'; import DesktopView from '@/core/components/views/DesktopView'; import MobileView from '@/core/components/views/MobileView'; import { FlashSaleSkeleton } from '@/lib/flashSale/skeleton/FlashSaleSkeleton'; -import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBrandSkeleton'; import BannerPromoSkeleton from '@/lib/home/components/Skeleton/BannerPromoSkeleton'; -import PromotinProgram from '@/lib/promotinProgram/components/HomePage'; +import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBrandSkeleton'; +import dynamic from 'next/dynamic'; +import { useEffect, useRef, useState } from 'react'; +import { getAuth } from '~/libs/auth'; import PagePopupIformation from '~/modules/popup-information'; // need change to dynamic and ssr : false import CategoryPilihan from '../lib/home/components/CategoryPilihan'; -import odooApi from '@/core/api/odooApi'; -import { getAuth } from '~/libs/auth'; // import { getAuth } from '~/libs/auth'; -import useProductDetail from '~/modules/product-detail/stores/useProductDetail'; const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout'),{ssr: false} @@ -55,14 +53,14 @@ const ProgramPromotion = dynamic(() => ); const BannerSection = dynamic(() => - import('@/lib/home/components/BannerSection'), {ssr: false} + import('@/lib/home/components/BannerSection') ); const CategoryHomeId = dynamic(() => import('@/lib/home/components/CategoryHomeId'), {ssr: false} ); const CategoryDynamic = dynamic(() => - import('@/lib/home/components/CategoryDynamic'), {ssr: false} + import('@/lib/home/components/CategoryDynamic'), {ssr : false} ); const CategoryDynamicMobile = dynamic(() => |
