feat: add filters to mainpage

This commit is contained in:
2025-10-03 00:26:13 +03:00
parent 023acee68f
commit 1e2a9bc705
168 changed files with 5367 additions and 662 deletions

View File

@@ -8,4 +8,58 @@
<script setup>
import ProductsList from "@/components/ProductsList.vue";
import SearchInput from "@/components/SearchInput.vue";
import {onMounted} from "vue";
import {useRoute} from "vue-router";
import {useProductsStore} from "@/stores/ProductsStore.js";
const route = useRoute();
const productsStore = useProductsStore();
const categoryId = route.params.category_id ?? null;
onMounted(async () => {
console.debug("Load products for category: ", categoryId);
if (productsStore.filtersFullUrl === route.fullPath) {
await productsStore.loadProducts(productsStore.filters ?? {
operand: "AND",
rules: {
RULE_PRODUCT_CATEGORIES: {
criteria: {
product_category_ids: {
type: "product_categories",
params: {
operator: "contains",
value: [
categoryId
]
}
}
}
}
},
});
} else {
productsStore.reset();
productsStore.filtersFullUrl = route.fullPath;
await productsStore.loadProducts({
operand: "AND",
rules: {
RULE_PRODUCT_CATEGORIES: {
criteria: {
product_category_ids: {
type: "product_categories",
params: {
operator: "contains",
value: [
categoryId
]
}
}
}
}
},
});
}
});
</script>