import { useCallback, useEffect, useState } from 'react' import BrandCard from './BrandCard' import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' import axios from 'axios' const Brands = () => { const alpha = Array.from(Array(26)).map((e, i) => i + 65) const alphabets = alpha.map((x) => String.fromCharCode(x)) const [isLoading, setIsLoading] = useState(true) const [startWith, setStartWith] = useState(null) const [manufactures, setManufactures] = useState([]) const loadBrand = useCallback(async () => { setIsLoading(true) const name = startWith ? `${startWith}*` : '' //Get brand from odoo /*const result = await odooApi( 'GET', `/api/v1/manufacture?limit=0&offset=${manufactures.length}&name=${name}` )*/ // Change get brands from solr const result = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=${name}`) setIsLoading(false) setManufactures((manufactures) => [...result.data]) }, [startWith]) const toggleStartWith = (alphabet) => { setManufactures([]) if (alphabet == startWith) { setStartWith(null) return } setStartWith(alphabet) } useEffect(() => { loadBrand() }, [loadBrand]) if (isLoading) { return ( <>
) } return (

Semua Brand di Indoteknik

{alphabets.map((alphabet, index) => ( ))}
{manufactures?.map( (manufacture, index) => manufacture.name && )}
) } export default Brands