fixed login session for user name, and updated the api calls on the product detials pages.
CI / test (push) Successful in 6s
CI / test (push) Successful in 6s
This commit is contained in:
@@ -1470,6 +1470,11 @@ function GunbuilderPageContent() {
|
||||
|
||||
if (groupCategories.length === 0) return null;
|
||||
|
||||
// Check if there are locked/conflicting parts in this group
|
||||
const hasConflicts = tableRows.some(
|
||||
(row) => row.kind === "category" && row.locked
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
id={`group-${group.id}`}
|
||||
@@ -1489,6 +1494,23 @@ function GunbuilderPageContent() {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{hasConflicts && (
|
||||
<div className="rounded-md border border-amber-500/30 bg-amber-500/10 p-3">
|
||||
<div className="flex items-start gap-2">
|
||||
<span className="text-amber-400 text-sm">⚠</span>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-medium text-amber-300">
|
||||
Part Conflict Detected
|
||||
</p>
|
||||
<p className="text-xs text-zinc-300 mt-1">
|
||||
Some parts below are disabled because you've selected a complete assembly that already includes them. To customize individual parts, remove the complete assembly first.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="overflow-x-auto rounded-md border border-zinc-800 bg-zinc-950/80">
|
||||
<table className="min-w-full text-xs md:text-sm">
|
||||
<thead>
|
||||
@@ -1635,8 +1657,27 @@ function GunbuilderPageContent() {
|
||||
<td className="px-3 py-2 align-top">
|
||||
<div className="flex justify-end gap-2">
|
||||
{isLocked ? (
|
||||
<div className="text-[0.7rem] text-zinc-500">
|
||||
—
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-[0.7rem] text-amber-400/70">
|
||||
⚠ Disabled
|
||||
</span>
|
||||
<div className="group relative">
|
||||
<button
|
||||
type="button"
|
||||
className="text-zinc-500 hover:text-zinc-300 text-xs"
|
||||
title="Why is this disabled?"
|
||||
>
|
||||
ⓘ
|
||||
</button>
|
||||
<div className="invisible group-hover:visible absolute right-0 top-6 z-10 w-64 rounded-md border border-zinc-800 bg-zinc-950 p-3 text-xs text-zinc-300 shadow-xl">
|
||||
<p className="font-semibold text-amber-300 mb-1">
|
||||
Part Conflict
|
||||
</p>
|
||||
<p>
|
||||
You've selected a complete assembly which already includes this part. Remove the complete assembly to select individual parts.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : selectedPart ? (
|
||||
<>
|
||||
|
||||
@@ -238,8 +238,11 @@ export default function ProductDetailsPage() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const url = `${API_BASE_URL}/api/v1/products/${numericId}`;
|
||||
const res = await fetch(url, { signal: controller.signal });
|
||||
const url = `/api/catalog/products/${numericId}`;
|
||||
const res = await fetch(url, {
|
||||
signal: controller.signal,
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to load product (${res.status})`);
|
||||
@@ -272,8 +275,11 @@ export default function ProductDetailsPage() {
|
||||
try {
|
||||
setOffersLoading(true);
|
||||
|
||||
const url = `${API_BASE_URL}/api/v1/products/${numericId}/offers`;
|
||||
const res = await fetch(url, { signal: controller.signal });
|
||||
const url = `/api/catalog/products/${numericId}/offers`;
|
||||
const res = await fetch(url, {
|
||||
signal: controller.signal,
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to load offers (${res.status})`);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const API_BASE_URL = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const { id } = params;
|
||||
|
||||
// Public build detail - no auth required
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/api/v1/builds/${id}`,
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
cache: 'no-store',
|
||||
}
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: await res.text() },
|
||||
{ status: res.status }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(await res.json());
|
||||
} catch (err: any) {
|
||||
return NextResponse.json(
|
||||
{ error: err?.message || 'Failed to fetch build' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const API_BASE_URL = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
// Public builds endpoint - no auth required
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/api/v1/builds?${searchParams}`,
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
cache: 'no-store',
|
||||
}
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: await res.text() },
|
||||
{ status: res.status }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(await res.json());
|
||||
} catch (err: any) {
|
||||
return NextResponse.json(
|
||||
{ error: err?.message || 'Failed to fetch builds' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const API_BASE_URL = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const { id } = params;
|
||||
|
||||
// No auth required for public catalog
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/api/v1/products/${id}/offers`,
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
cache: 'no-store',
|
||||
}
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: await res.text() },
|
||||
{ status: res.status }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(await res.json());
|
||||
} catch (err: any) {
|
||||
return NextResponse.json(
|
||||
{ error: err?.message || 'Failed to fetch product offers' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const API_BASE_URL = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const { id } = params;
|
||||
|
||||
// No auth required for public catalog
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/api/v1/products/${id}`,
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
cache: 'no-store',
|
||||
}
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: await res.text() },
|
||||
{ status: res.status }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(await res.json());
|
||||
} catch (err: any) {
|
||||
return NextResponse.json(
|
||||
{ error: err?.message || 'Failed to fetch product' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const API_BASE_URL = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
// No auth required for public catalog
|
||||
const res = await fetch(
|
||||
`${API_BASE_URL}/api/v1/products?${searchParams}`,
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
cache: 'no-store',
|
||||
}
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: await res.text() },
|
||||
{ status: res.status }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(await res.json());
|
||||
} catch (err: any) {
|
||||
return NextResponse.json(
|
||||
{ error: err?.message || 'Failed to fetch products' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,9 @@ export default async function BuildBreakdownPage({
|
||||
}: {
|
||||
params: { buildId: string };
|
||||
}) {
|
||||
// Public detail endpoint
|
||||
const res = await fetch(`${API_BASE_URL}/api/v1/builds/${params.buildId}`, {
|
||||
// Public detail endpoint - use Next.js API route
|
||||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000';
|
||||
const res = await fetch(`${baseUrl}/api/builds/public/${params.buildId}`, {
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ export default function BuildsPage() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const res = await fetch(`${API_BASE_URL}/api/v1/builds?limit=50`, {
|
||||
const res = await fetch('/api/builds/public?limit=50', {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
||||
Reference in New Issue
Block a user