feat: add public listing detail web flow

This commit is contained in:
2026-09-08 19:40:11 -04:00
parent 3d17637711
commit fd6d4cf37b
10 changed files with 128 additions and 16 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3000/api/v1';
const apiBaseUrl = import.meta.env?.VITE_API_BASE_URL ?? 'http://localhost:3000/api/v1';
export async function searchCatalog({ query = '', page = 1, limit = 20 } = {}) {
const params = new URLSearchParams({ query, page: String(page), limit: String(limit) });
@@ -8,6 +8,17 @@ export async function searchCatalog({ query = '', page = 1, limit = 20 } = {}) {
throw new Error('Catalog search is unavailable.');
}
const payload = await response.json();
return payload.data;
}
export async function getPublicListing(id) {
const response = await fetch(`${apiBaseUrl}/public/listings/${encodeURIComponent(id)}`);
if (!response.ok) {
throw new Error(response.status === 404 ? 'Listing not found.' : 'Listing is unavailable.');
}
const payload = await response.json();
return payload.data;
}