fix: frontend fixes batch - live search proxy, quick products 10 slots, categories emoji list, bell notifications with tabs, awaiting payment orders endpoint
This commit is contained in:
@@ -530,6 +530,38 @@ export async function registerOrdersRoutes(
|
||||
throw mapOrderError(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Awaiting payment orders for admin notifications
|
||||
app.get('/orders/notifications/awaiting-payment', async (request, reply) => {
|
||||
const user = await deps.authenticate(request);
|
||||
requireRole(user, 'admin');
|
||||
const result = await deps.pool.query<{
|
||||
id: string;
|
||||
total_cents: number;
|
||||
customer_email: string | null;
|
||||
created_at: Date;
|
||||
total_count: number;
|
||||
}>(
|
||||
`SELECT o.id, o.total_cents, u.email AS customer_email, o.created_at,
|
||||
COUNT(*) OVER()::int AS total_count
|
||||
FROM orders_orders o
|
||||
LEFT JOIN identity_users u ON u.id = o.user_id
|
||||
WHERE o.payment_status = 'AWAITING'
|
||||
AND o.state = 'PENDING'
|
||||
AND o.deleted_at IS NULL
|
||||
ORDER BY o.created_at ASC
|
||||
LIMIT 20`,
|
||||
);
|
||||
return reply.send({
|
||||
total: result.rows[0]?.total_count ?? 0,
|
||||
items: result.rows.map((row) => ({
|
||||
id: row.id,
|
||||
totalCents: row.total_cents,
|
||||
customerEmail: row.customer_email,
|
||||
createdAt: row.created_at.toISOString(),
|
||||
})),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function mapOrderError(error: unknown): Error {
|
||||
|
||||
Reference in New Issue
Block a user