fix(storefront): use params.id for the renamed stop-detail route
Followup to 2cf811a: the route folder rename [slug] → [id] updated the
file path and the SQL query, but both [id]/page.tsx files still read
'useParams().slug', which Next.js now resolves to undefined.
Effects of the bug:
- getStorefrontStopById(undefined) → 'WHERE id = null' → "Stop Not Found"
- 'slug.includes("indian")' throws on undefined
Fix: switch to params.id. Also drop the brand-detection branch
('slug.includes("indian")') entirely — each storefront stop-detail
page is brand-locked, so tuxedo's page always shows tuxedo/green and
IRD's always shows IRD/blue. The runtime was already dead code because
the param is now a UUID.
Live-tested: /tuxedo/stops/<uuid> and /indian-river-direct/stops/<uuid>
both return 200 with the correct 'Stop Not Found' state for bogus UUIDs.
This commit is contained in:
@@ -36,7 +36,7 @@ type Stop = {
|
||||
|
||||
export default function StopPage() {
|
||||
const params = useParams();
|
||||
const slug = params.slug as string;
|
||||
const slug = params.id as string;
|
||||
|
||||
const [stop, setStop] = useState<{
|
||||
id: string;
|
||||
@@ -57,9 +57,6 @@ export default function StopPage() {
|
||||
if (!result) return;
|
||||
|
||||
setStop(result.stop as unknown as Stop);
|
||||
const isIndian = slug.includes("indian");
|
||||
setBrandSlug(isIndian ? "indian-river-direct" : "tuxedo");
|
||||
setBrandAccent(isIndian ? "blue" : "green");
|
||||
setProducts(result.products as unknown as Product[]);
|
||||
}
|
||||
load();
|
||||
|
||||
@@ -35,7 +35,7 @@ type Stop = {
|
||||
|
||||
export default function StopPage() {
|
||||
const params = useParams();
|
||||
const slug = params.slug as string;
|
||||
const slug = params.id as string;
|
||||
|
||||
const [stop, setStop] = useState<{
|
||||
id: string;
|
||||
@@ -56,9 +56,6 @@ export default function StopPage() {
|
||||
if (!result) return;
|
||||
|
||||
setStop(result.stop as unknown as Stop);
|
||||
const isIndian = slug.includes("indian");
|
||||
setBrandSlug(isIndian ? "indian-river-direct" : "tuxedo");
|
||||
setBrandAccent(isIndian ? "blue" : "green");
|
||||
setProducts(result.products as unknown as Product[]);
|
||||
}
|
||||
load();
|
||||
|
||||
Reference in New Issue
Block a user