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

@@ -22,6 +22,7 @@ export interface InventoryRoutesDeps {
}
const variantParamSchema = z.object({ variantId: z.uuid() });
const productParamSchema = z.object({ productId: z.uuid() });
const availabilityQuerySchema = z.object({
quantity: z.coerce.number().int().positive().default(1),
storeId: z.uuid().optional(),
@@ -80,6 +81,49 @@ export async function registerInventoryRoutes(
},
);
// GET /inventory/product/:productId/availability — lookup first variant and return stock
const productAvailabilitySchema: FastifySchema = {
tags: ['Inventory'],
summary: 'Check availability by productId (público)',
params: {
type: 'object',
required: ['productId'],
properties: { productId: { type: 'string', format: 'uuid' } },
},
querystring: {
type: 'object',
properties: {
quantity: { type: 'integer', default: 1 },
storeId: { type: 'string', format: 'uuid' },
},
},
};
app.get(
'/inventory/product/:productId/availability',
{ schema: productAvailabilitySchema },
async (request, reply) => {
const { productId } = parseJson(productParamSchema, request.params);
const { quantity, storeId } = parseJson(availabilityQuerySchema, request.query);
// Lookup the first variant for this product
const variantResult = await deps.pool.query(
`SELECT id FROM product_variants WHERE product_id = $1 LIMIT 1`,
[productId],
);
if (variantResult.rows.length === 0) {
throw new AppError(404, 'VARIANT_NOT_FOUND', 'No variant found for this product');
}
const variantId = variantResult.rows[0].id;
const availability = await inventory.checkAvailability(
variantId,
storeId ?? DEFAULT_STORE_ID,
quantity,
);
return reply.send(availability);
},
);
const setStockSchema: FastifySchema = {
tags: ['Inventory'],
summary: 'Set available stock (admin)',