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
+2 -2
View File
@@ -177,12 +177,12 @@ export default function BuildSummaryPage() {
setError(null);
// scoped (platform)
const scopedUrl = `${API_BASE_URL}/api/products?platform=${encodeURIComponent(
const scopedUrl = `${API_BASE_URL}/api/v1/products?platform=${encodeURIComponent(
platform
)}`;
// universal (optional)
const universalUrl = `${API_BASE_URL}/api/products`;
const universalUrl = `${API_BASE_URL}/api/v1/products`;
const [scopedRes, universalRes] = await Promise.all([
fetch(scopedUrl, { signal: controller.signal }),
+2 -2
View File
@@ -316,11 +316,11 @@ export default function GunbuilderPage() {
setLoading(true);
setError(null);
const scopedUrl = `${API_BASE_URL}/api/products?platform=${encodeURIComponent(
const scopedUrl = `${API_BASE_URL}/api/v1/products?platform=${encodeURIComponent(
platform
)}`;
const universalUrl = `${API_BASE_URL}/api/products`;
const universalUrl = `${API_BASE_URL}/api/v1/products`;
const [scopedRes, universalRes] = await Promise.all([
fetch(scopedUrl, { signal: controller.signal }),
+1 -1
View File
@@ -116,7 +116,7 @@ export default function BuildDetailsPage() {
setPartsError(null);
const res = await fetch(
`${API_BASE_URL}/api/products?platform=${encodeURIComponent(platform)}`,
`${API_BASE_URL}/api/v1/products?platform=${encodeURIComponent(platform)}`,
{ signal: controller.signal },
);
@@ -122,7 +122,7 @@ export default function ProductDetailsPage() {
setLoading(true);
setError(null);
const url = `${API_BASE_URL}/api/products/${numericId}`;
const url = `${API_BASE_URL}/api/v1/products/${numericId}`;
const res = await fetch(url, { signal: controller.signal });
if (!res.ok) {
@@ -56,13 +56,13 @@ export function getPricingHistory(
/**
* Get retailer offers for a part
* Real implementation using Ballistic backend:
* GET /api/products/{productId}/offers
* GET /api/v1/products/{productId}/offers
*/
export async function getRetailerOffers(
productId: string,
): Promise<RetailerOffer[]> {
const res = await fetch(
`${API_BASE_URL}/api/products/${productId}/offers`,
`${API_BASE_URL}/api/v1/products/${productId}/offers`,
{
// This will be called from the client detail page,
// so we *don't* use cache here.
@@ -135,7 +135,7 @@ export default function CategoryPage() {
search.append("partRoles", r);
}
const url = `${API_BASE_URL}/api/products?${search.toString()}`;
const url = `${API_BASE_URL}/api/v1/products?${search.toString()}`;
const res = await fetch(url, { signal: controller.signal });
@@ -172,7 +172,7 @@ export default function ProductDetailsPage() {
setLoading(true);
setError(null);
const url = `${API_BASE_URL}/api/products/${numericId}`;
const url = `${API_BASE_URL}/api/v1/products/${numericId}`;
const res = await fetch(url, { signal: controller.signal });
if (!res.ok) {
+3 -3
View File
@@ -22,7 +22,7 @@ type PlatformOption = {
};
// Backend currently filters products by canonical platform strings like "AR-15".
// DB platform keys are like "AR15" / "AR9". Translate when calling /api/products.
// DB platform keys are like "AR15" / "AR9". Translate when calling /api/v1/products.
const platformKeyToApiPlatform = (key: string) => {
const k = (key ?? "").toUpperCase().trim();
if (!k) return "AR-15";
@@ -123,7 +123,7 @@ export default function AdminProductsPage() {
const apiPlatform = platformKeyToApiPlatform(platform);
// NOTE: backend endpoint expects `platform`, not `platformKey`.
const url = `${API_BASE_URL}/api/products?platform=${encodeURIComponent(
const url = `${API_BASE_URL}/api/v1/products?platform=${encodeURIComponent(
apiPlatform
)}`;
@@ -402,7 +402,7 @@ export default function AdminProductsPage() {
)}
<div className="mt-3 text-[0.7rem] text-zinc-500">
Backend: <span className="font-mono text-zinc-400">{API_BASE_URL}</span> · Endpoint: <span className="font-mono text-zinc-400">/api/products?platform=...</span> · Page size: <span className="font-mono text-zinc-400">{pageSize}</span>
Backend: <span className="font-mono text-zinc-400">{API_BASE_URL}</span> · Endpoint: <span className="font-mono text-zinc-400">/api/v1/products?platform=...</span> · Page size: <span className="font-mono text-zinc-400">{pageSize}</span>
</div>
</section>
</div>