diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-18 17:24:36 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-18 17:24:36 +0700 |
| commit | 0840f5ccc7493dfa091508db84bad8a21e073268 (patch) | |
| tree | 426b6bf35e332f3d33e06252320cb2bbcea446f6 /src/lib/home/hooks | |
| parent | 59cba752134fa41063956569a3f4e7ed2a6d2537 (diff) | |
<iman> update category-management
Diffstat (limited to 'src/lib/home/hooks')
| -rw-r--r-- | src/lib/home/hooks/useCategoryManagement.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/home/hooks/useCategoryManagement.js b/src/lib/home/hooks/useCategoryManagement.js new file mode 100644 index 00000000..7c01df6e --- /dev/null +++ b/src/lib/home/hooks/useCategoryManagement.js @@ -0,0 +1,34 @@ +export const fetchProductManagementSolr = async () => { + try { + const queryParams = new URLSearchParams({q: 'type_value_s:bundling'}) + const response = await fetch(`/solr/product_category_management/query?q=*:*&q.op=OR&indent=true`); + // console.log("response", response) + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + // console.log("data",data) + const dataManagement = await map(data.response.docs); + // console.log("dataManagement",dataManagement) + return dataManagement; + } catch (error) { + console.error("Error fetching promotion data:", error); + return []; + } +}; + +const map = async (promotions) => { + const result = []; + for (const promotion of promotions) { + const data = { + id: promotion.id, + category_id: promotion.category_id_i, + name: promotion.name_s, + sequence: promotion.sequence_i, + image: promotion.image_s, + category_id2: JSON.parse(promotion.category_id2_s), + }; + result.push(data); + } + return result; +}; |
