From 065a0e341cc42443fe5e2380e078983b3c66f111 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Mon, 25 Sep 2023 16:48:25 +0700
Subject: migrasi get brand di homepage dan page all brand ke solr

---
 src/lib/brand/components/Brands.jsx | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

(limited to 'src/lib/brand/components/Brands.jsx')

diff --git a/src/lib/brand/components/Brands.jsx b/src/lib/brand/components/Brands.jsx
index c7483e40..ccdd134d 100644
--- a/src/lib/brand/components/Brands.jsx
+++ b/src/lib/brand/components/Brands.jsx
@@ -2,6 +2,7 @@ import odooApi from '@/core/api/odooApi'
 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)
@@ -13,13 +14,22 @@ const Brands = () => {
 
   const loadBrand = useCallback(async () => {
     setIsLoading(true)
-    const name = startWith ? `${startWith}%` : ''
-    const result = await odooApi(
+    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
+    let result = null
+    if (name) {
+      result = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=${name}`)
+    } else {
+      result = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands`)
+    }
     setIsLoading(false)
-    setManufactures((manufactures) => [...manufactures, ...result.manufactures])
+    setManufactures((manufactures) => [...manufactures, ...result.data])
   }, [startWith])
 
   const toggleStartWith = (alphabet) => {
-- 
cgit v1.2.3

