summaryrefslogtreecommitdiff
path: root/src/lib/category
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-13 10:19:38 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-13 10:19:38 +0700
commit004a9a644aed65d5c02263f19cce8b7c3000f354 (patch)
treec9f3df2e2f841ca35bbf9e107948f710d6066cba /src/lib/category
parent3e11fce63de4b0d99a1e48c9998d6fcfcec13d98 (diff)
<iman> update category
Diffstat (limited to 'src/lib/category')
-rw-r--r--src/lib/category/api/popularProduct.js5
-rw-r--r--src/lib/category/components/Category.jsx38
-rw-r--r--src/lib/category/components/PopularBrand.jsx4
3 files changed, 24 insertions, 23 deletions
diff --git a/src/lib/category/api/popularProduct.js b/src/lib/category/api/popularProduct.js
index e17e0ae5..146c9449 100644
--- a/src/lib/category/api/popularProduct.js
+++ b/src/lib/category/api/popularProduct.js
@@ -1,9 +1,10 @@
-export const fetchPromoItemsSolr = async (category_id_ids) => {
+export const fetchPopulerProductSolr = async (category_id_ids) => {
let sort ='sort=qty_sold_f desc';
try {
const queryParams = new URLSearchParams({ q: category_id_ids });
- const response = await fetch(`/solr/product/select?${queryParams.toString()}&rows=2000&fl=manufacture_name_s,manufacture_id_i,id,display_name_s&${sort}`);
+ const response = await fetch(`/solr/product/select?${queryParams.toString()}&rows=2000&fl=manufacture_name_s,manufacture_id_i,id,display_name_s,qty_sold_f&${sort}`);
+ console.log("response",response)
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx
index b10cb661..374cdf78 100644
--- a/src/lib/category/components/Category.jsx
+++ b/src/lib/category/components/Category.jsx
@@ -37,25 +37,25 @@ const Category = () => {
loadCategories()
}, [])
- 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()
- }, [])
+ // 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()
+ // }, [])
// console.log("categories",categories)
return (
diff --git a/src/lib/category/components/PopularBrand.jsx b/src/lib/category/components/PopularBrand.jsx
index 09c0f8a1..f0b12e2c 100644
--- a/src/lib/category/components/PopularBrand.jsx
+++ b/src/lib/category/components/PopularBrand.jsx
@@ -8,7 +8,7 @@ import Image from 'next/image'
import { ChevronRightIcon } from '@heroicons/react/24/outline'
import useProductSearch from '../../../lib/product/hooks/useProductSearch';
import { SolrResponse } from "~/types/solr";
-import { fetchPromoItemsSolr } from '../api/popularProduct'
+import { fetchPopulerProductSolr } from '../api/popularProduct'
const SOLR_HOST = process.env.SOLR_HOST
@@ -17,7 +17,7 @@ const PopularBrand = ({ category }) => {
const fetchTopBrands = async () => {
try {
- const items = await fetchPromoItemsSolr(`category_id_ids:(${category?.categoryDataIds?.join(' OR ')})`);
+ const items = await fetchPopulerProductSolr(`category_id_ids:(${category?.categoryDataIds?.join(' OR ')})`);
// console.log("id",items)
// Fungsi untuk deduplikasi dan mengambil 12 nama brand teratas
const getTop12UniqueBrands = (prod) => {