ui using new v1 api for products

This commit is contained in:
2025-12-18 19:18:15 -05:00
parent 463fd06a12
commit 7f3818f795
12 changed files with 153 additions and 74 deletions
+5 -5
View File
@@ -42,7 +42,7 @@ export function slugify(input: string) {
/**
* Your existing list endpoint:
* GET /api/products?platform=AR-15&partRoles=complete-upper
* GET /api/v1/products?platform=AR-15&partRoles=complete-upper
*/
export async function fetchProducts(params: {
platform: string;
@@ -51,7 +51,7 @@ export async function fetchProducts(params: {
const { platform, partRole } = params;
const url =
`${API_BASE_URL}/api/products?` +
`${API_BASE_URL}/api/v1/products?` +
new URLSearchParams({
platform,
partRoles: partRole,
@@ -70,9 +70,9 @@ export async function fetchProducts(params: {
/**
* You likely have (or should add) a detail endpoint like:
* GET /api/products/{id}?platform=AR-15 OR GET /api/products/{id}
* GET /api/v1/products/{id}?platform=AR-15 OR GET /api/v1/products/{id}
*
* We'll call /api/products/{id} and optionally include platform as a query param.
* We'll call /api/v1/products/{id} and optionally include platform as a query param.
*/
export async function fetchProductById(params: {
id: string;
@@ -81,7 +81,7 @@ export async function fetchProductById(params: {
const { id, platform } = params;
const url =
`${API_BASE_URL}/api/products/${encodeURIComponent(id)}` +
`${API_BASE_URL}/api/v1/products/${encodeURIComponent(id)}` +
(platform ? `?${new URLSearchParams({ platform })}` : "");
const res = await fetch(url, { cache: "no-store" });