fix: storefront live search relative URLs + auth error messages + TPV clock

- Storefront: use relative URLs in api.ts (fix ERR_ADDRESS_UNREACHABLE)
- Auth: show specific error for EMAIL_NOT_CONFIRMED
- TPV: add clock with date/time, modern SVG icons, panel toggle left
This commit is contained in:
chattie
2026-08-24 16:13:02 +02:00
parent 3d404de25c
commit 30a0cd3552
9 changed files with 163 additions and 21 deletions

View File

@@ -41,7 +41,7 @@ export function AddToCart({ productId, productName, unitPriceCents, imageUrl }:
const [added, setAdded] = useState<boolean>(false);
useEffect(() => {
fetch(`/api/inventory/${encodeURIComponent(productId)}/availability`)
fetch(`/api/inventory/product/${encodeURIComponent(productId)}/availability`)
.then(async (r) => (r.ok ? await r.json() : { availableQuantity: 0 }))
.then((j) => setStock(j.availableQuantity ?? 0))
.catch(() => setStock(0));

View File

@@ -77,14 +77,10 @@ export interface SearchProductsInput {
offset?: number;
}
const DEFAULT_API_BASE_URL = 'http://localhost:3000';
// Use env var if set, otherwise use relative URL (works for SSR and client-side via same-origin)
function apiBaseUrl(): string {
return (
process.env.API_BASE_URL ??
process.env.NEXT_PUBLIC_API_BASE_URL ??
DEFAULT_API_BASE_URL
).replace(/\/$/, '');
const base = process.env.API_BASE_URL ?? process.env.NEXT_PUBLIC_API_BASE_URL ?? '';
return base.replace(/\/$/, '');
}
function toQueryString(input: SearchProductsInput): string {