diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-04 13:02:36 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-04 13:02:36 +0700 |
| commit | 4e8fc0f09765cd90773fcef0cb483ca1872f2883 (patch) | |
| tree | b83781751bb4dfd275ba21ebf2b1221cc4b884af | |
| parent | 61b5c173a37edf867a764cc965d950182b31b5b3 (diff) | |
no message
| -rw-r--r-- | next.config.js | 8 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | src/components/elements/Image.js | 21 | ||||
| -rw-r--r-- | src/pages/index.js | 1 | ||||
| -rw-r--r-- | src/pages/shop/product/[slug].js | 9 |
5 files changed, 26 insertions, 14 deletions
diff --git a/next.config.js b/next.config.js index 608cbb45..59ab4116 100644 --- a/next.config.js +++ b/next.config.js @@ -15,6 +15,14 @@ const nextConfig = { locales: ['id'], defaultLocale: 'id', }, + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'erp.indoteknik.com' + } + ] + }, env: { SELF_HOST: 'http://localhost:3000', // ODOO_HOST: 'http://35.219.117.154:8069', diff --git a/package.json b/package.json index 645510b2..da31e920 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "react-hook-form": "^7.42.1", "react-hot-toast": "^2.4.0", "react-infinite-scroll-component": "^6.1.0", + "react-lazy-load": "^4.0.1", "react-lazy-load-image-component": "^1.5.5", "react-select": "^5.7.0", "swiper": "^8.4.4", diff --git a/src/components/elements/Image.js b/src/components/elements/Image.js index e85237ed..26e85bee 100644 --- a/src/components/elements/Image.js +++ b/src/components/elements/Image.js @@ -1,13 +1,18 @@ -import { LazyLoadImage } from "react-lazy-load-image-component"; -import 'react-lazy-load-image-component/src/effects/opacity.css'; +import NextImage from "next/image"; +import { LazyLoadComponent } from "react-lazy-load-image-component"; export default function Image({ src, alt, className = "" }) { return ( - <LazyLoadImage - effect="opacity" - src={src || '/images/noimage.jpeg'} - alt={src ? alt : 'Image Not Found - Indoteknik'} - className={className} - /> + <LazyLoadComponent> + <div className="w-full h-full flex justify-center items-center"> + <NextImage + src={src || '/images/noimage.jpeg'} + alt={src ? alt : 'Image Not Found - Indoteknik'} + width={512} + height={512} + className={className} + /> + </div> + </LazyLoadComponent> ); }
\ No newline at end of file diff --git a/src/pages/index.js b/src/pages/index.js index 56f0ff1c..ca501ecc 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -17,7 +17,6 @@ import ManufactureCard from "@/components/manufactures/ManufactureCard"; import Footer from "@/components/layouts/Footer"; import Image from "@/components/elements/Image"; import ProductCategories from "@/components/products/ProductCategories"; -import { LazyLoadComponent } from "react-lazy-load-image-component"; export async function getServerSideProps() { const heroBanners = await apiOdoo('GET', `/api/v1/banner?type=index-a-1`); diff --git a/src/pages/shop/product/[slug].js b/src/pages/shop/product/[slug].js index c3d34806..60849264 100644 --- a/src/pages/shop/product/[slug].js +++ b/src/pages/shop/product/[slug].js @@ -5,7 +5,6 @@ import Header from "@/components/layouts/Header"; import apiOdoo from "@/core/utils/apiOdoo"; import { createSlug, getIdFromSlug } from "@/core/utils/slug"; import currencyFormat from "@/core/utils/currencyFormat"; -import ProductSlider from "@/components/products/ProductSlider"; import Layout from "@/components/layouts/Layout"; import { createOrUpdateItemCart } from "@/core/utils/cart"; import toast from "react-hot-toast"; @@ -15,13 +14,13 @@ import LineDivider from "@/components/elements/LineDivider"; import { HeartIcon as HeartIconSolid } from "@heroicons/react/24/solid"; import { useAuth } from "@/core/utils/auth"; import { HeartIcon } from "@heroicons/react/24/outline"; -import { LazyLoadComponent } from "react-lazy-load-image-component"; +import LazyLoad from "react-lazy-load"; import ProductSimilar from "@/components/products/ProductSimilar"; export async function getServerSideProps( context ) { const { slug } = context.query; let product = await apiOdoo('GET', '/api/v1/product/' + getIdFromSlug(slug)); - if (product.length == 1) { + if (product?.length == 1) { product = product[0]; product.description = product.description.replaceAll('<p>', '||p||'); product.description = product.description.replaceAll('</p>', '||/p||'); @@ -274,9 +273,9 @@ export default function ProductDetail({ product }) { <LineDivider /> - <LazyLoadComponent> + <LazyLoad> <ProductSimilar productId={getIdFromSlug(slug || '')} /> - </LazyLoadComponent> + </LazyLoad> <Footer /> </Layout> |
