import odooApi from '@/core/api/odooApi' import Link from '@/core/components/elements/Link/Link' import DesktopView from '@/core/components/views/DesktopView' import { createSlug } from '@/core/utils/slug' import { ChevronRightIcon } from '@heroicons/react/24/outline' import Image from 'next/image' import { useEffect, useState } from 'react' const Category = () => { const [categories, setCategories] = useState([]) const [openCategories, setOpenCategory] = useState([]); useEffect(() => { const loadCategories = async () => { let dataCategories = await odooApi('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() }, []) return (
{categories?.map((category) => (
{category.name}
{category.childs.map((child1Category) => (
{child1Category.name}
{child1Category.childs.map((child2Category, index) => ( (index < 4) && ( {child2Category.name} ) ))} {child1Category.childs.length > 5 && (

Lihat Semua

)}
))}
{category.childs.map((brand, index) => ( (index < 8 ) && (
) ))}
{category.childs.length > 8 && (

Lihat Semua Brand

)}
))}
) } export default Category