feat: play button, last played, loan lend/return on item page
This commit is contained in:
@@ -179,7 +179,14 @@ export async function registerCollectionRoutes(app: FastifyInstance): Promise<vo
|
||||
const db = request.server.db
|
||||
const row = getItem(db, request.user!.id, Number((request.params as { id: string }).id))
|
||||
if (!row) return reply.code(404).send({ error: 'not_found' })
|
||||
return { ...rowToItem(db, row), matchedAlbum: findMatchedAlbum(db, request.user!.id, row.id) }
|
||||
const loan = db
|
||||
.prepare('SELECT id, borrower, lent_at FROM loans WHERE item_id = ? AND returned_at IS NULL')
|
||||
.get(row.id) as { id: number; borrower: string; lent_at: string } | undefined
|
||||
return {
|
||||
...rowToItem(db, row),
|
||||
matchedAlbum: findMatchedAlbum(db, request.user!.id, row.id),
|
||||
loan: loan ? { id: loan.id, borrower: loan.borrower, lentAt: loan.lent_at } : null,
|
||||
}
|
||||
})
|
||||
|
||||
app.delete('/api/collection/:id', { preHandler: [requireAuth] }, async (request, reply) => {
|
||||
|
||||
Reference in New Issue
Block a user