From f99e0aba70efad0deb907d8e27f09fc9f527c8a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Feb 2023 17:07:50 +0700 Subject: Refactor --- src/components/auth/WithAuth.js | 20 -- src/components/elements/Alert.js | 19 -- src/components/elements/BottomPopup.js | 25 -- src/components/elements/ConfirmAlert.js | 27 --- src/components/elements/DescriptionRow.js | 10 - src/components/elements/Disclosure.js | 14 -- src/components/elements/Fields.js | 21 -- src/components/elements/Filter.js | 176 -------------- src/components/elements/Image.js | 17 -- src/components/elements/LineDivider.js | 7 - src/components/elements/Link.js | 13 -- src/components/elements/Pagination.js | 58 ----- src/components/elements/ProgressBar.js | 25 -- src/components/elements/Skeleton.js | 48 ---- src/components/elements/Spinner.js | 13 -- src/components/layouts/AppBar.js | 47 ---- src/components/layouts/Footer.js | 91 -------- src/components/layouts/Header.js | 253 --------------------- src/components/layouts/Layout.js | 20 -- src/components/manufactures/ManufactureCard.js | 18 -- src/components/products/ProductCard.js | 69 ------ src/components/products/ProductCategories.js | 62 ----- src/components/products/ProductSimilar.js | 25 -- src/components/products/ProductSlider.js | 39 ---- src/components/transactions/TransactionDetail.js | 67 ------ .../transactions/TransactionStatusBadge.js | 45 ---- src/components/variants/VariantCard.js | 92 -------- src/components/variants/VariantGroupCard.js | 31 --- 28 files changed, 1352 deletions(-) delete mode 100644 src/components/auth/WithAuth.js delete mode 100644 src/components/elements/Alert.js delete mode 100644 src/components/elements/BottomPopup.js delete mode 100644 src/components/elements/ConfirmAlert.js delete mode 100644 src/components/elements/DescriptionRow.js delete mode 100644 src/components/elements/Disclosure.js delete mode 100644 src/components/elements/Fields.js delete mode 100644 src/components/elements/Filter.js delete mode 100644 src/components/elements/Image.js delete mode 100644 src/components/elements/LineDivider.js delete mode 100644 src/components/elements/Link.js delete mode 100644 src/components/elements/Pagination.js delete mode 100644 src/components/elements/ProgressBar.js delete mode 100644 src/components/elements/Skeleton.js delete mode 100644 src/components/elements/Spinner.js delete mode 100644 src/components/layouts/AppBar.js delete mode 100644 src/components/layouts/Footer.js delete mode 100644 src/components/layouts/Header.js delete mode 100644 src/components/layouts/Layout.js delete mode 100644 src/components/manufactures/ManufactureCard.js delete mode 100644 src/components/products/ProductCard.js delete mode 100644 src/components/products/ProductCategories.js delete mode 100644 src/components/products/ProductSimilar.js delete mode 100644 src/components/products/ProductSlider.js delete mode 100644 src/components/transactions/TransactionDetail.js delete mode 100644 src/components/transactions/TransactionStatusBadge.js delete mode 100644 src/components/variants/VariantCard.js delete mode 100644 src/components/variants/VariantGroupCard.js (limited to 'src/components') diff --git a/src/components/auth/WithAuth.js b/src/components/auth/WithAuth.js deleted file mode 100644 index ef975873..00000000 --- a/src/components/auth/WithAuth.js +++ /dev/null @@ -1,20 +0,0 @@ -import { getAuth } from "@/core/utils/auth"; -import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; - -const WithAuth = ({ children }) => { - const router = useRouter(); - const [response, setResponse] = useState(<>); - - useEffect(() => { - if (!getAuth()) { - router.replace('/login'); - } else { - setResponse(children); - } - }, [children, router]); - - return response; -} - -export default WithAuth; \ No newline at end of file diff --git a/src/components/elements/Alert.js b/src/components/elements/Alert.js deleted file mode 100644 index 914d1590..00000000 --- a/src/components/elements/Alert.js +++ /dev/null @@ -1,19 +0,0 @@ -const Alert = ({ children, className, type }) => { - let typeClass = ''; - switch (type) { - case 'info': - typeClass = ' bg-blue-100 text-blue-900 border-blue-400 ' - break; - case 'success': - typeClass = ' bg-green-100 text-green-900 border-green-400 ' - break; - case 'warning': - typeClass = ' bg-yellow-100 text-yellow-900 border-yellow-400 ' - break; - } - return ( -
{children}
- ); -} - -export default Alert; \ No newline at end of file diff --git a/src/components/elements/BottomPopup.js b/src/components/elements/BottomPopup.js deleted file mode 100644 index c1a56e10..00000000 --- a/src/components/elements/BottomPopup.js +++ /dev/null @@ -1,25 +0,0 @@ -import CloseIcon from "@/icons/close.svg"; - -const BottomPopup = ({ - active = false, - title, - children, - closePopup = () => {} -}) => { - return ( - <> -
-
-
-

{ title }

- -
- { children } -
- - ); -}; - -export default BottomPopup; \ No newline at end of file diff --git a/src/components/elements/ConfirmAlert.js b/src/components/elements/ConfirmAlert.js deleted file mode 100644 index d33abb89..00000000 --- a/src/components/elements/ConfirmAlert.js +++ /dev/null @@ -1,27 +0,0 @@ -const ConfirmAlert = ({ - title, - caption, - show, - onClose, - onSubmit, - closeText, - submitText -}) => { - return ( - <> - {show && ( -
- )} -
-

{title}

-

{caption}

-
- - -
-
- - ); -}; - -export default ConfirmAlert; \ No newline at end of file diff --git a/src/components/elements/DescriptionRow.js b/src/components/elements/DescriptionRow.js deleted file mode 100644 index 7fe9e3a1..00000000 --- a/src/components/elements/DescriptionRow.js +++ /dev/null @@ -1,10 +0,0 @@ -const DescriptionRow = ({ label, children }) => ( -
-

{ label }

-
- { children } -
-
-); - -export default DescriptionRow; \ No newline at end of file diff --git a/src/components/elements/Disclosure.js b/src/components/elements/Disclosure.js deleted file mode 100644 index 1f334be3..00000000 --- a/src/components/elements/Disclosure.js +++ /dev/null @@ -1,14 +0,0 @@ -const { ChevronUpIcon, ChevronDownIcon } = require("@heroicons/react/24/outline"); - -const Disclosure = ({ label, active, onClick }) => ( -
-

{ label }

- { onClick && ( active ? ( - - ) : ( - - ) ) } -
-); - -export default Disclosure; \ No newline at end of file diff --git a/src/components/elements/Fields.js b/src/components/elements/Fields.js deleted file mode 100644 index 586a6a22..00000000 --- a/src/components/elements/Fields.js +++ /dev/null @@ -1,21 +0,0 @@ -import ReactSelect from "react-select"; - -const Select = ({ - field, - ...props -}) => ( - <> - field.onChange(option.value)} - value={field.value ? props.options.find(option => option.value === field.value) : ''} - isDisabled={props.disabled} - {...props} - /> - -); - -export { - Select -}; \ No newline at end of file diff --git a/src/components/elements/Filter.js b/src/components/elements/Filter.js deleted file mode 100644 index f2051ba8..00000000 --- a/src/components/elements/Filter.js +++ /dev/null @@ -1,176 +0,0 @@ -import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; -import BottomPopup from "./BottomPopup"; - -const Filter = ({ - isActive, - closeFilter, - defaultRoute, - defaultPriceFrom, - defaultPriceTo, - defaultCategory, - defaultBrand, - defaultOrderBy, - searchResults, - disableFilter = [] -}) => { - const router = useRouter(); - - const [priceFrom, setPriceFrom] = useState(defaultPriceFrom); - const [priceTo, setPriceTo] = useState(defaultPriceTo); - const [orderBy, setOrderBy] = useState(defaultOrderBy); - const [selectedCategory, setSelectedCategory] = useState(defaultCategory); - const [selectedBrand, setSelectedBrand] = useState(defaultBrand); - const [categories, setCategories] = useState([]); - const [brands, setBrands] = useState([]); - - const filterRoute = () => { - let filterRoute = []; - let filterRoutePrefix = '?'; - if (selectedBrand) filterRoute.push(`brand=${selectedBrand}`); - if (selectedCategory) filterRoute.push(`category=${selectedCategory}`); - if (priceFrom) filterRoute.push(`price_from=${priceFrom}`); - if (priceTo) filterRoute.push(`price_to=${priceTo}`); - if (orderBy) filterRoute.push(`order_by=${orderBy}`); - - if (defaultRoute.includes('?')) filterRoutePrefix = '&'; - if (filterRoute.length > 0) { - filterRoute = filterRoutePrefix + filterRoute.join('&'); - } else { - filterRoute = ''; - } - - return defaultRoute + filterRoute; - } - - useEffect(() => { - const filterCategory = searchResults.facet_counts.facet_fields.category_name_str.filter((category, index) => { - if (index % 2 == 0) { - const productCountInCategory = searchResults.facet_counts.facet_fields.category_name_str[index + 1]; - if (productCountInCategory > 0) return category; - } - }); - setCategories(filterCategory); - - const filterBrand = searchResults.facet_counts.facet_fields.brand_str.filter((brand, index) => { - if (index % 2 == 0) { - const productCountInBrand = searchResults.facet_counts.facet_fields.brand_str[index + 1]; - if (productCountInBrand > 0) return brand; - } - }); - setBrands(filterBrand); - }, [searchResults]); - - const submit = (e) => { - e.preventDefault(); - closeFilter(); - router.push(filterRoute(), undefined, { scroll: false }); - } - - const reset = () => { - setSelectedBrand(''); - setSelectedCategory(''); - setPriceFrom(''); - setPriceTo(''); - setOrderBy(''); - } - - const changeOrderBy = (value) => { - if (orderBy == value) { - setOrderBy(''); - } else { - setOrderBy(value); - } - } - - const sortOptions = [ - { - name: 'Harga Terendah', - value: 'price-asc', - }, - { - name: 'Harga Tertinggi', - value: 'price-desc', - }, - { - name: 'Populer', - value: 'popular', - }, - { - name: 'Ready Stock', - value: 'stock', - }, - ]; - - return ( - <> - -
- {(selectedBrand || selectedCategory || priceFrom || priceTo || orderBy) && ( - - )} - - {!disableFilter.includes('orderBy') && ( -
- -
- {sortOptions.map((sortOption, index) => ( - - ))} -
-
- )} - - {!disableFilter.includes('category') && ( -
- - -
- )} - - {!disableFilter.includes('brand') && ( -
- - -
- )} - - {!disableFilter.includes('price') && ( -
- -
- setPriceFrom(e.target.value)}/> - - setPriceTo(e.target.value)}/> -
-
- )} - -
-
- - ) -}; - -export default Filter; \ No newline at end of file diff --git a/src/components/elements/Image.js b/src/components/elements/Image.js deleted file mode 100644 index 60e249b9..00000000 --- a/src/components/elements/Image.js +++ /dev/null @@ -1,17 +0,0 @@ -import { LazyLoadImage } from "react-lazy-load-image-component" -import "react-lazy-load-image-component/src/effects/opacity.css" - -const Image = ({ ...props }) => { - return ( - - ) -} - -Image.defaultProps = LazyLoadImage.defaultProps - -export default Image \ No newline at end of file diff --git a/src/components/elements/LineDivider.js b/src/components/elements/LineDivider.js deleted file mode 100644 index 4e8c7b52..00000000 --- a/src/components/elements/LineDivider.js +++ /dev/null @@ -1,7 +0,0 @@ -const LineDivider = () => { - return ( -
- ); -}; - -export default LineDivider; \ No newline at end of file diff --git a/src/components/elements/Link.js b/src/components/elements/Link.js deleted file mode 100644 index 065b5c9e..00000000 --- a/src/components/elements/Link.js +++ /dev/null @@ -1,13 +0,0 @@ -import NextLink from "next/link"; - -const Link = ({ children, ...props }) => { - return ( - - {children} - - ) -} - -Link.defaultProps = NextLink.defaultProps - -export default Link \ No newline at end of file diff --git a/src/components/elements/Pagination.js b/src/components/elements/Pagination.js deleted file mode 100644 index ff2a8462..00000000 --- a/src/components/elements/Pagination.js +++ /dev/null @@ -1,58 +0,0 @@ -import Link from "./Link"; - -export default function Pagination({ pageCount, currentPage, url }) { - let firstPage = false; - let lastPage = false; - let dotsPrevPage = false; - let dotsNextPage = false; - let urlParameterPrefix = url.includes('?') ? '&' : '?'; - - return pageCount > 1 && ( -
- {Array.from(Array(pageCount)).map((v, i) => { - let page = i + 1; - let rangePrevPage = currentPage - 2; - let rangeNextPage = currentPage + 2; - let PageComponent = {page}; - let DotsComponent =
...
; - - if (pageCount == 7) { - return PageComponent; - } - - if (currentPage == 1) rangeNextPage += 3; - if (currentPage == 2) rangeNextPage += 2; - if (currentPage == 3) rangeNextPage += 1; - if (currentPage == 4) rangePrevPage -= 1; - if (currentPage == pageCount) rangePrevPage -= 3; - if (currentPage == pageCount - 1) rangePrevPage -= 2; - if (currentPage == pageCount - 2) rangePrevPage -= 1; - if (currentPage == pageCount - 3) rangeNextPage += 1; - - if (page > rangePrevPage && page < rangeNextPage) { - return PageComponent; - } - - if (page == 1 && rangePrevPage >= 1 && !firstPage) { - firstPage = true; - return PageComponent; - } - - if (page == pageCount && rangeNextPage <= pageCount && !lastPage) { - lastPage = true; - return PageComponent; - } - - if (page > currentPage && (pageCount - currentPage) > 1 && !dotsNextPage) { - dotsNextPage = true; - return DotsComponent; - } - - if (page < currentPage && (currentPage - 1) > 1 && !dotsPrevPage) { - dotsPrevPage = true; - return DotsComponent; - } - })} -
- ) -} \ No newline at end of file diff --git a/src/components/elements/ProgressBar.js b/src/components/elements/ProgressBar.js deleted file mode 100644 index 0adedcdf..00000000 --- a/src/components/elements/ProgressBar.js +++ /dev/null @@ -1,25 +0,0 @@ -import { Fragment } from "react"; - -const ProgressBar = ({ current, labels }) => { - return ( -
- {labels.map((label, index) => ( - -
-
- { index + 1 } -
-

{ label }

-
- { index < (labels.length - 1) && ( -
-
-
- ) } -
- ))} -
- ) -} - -export default ProgressBar; \ No newline at end of file diff --git a/src/components/elements/Skeleton.js b/src/components/elements/Skeleton.js deleted file mode 100644 index fbdbc245..00000000 --- a/src/components/elements/Skeleton.js +++ /dev/null @@ -1,48 +0,0 @@ -import ImagePlaceholderIcon from "../../icons/image-placeholder.svg"; - -const SkeletonList = ({ number }) => ( -
- { Array.from(Array(number), (e, i) => ( -
-
-
-
-
-
-
- )) } - Loading... -
-); - -const SkeletonProduct = () => ( -
-
-
- -
-
-
-
-
-
- Loading... -
-
-
- -
-
-
-
-
-
- Loading... -
-
-); - -export { - SkeletonList, - SkeletonProduct -}; \ No newline at end of file diff --git a/src/components/elements/Spinner.js b/src/components/elements/Spinner.js deleted file mode 100644 index 21006ecd..00000000 --- a/src/components/elements/Spinner.js +++ /dev/null @@ -1,13 +0,0 @@ -const Spinner = ({ className }) => { - return ( -
- - Loading... -
- ) -} - -export default Spinner; \ No newline at end of file diff --git a/src/components/layouts/AppBar.js b/src/components/layouts/AppBar.js deleted file mode 100644 index fe74c940..00000000 --- a/src/components/layouts/AppBar.js +++ /dev/null @@ -1,47 +0,0 @@ -import { Bars3Icon, ChevronLeftIcon, HomeIcon, ShoppingCartIcon } from "@heroicons/react/24/outline"; -import Head from "next/head"; -import { useRouter } from "next/router"; -import Link from "../elements/Link"; - -const AppBar = ({ title }) => { - const router = useRouter(); - - const handleBackButtonClick = (event) => { - event.currentTarget.disabled = true; - router.back(); - } - - return ( - <> - - { title } - Indoteknik - -
- {/* --- Start Title */} -
- -

{ title }

-
- {/* --- End Title */} - - {/* --- Start Icons */} -
- - - - - - - - - -
- {/* --- End Icons */} -
- - ); -}; - -export default AppBar; \ No newline at end of file diff --git a/src/components/layouts/Footer.js b/src/components/layouts/Footer.js deleted file mode 100644 index d173a525..00000000 --- a/src/components/layouts/Footer.js +++ /dev/null @@ -1,91 +0,0 @@ -import { - PhoneIcon, - DevicePhoneMobileIcon, - EnvelopeIcon -} from "@heroicons/react/24/outline"; -import Image from "next/image"; -import InstagramIcon from "@/icons/instagram.svg"; -import LinkedinIcon from "@/icons/linkedin.svg"; -import Link from "../elements/Link"; - -export default function Footer() { - return ( -
-
-
-

Kantor Pusat

-

- Jl. Bandengan Utara 85A No. 8-9 RT.3/RW.16, Penjaringan, Kec. Penjaringan -

- -

Layanan Informasi

- - - - -

Panduan Pelanggan

-
- FAQ - Kebijakan Privasi - Pengajuan Tempo - Garansi Produk - Online Quotation - Pengiriman - Pembayaran - Syarat & Ketentuan - -
-
-
-

Jam Operasional

-

- Senin - Jumat: 08:30 - 17:00 -

-

- Sabtu: 08:30 - 14:00 -

- -

Temukan Kami

-
- - -
- -

Pembayaran

-
- BCA Payment - BCA Payment - BCA Payment - BCA Payment - BCA Payment - BCA Payment - BCA Payment - BCA Payment -
- - {/*

Pengiriman

*/} -
-
-
PT. Indoteknik Dotcom Gemilang
-
- ); -} \ No newline at end of file diff --git a/src/components/layouts/Header.js b/src/components/layouts/Header.js deleted file mode 100644 index 23fda642..00000000 --- a/src/components/layouts/Header.js +++ /dev/null @@ -1,253 +0,0 @@ -import Image from "next/image"; -import { Fragment, useCallback, useEffect, useRef, useState } from "react"; -import Head from "next/head"; -import { useRouter } from "next/router"; -import axios from "axios"; -import { - MagnifyingGlassIcon, - Bars3Icon, - ShoppingCartIcon, - ChevronRightIcon, - Cog6ToothIcon, - HeartIcon, - ChevronDownIcon, - ChevronUpIcon -} from "@heroicons/react/24/outline"; - -// Helpers -import { useAuth } from "@/core/utils/auth"; -// Components -import Link from "../elements/Link"; -// Images -import Logo from "@/images/logo.png"; -import greeting from "@/core/utils/greeting"; -import apiOdoo from "@/core/utils/apiOdoo"; - -const menus = [ - { name: 'Semua Brand', href: '/shop/brands' }, - { name: 'Blog Indoteknik', href: '/' }, - { name: 'Tentang Indoteknik', href: '/' }, - { name: 'Pusat Bantuan', href: '/' }, -]; - -export default function Header({ title }) { - const router = useRouter(); - const { q = '' } = router.query; - const [searchQuery, setSearchQuery] = useState(q != '*' ? q : ''); - const [suggestions, setSuggestions] = useState([]); - const searchQueryRef = useRef(); - const [isMenuActive, setIsMenuActive] = useState(false); - const [auth] = useAuth(); - - useEffect(() => { - if (q) { - searchQueryRef.current.blur(); - setSuggestions([]); - }; - }, [q]); - - const clickSuggestion = (value) => { - router.push(`/shop/search?q=${value}`, undefined, { scroll: false }); - }; - - const getSuggestion = useCallback(async () => { - if (searchQuery.trim().length > 0) { - let result = await axios(`${process.env.SELF_HOST}/api/shop/suggest?q=${searchQuery.trim()}`); - setSuggestions(result.data.suggest.mySuggester[searchQuery.trim()].suggestions); - } else { - setSuggestions([]); - } - }, [searchQuery]); - - useEffect(() => { - if (document.activeElement == searchQueryRef.current) getSuggestion(); - }, [getSuggestion]); - - const openMenu = () => setIsMenuActive(true); - const closeMenu = () => setIsMenuActive(false); - - const searchSubmit = (e) => { - e.preventDefault(); - if (searchQuery.length > 0) { - router.push(`/shop/search?q=${searchQuery}`, undefined, { scroll: false }); - } else { - searchQueryRef.current.focus(); - } - } - - const [ isOpenCategory, setOpenCategory ] = useState(false); - const [ categories, setCategories ] = useState([]); - - useEffect(() => { - const loadCategories = async () => { - if (isOpenCategory && categories.length == 0) { - let dataCategories = await apiOdoo('GET', '/api/v1/category/tree'); - dataCategories = dataCategories.map((category) => { - category.childs = category.childs.map((child1Category) => { - return { - ...child1Category, - isOpen: false - } - }) - return { - ...category, - isOpen: false - } - }); - setCategories(dataCategories); - } - } - loadCategories(); - }, [ isOpenCategory, categories ]); - - const toggleCategories = (id = 0) => { - let newCategories = categories.map((category) => { - category.childs = category.childs.map((child1Category) => { - return { - ...child1Category, - isOpen: id == child1Category.id ? !child1Category.isOpen : child1Category.isOpen - } - }) - return { - ...category, - isOpen: id == category.id ? !category.isOpen : category.isOpen - } - }); - setCategories(newCategories); - } - - return ( - <> - - - {title} - - -
-
- { auth && ( - -
-

{ greeting() },

-

{auth.name}

-
-
- -
- - ) } - - { !auth && ( - <> - Masuk - Daftar - - ) } -
-
- { menus.map((menu, index) => ( - - { menu.name } -
- -
- - )) } -
setOpenCategory(!isOpenCategory)}> - Kategori -
- { !isOpenCategory && } - { isOpenCategory && } -
-
- { isOpenCategory && categories.map((category) => ( - -
- - { category.name } - -
toggleCategories(category.id)}> - { !category.isOpen && } - { category.isOpen && } -
-
- { category.isOpen && category.childs.map((child1Category) => ( - -
- - { child1Category.name } - - { child1Category.childs.length > 0 && ( -
toggleCategories(child1Category.id)}> - { !child1Category.isOpen && } - { child1Category.isOpen && } -
- ) } -
- { child1Category.isOpen && child1Category.childs.map((child2Category) => ( - - { child2Category.name } - - )) } -
- )) } -
- )) } -
-
- - -
-
- - Logo Indoteknik - -
- - - - - - - -
-
-
- setSearchQuery(e.target.value)} - onFocus={getSuggestion} - value={searchQuery} - className="form-input rounded-r-none border-r-0 focus:border-gray_r-7" - placeholder="Ketikan nama, merek, part number" - autoComplete="off" - /> - - - - {suggestions.length > 1 && ( -
- {suggestions.map((suggestion, index) => ( -

clickSuggestion(suggestion.term)} className="w-full p-2" key={index}>{suggestion.term}

- ))} -
- )} -
-
- - {suggestions.length > 1 && ( -
setSuggestions([])}>
- )} - - ) -} \ No newline at end of file diff --git a/src/components/layouts/Layout.js b/src/components/layouts/Layout.js deleted file mode 100644 index fd507963..00000000 --- a/src/components/layouts/Layout.js +++ /dev/null @@ -1,20 +0,0 @@ -import { motion } from 'framer-motion'; - -export default function Layout({ children, ...pageProps }) { - const transition = { - ease: 'easeOut', - duration: 0.3 - }; - - return children && ( - - {children} - - ); -} \ No newline at end of file diff --git a/src/components/manufactures/ManufactureCard.js b/src/components/manufactures/ManufactureCard.js deleted file mode 100644 index 73a96902..00000000 --- a/src/components/manufactures/ManufactureCard.js +++ /dev/null @@ -1,18 +0,0 @@ -import { createSlug } from "@/core/utils/slug"; -import Image from "../elements/Image"; -import Link from "../elements/Link"; - -export default function ManufactureCard({ data }) { - const manufacture = data; - return ( - - {manufacture.logo ? ( - {manufacture.name} - ) : manufacture.name} - - ); -} \ No newline at end of file diff --git a/src/components/products/ProductCard.js b/src/components/products/ProductCard.js deleted file mode 100644 index c79a4900..00000000 --- a/src/components/products/ProductCard.js +++ /dev/null @@ -1,69 +0,0 @@ -import Link from "../elements/Link"; -import currencyFormat from "@/core/utils/currencyFormat"; -import { createSlug } from "@/core/utils/slug"; -import { ChevronRightIcon } from "@heroicons/react/20/solid"; -import Image from "../elements/Image"; - - -export default function ProductCard({ - data, - simpleProductTitleLine = false -}) { - let product = data; - return ( -
- - {product.name} - {product.variant_total > 1 ? ( -
{product.variant_total} Varian
- ) : ''} - -
-
- {typeof product.manufacture.name !== "undefined" ? ( - {product.manufacture.name} - ) : ( - - - )} - - {product.name} - -
-
- {product.lowest_price.discount_percentage > 0 ? ( -
-

{currencyFormat(product.lowest_price.price)}

- {product.lowest_price.discount_percentage}% -
- ) : ''} - - {product.lowest_price.price_discount > 0 ? ( -

- {currencyFormat(product.lowest_price.price_discount)} -

- ) : ( - - Tanya Harga - - )} - - {product.stock_total > 0 ? ( -
-
Ready Stock
-
{product.stock_total > 5 ? '> 5' : '< 5'}
-
- ) : ''} -
-
-
- ) -} \ No newline at end of file diff --git a/src/components/products/ProductCategories.js b/src/components/products/ProductCategories.js deleted file mode 100644 index 3b671f29..00000000 --- a/src/components/products/ProductCategories.js +++ /dev/null @@ -1,62 +0,0 @@ -import { useEffect, useState } from "react"; -import ProductSlider from "./ProductSlider"; -import apiOdoo from "@/core/utils/apiOdoo"; -import { LazyLoadComponent } from "react-lazy-load-image-component"; -import { SkeletonProduct } from "../elements/Skeleton"; - -const ProductCategory = ({ id }) => { - const [ content, setContent ] = useState(null); - - useEffect(() => { - const loadContent = async () => { - if (!content) { - const dataContent = await apiOdoo('GET', `/api/v1/categories_homepage?id=${id}`); - setContent(dataContent[0]); - } - } - loadContent(); - }, [id, content]); - - return ( -
- { content ? ( - - ) : } -
- ); -} - -export default function ProductCategories() { - const [ contentIds, setContentIds ] = useState([]); - - useEffect(() => { - const getContentIds = async () => { - if (contentIds.length == 0) { - const dataContentIds = await apiOdoo('GET', '/api/v1/categories_homepage/ids'); - setContentIds(dataContentIds); - } - } - getContentIds(); - }, [ contentIds ]); - - return ( -
- { contentIds.map((contentId) => ( - } key={contentId}> - - - )) } -
- ) -} \ No newline at end of file diff --git a/src/components/products/ProductSimilar.js b/src/components/products/ProductSimilar.js deleted file mode 100644 index 9e2292cb..00000000 --- a/src/components/products/ProductSimilar.js +++ /dev/null @@ -1,25 +0,0 @@ -import apiOdoo from '@/core/utils/apiOdoo'; -import { useEffect, useState } from 'react'; -import ProductSlider from './ProductSlider'; - -export default function ProductSimilar({ productId }) { - const [similarProducts, setSimilarProducts] = useState(null); - - useEffect(() => { - const getSimilarProducts = async () => { - if (productId && !similarProducts) { - const dataSimilarProducts = await apiOdoo('GET', `/api/v1/product/${productId}/similar?limit=20`); - setSimilarProducts(dataSimilarProducts); - } - } - getSimilarProducts(); - }, [productId, similarProducts]); - - - return ( -
-

Kamu Mungkin Juga Suka

- -
- ) -} \ No newline at end of file diff --git a/src/components/products/ProductSlider.js b/src/components/products/ProductSlider.js deleted file mode 100644 index 662a6511..00000000 --- a/src/components/products/ProductSlider.js +++ /dev/null @@ -1,39 +0,0 @@ -import { Swiper, SwiperSlide } from "swiper/react"; -import ProductCard from "./ProductCard"; -import "swiper/css"; -import Image from "../elements/Image"; -import Link from "../elements/Link"; -import { SkeletonProduct } from "../elements/Skeleton"; -import { useState } from "react"; - -export default function ProductSlider({ - products, - simpleProductTitleLine = false, - bannerMode = false -}) { - const [ activeIndex, setActiveIndex ] = useState(0); - const swiperSliderFirstMove = (swiper) => { - setActiveIndex(swiper.activeIndex); - }; - - return ( - <> - { bannerMode && ( - {products.banner.name} 0 ? 'opacity-0' : 'opacity-100')} /> - ) } - - { bannerMode && ( - - - - ) } - {products?.products?.map((product, index) => ( - - - - ))} - - { !products ? : ''} - - ) -} \ No newline at end of file diff --git a/src/components/transactions/TransactionDetail.js b/src/components/transactions/TransactionDetail.js deleted file mode 100644 index 295a4f9f..00000000 --- a/src/components/transactions/TransactionDetail.js +++ /dev/null @@ -1,67 +0,0 @@ -import { useState } from "react"; -import DescriptionRow from "../elements/DescriptionRow"; -import Disclosure from "../elements/Disclosure"; - -const DetailAddress = ({ address }) => { - const fullAddress = []; - if (address?.street) fullAddress.push(address.street); - if (address?.sub_district?.name) fullAddress.push(address.sub_district.name); - if (address?.district?.name) fullAddress.push(address.district.name); - if (address?.city?.name) fullAddress.push(address.city.name); - return ( -
- { address?.name } - { address?.email || '-' } - { address?.mobile || '-' } - { fullAddress.join(', ') } -
- ); -}; - -const TransactionDetailAddress = ({ transaction }) => { - const [ activeSection, setActiveSection ] = useState({ - purchase: false, - shipping: false, - invoice: false, - }); - - const toggleSection = ( name ) => { - setActiveSection({ - ...activeSection, - [name]: !activeSection[name] - }); - }; - - return ( -
- toggleSection('purchase')} - /> - { activeSection.purchase && ( - - ) } - - toggleSection('shipping')} - /> - { activeSection.shipping && ( - - ) } - - toggleSection('invoice')} - /> - { activeSection.invoice && ( - - ) } -
- ); -}; - -export { TransactionDetailAddress }; \ No newline at end of file diff --git a/src/components/transactions/TransactionStatusBadge.js b/src/components/transactions/TransactionStatusBadge.js deleted file mode 100644 index f94fd3fd..00000000 --- a/src/components/transactions/TransactionStatusBadge.js +++ /dev/null @@ -1,45 +0,0 @@ -const TransactionStatusBadge = ({ status }) => { - let badgeProps = { - className: ['h-fit'], - text: '' - }; - switch (status) { - case 'cancel': - badgeProps.className.push('badge-solid-red'); - badgeProps.text = 'Pesanan Batal' - break; - case 'draft': - badgeProps.className.push('badge-red'); - badgeProps.text = 'Pending Quotation' - break; - case 'waiting': - badgeProps.className.push('badge-yellow'); - badgeProps.text = 'Pesanan diterima' - break; - case 'sale': - badgeProps.className.push('badge-yellow'); - badgeProps.text = 'Pesanan diproses' - break; - case 'shipping': - badgeProps.className.push('badge-green'); - badgeProps.text = 'Pesanan dikirim' - break; - case 'partial_shipping': - badgeProps.className.push('badge-green'); - badgeProps.text = 'Dikirim sebagian' - break; - case 'done': - badgeProps.className.push('badge-solid-green'); - badgeProps.text = 'Pesanan Selesai' - break; - } - badgeProps.className = badgeProps.className.join(' '); - - return ( -
- { badgeProps.text } -
- ) -}; - -export default TransactionStatusBadge; \ No newline at end of file diff --git a/src/components/variants/VariantCard.js b/src/components/variants/VariantCard.js deleted file mode 100644 index a821480c..00000000 --- a/src/components/variants/VariantCard.js +++ /dev/null @@ -1,92 +0,0 @@ -import { createSlug } from "@/core/utils/slug"; -import Image from "../elements/Image"; -import Link from "../elements/Link"; -import currencyFormat from "@/core/utils/currencyFormat"; -import { useRouter } from "next/router"; -import { toast } from "react-hot-toast"; -import { createOrUpdateItemCart } from "@/core/utils/cart"; - -export default function VariantCard({ - data, - openOnClick = true, - buyMore = false -}) { - let product = data; - const router = useRouter(); - - const addItemToCart = () => { - toast.success('Berhasil menambahkan ke keranjang', { duration: 1500 }); - createOrUpdateItemCart(product.id, 1); - return; - }; - - const checkoutItem = () => { - router.push(`/shop/checkout?product_id=${product.id}&qty=${product.quantity}`); - } - - const Card = () => ( -
-
- {product.parent.name} -
-
-

- {product.parent.name} -

-

- {product.code || '-'} - {product.attributes.length > 0 ? ` ・ ${product.attributes.join(', ')}` : ''} -

-
- {product.price.discount_percentage > 0 && ( - <> -

{currencyFormat(product.price.price)}

- {product.price.discount_percentage}% - - )} -

{currencyFormat(product.price.price_discount)}

-
-

- {currencyFormat(product.price.price_discount)} × {product.quantity} Barang -

-

- {currencyFormat(product.quantity * product.price.price_discount)} -

-
-
- ); - - if (openOnClick) { - return ( - <> - - - - { buyMore && ( -
- - -
- ) } - - ); - } - - return ; -} \ No newline at end of file diff --git a/src/components/variants/VariantGroupCard.js b/src/components/variants/VariantGroupCard.js deleted file mode 100644 index 462c63cf..00000000 --- a/src/components/variants/VariantGroupCard.js +++ /dev/null @@ -1,31 +0,0 @@ -import { useState } from "react" -import VariantCard from "./VariantCard" - -export default function VariantGroupCard({ - variants, - ...props -}) { - const [ showAll, setShowAll ] = useState(false) - const variantsToShow = showAll ? variants : variants.slice(0, 2) - - return ( - <> - { variantsToShow?.map((variant, index) => ( - - )) } - { variants.length > 2 && ( - - ) } - - ) -} \ No newline at end of file -- cgit v1.2.3