Skip to content

Commit 4b21c27

Browse files
committed
fix: add client-side filtering for categories and products in listboxes
1 parent 1e56deb commit 4b21c27

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

resources/assets/editor/components/CategoryListbox.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ const { channel, locale, getCategories } = useState();
99
const model = defineModel<Category | null>();
1010
const search = ref('');
1111
12-
const categories = computed(() => getCategories());
12+
const categories = computed(() => {
13+
const allCategories = getCategories();
14+
if (!search.value) {
15+
return allCategories;
16+
}
17+
const searchLower = search.value.toLowerCase();
18+
return allCategories.filter(category =>
19+
category.name.toLowerCase().includes(searchLower)
20+
);
21+
});
1322
1423
const { isFetching, execute } = fetchCategories();
1524

resources/assets/editor/components/ProductListbox.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ const { channel, locale, getProducts } = useState();
99
const model = defineModel<Product | null>();
1010
const search = ref('');
1111
12-
const products = computed(() => getProducts());
12+
const products = computed(() => {
13+
const allProducts = getProducts();
14+
if (!search.value) {
15+
return allProducts;
16+
}
17+
const searchLower = search.value.toLowerCase();
18+
return allProducts.filter(product =>
19+
product.name.toLowerCase().includes(searchLower)
20+
);
21+
});
1322
1423
const { isFetching, execute } = fetchProducts();
1524

0 commit comments

Comments
 (0)