From ee4297280c1305c7e03bedd4df63ccf136c28c6c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 24 Jan 2023 15:54:48 +0700 Subject: Merapihkan struktur folder --- src/pages/shop/brands.js | 79 ---------------------------------------- src/pages/shop/brands/[slug].js | 16 ++++---- src/pages/shop/brands/index.js | 79 ++++++++++++++++++++++++++++++++++++++++ src/pages/shop/cart.js | 26 ++++++------- src/pages/shop/checkout.js | 30 +++++++-------- src/pages/shop/product/[slug].js | 22 +++++------ src/pages/shop/search.js | 14 +++---- 7 files changed, 133 insertions(+), 133 deletions(-) delete mode 100644 src/pages/shop/brands.js create mode 100644 src/pages/shop/brands/index.js (limited to 'src/pages/shop') diff --git a/src/pages/shop/brands.js b/src/pages/shop/brands.js deleted file mode 100644 index d82fc31d..00000000 --- a/src/pages/shop/brands.js +++ /dev/null @@ -1,79 +0,0 @@ -import Header from "../../components/Header"; -import apiOdoo from "../../helpers/apiOdoo"; -import InfiniteScroll from "react-infinite-scroll-component"; -import { useEffect, useState } from "react"; -import Spinner from "../../components/Spinner"; -import Layout from "../../components/Layout"; -import ManufactureCard from "../../components/ManufactureCard"; -import Footer from "../../components/Footer"; - -export async function getServerSideProps() { - let initialManufactures = await apiOdoo('GET', '/api/v1/manufacture?limit=31'); - return {props: {initialManufactures}}; -} - -export default function Brands({ initialManufactures }) { - const [manufactures, setManufactures] = useState(initialManufactures.manufactures); - const [hasMoreManufacture, setHasMoreManufacture] = useState(true); - const [manufactureStartwith, setManufactureStartWith] = useState(''); - - const alpha = Array.from(Array(26)).map((e, i) => i + 65); - const alphabets = alpha.map((x) => String.fromCharCode(x)); - - const getMoreManufactures = async () => { - const name = manufactureStartwith != '' ? `${manufactureStartwith}%` : ''; - const result = await apiOdoo('GET', `/api/v1/manufacture?limit=30&offset=${manufactures.length}&name=${name}`); - setHasMoreManufacture(manufactures.length + 30 < result.manufacture_total) - setManufactures((manufactures) => [...manufactures, ...result.manufactures]); - }; - - const filterManufactureStartWith = (character) => { - setManufactures([]); - if (manufactureStartwith == character) { - setManufactureStartWith(''); - } else { - setManufactureStartWith(character); - } - }; - - useEffect(() => { - getMoreManufactures(); - }, [manufactureStartwith]); - - return ( - <> -
- -
-

Semua Brand di Indoteknik

-
- {alphabets.map((alphabet, index) => ( - - ))} -
- - -
- } - > - {manufactures?.map((manufacture, index) => ( - manufacture.name ? ( - - ) : '' - ))} - - - -