feat: add public search controls
Quality / test (push) Canceled after 0s

Add public category lookup options, allowlisted sort ordering, URL-backed catalog controls, and strict search route validation with regression tests.
This commit is contained in:
2026-09-09 01:44:28 -04:00
parent 67ce29a93e
commit f4e4685ecc
10 changed files with 71 additions and 12 deletions
+8 -1
View File
@@ -1,7 +1,8 @@
const apiBaseUrl = import.meta.env?.VITE_API_BASE_URL ?? '/api/v1';
export async function searchCatalog({ query = '', category = '', minPriceMinor, maxPriceMinor, page = 1, limit = 20 } = {}) {
export async function searchCatalog({ query = '', category = '', minPriceMinor, maxPriceMinor, sort = 'recent', page = 1, limit = 20 } = {}) {
const params = new URLSearchParams({ query, page: String(page), limit: String(limit) });
if (sort !== 'recent') params.set('sort', sort);
if (category) params.set('category', category);
if (typeof minPriceMinor === 'number') params.set('minPriceMinor', String(minPriceMinor));
if (typeof maxPriceMinor === 'number') params.set('maxPriceMinor', String(maxPriceMinor));
@@ -15,6 +16,12 @@ export async function searchCatalog({ query = '', category = '', minPriceMinor,
return payload.data;
}
export async function listPublicCategories() {
const response = await fetch(`${apiBaseUrl}/public/lookups/categories`);
if (!response.ok) throw new Error('Categories are unavailable.');
return (await response.json()).data;
}
export async function getPublicListing(id) {
const response = await fetch(`${apiBaseUrl}/public/listings/${encodeURIComponent(id)}`);