summaryrefslogtreecommitdiff
path: root/src/lib/promo/hooks/usePromotionSearch.js
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-23 09:22:29 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-23 09:22:29 +0700
commitc13bb5c6f78032695b24cf8a6c23942eb465c6d5 (patch)
treee48c1ab39a61fd5702f578fbfdb7a7375cc1ce43 /src/lib/promo/hooks/usePromotionSearch.js
parent870bede9df9920b23f2e5cb771ff5ae6448e3ac7 (diff)
parent4bd29979c34c1ec3b31dd384829b008eb726769c (diff)
Merge branch 'Feature/new-register' into Feature/switch-account
Diffstat (limited to 'src/lib/promo/hooks/usePromotionSearch.js')
-rw-r--r--src/lib/promo/hooks/usePromotionSearch.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/promo/hooks/usePromotionSearch.js b/src/lib/promo/hooks/usePromotionSearch.js
new file mode 100644
index 00000000..1a194646
--- /dev/null
+++ b/src/lib/promo/hooks/usePromotionSearch.js
@@ -0,0 +1,15 @@
+import { useQuery } from 'react-query'
+import productSearchApi from '../api/productSearchApi'
+import _ from 'lodash-contrib'
+
+const usePromotionSearch = ({ query, operation }) => {
+ const queryString = _.toQuery(query)
+ const fetchProductSearch = async () => await productSearchApi({ query: queryString , operation : operation})
+ const productSearch = useQuery(`promoSearch-${queryString}`, fetchProductSearch)
+
+ return {
+ productSearch
+ }
+}
+
+export default usePromotionSearch