diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-02 14:37:13 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-02 14:37:13 +0700 |
| commit | f8abd467d40ce9c98d0b10d436181fc2d9b69986 (patch) | |
| tree | ccad2b42be8a805966bb507e4c54da0ecc018151 | |
| parent | 2e6ce4c69cd15066fb6af35c2d7bf92d4316c9c9 (diff) | |
oprimize code
| -rw-r--r-- | src/core/components/elements/Navbar/NavbarDesktop.jsx | 30 | ||||
| -rw-r--r-- | src/lib/transaction/api/transactionsApi.js | 3 | ||||
| -rw-r--r-- | src/pages/index.jsx | 16 |
3 files changed, 22 insertions, 27 deletions
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/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(() => |
