From b30e6a53d660f9ccbc0ded640c2a1dc5df673ff2 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 2 Sep 2024 16:43:25 +0700 Subject: update fetch data --- src/lib/promo/hooks/usePromotionSearch.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/lib/promo/hooks/usePromotionSearch.js (limited to 'src/lib/promo/hooks/usePromotionSearch.js') 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 -- cgit v1.2.3