summaryrefslogtreecommitdiff
path: root/src/lib/product
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/product')
-rw-r--r--src/lib/product/components/ProductSearch.jsx34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index 07398795..b799d533 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -52,6 +52,24 @@ const ProductSearch = ({
const [orderBy, setOrderBy] = useState(router.query?.orderBy);
if (defaultBrand) query.brand = defaultBrand.toLowerCase();
const dataIdCategories = []
+
+ useEffect(() => {
+ const checkIfPenawaran = async () => {
+ if (router.asPath.includes('penawaran')) {
+ query = {
+ ...query,
+ fq: [
+ `-flashsale_id_i:${router.query.penawaran}`,
+ `flashsale_price_f:[1 TO *]`
+ ],
+ orderBy: 'flashsale-discount-desc'
+ };
+ setOrderBy('flashsale-discount-desc')
+ }
+ };
+ checkIfPenawaran();
+ }, [router]);
+
useEffect(() => {
if(prefixUrl.includes('category')){
const loadProduct = async () => {
@@ -142,22 +160,6 @@ const ProductSearch = ({
}
}, [prefixUrl,dataCategoriesProduct, query, finalQuery]);
- useEffect(() => {
- const checkIfPenawaran = async () => {
- if (router.asPath.includes('penawaran')) {
- query = {
- ...query,
- fq: [
- `-flashsale_id_i:${router.query.penawaran}`,
- `flashsale_price_f:[1 TO *]`
- ],
- orderBy: 'flashsale-discount-desc'
- };
- setOrderBy('flashsale-discount-desc')
- }
- };
- checkIfPenawaran();
- }, [router]);
const { productSearch } = useProductSearch({
query: queryFinal,