feat: add category field to housekeeping tasks + TechnicalPage for maintenance tasks
- Add migration 025 to add `category` column (housekeeping/maintenance) to housekeeping_tasks - Backend: filter by ?category= in GET, store category in POST, allow patching category - API client: HkPayload + housekeeping.list() now support category param - HousekeepingPage: filters by category=housekeeping so maintenance tasks don't appear - RoomContextMenu: priority sub-form for dirty/cleaning status, tech task creation inline form - BookingCalendar: accepts onMaintenanceTaskCreate prop, passes priority to onRoomUpdate - CalendarPage: handleRoomUpdate creates task for dirty+cleaning (with priority), new handleMaintenanceTaskCreate for category=maintenance tasks - TechnicalPage: new page for viewing/creating/updating maintenance tasks - App.tsx: /technical route added - Sidebar: Тех. задачи nav item added under Управление Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ const housekeeping: FastifyPluginAsync = async (fastify) => {
|
||||
role === 'super_admin' || userSlug === slug
|
||||
|
||||
// ── GET /api/hotels/:slug/housekeeping ─────────────────────────────────────
|
||||
fastify.get<SlugParam & { Querystring: { status?: string; date?: string } }>(
|
||||
fastify.get<SlugParam & { Querystring: { status?: string; date?: string; category?: string } }>(
|
||||
'/api/hotels/:slug/housekeeping',
|
||||
{ onRequest: [fastify.authenticate] },
|
||||
async (request, reply) => {
|
||||
@@ -31,9 +31,10 @@ const housekeeping: FastifyPluginAsync = async (fastify) => {
|
||||
const values: unknown[] = [hotelId]
|
||||
let idx = 2
|
||||
|
||||
const { status, date } = request.query
|
||||
if (status) { conditions.push(`t.status = $${idx}`); values.push(status); idx++ }
|
||||
if (date) { conditions.push(`t.due_date = $${idx}`); values.push(date); idx++ }
|
||||
const { status, date, category } = request.query
|
||||
if (status) { conditions.push(`t.status = $${idx}`); values.push(status); idx++ }
|
||||
if (date) { conditions.push(`t.due_date = $${idx}`); values.push(date); idx++ }
|
||||
if (category) { conditions.push(`t.category = $${idx}`); values.push(category); idx++ }
|
||||
|
||||
const { rows } = await db.query(
|
||||
`SELECT t.*,
|
||||
@@ -55,7 +56,7 @@ const housekeeping: FastifyPluginAsync = async (fastify) => {
|
||||
// ── POST /api/hotels/:slug/housekeeping ────────────────────────────────────
|
||||
fastify.post<SlugParam & { Body: {
|
||||
room_id?: string; type: string; priority?: string
|
||||
assignee_id?: string; notes?: string; due_date?: string
|
||||
assignee_id?: string; notes?: string; due_date?: string; category?: string
|
||||
} }>(
|
||||
'/api/hotels/:slug/housekeeping',
|
||||
{ onRequest: [fastify.authenticate] },
|
||||
@@ -67,13 +68,13 @@ const housekeeping: FastifyPluginAsync = async (fastify) => {
|
||||
const hotelId = await getHotelId(slug)
|
||||
if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' })
|
||||
|
||||
const { room_id, type, priority = 'medium', assignee_id, notes, due_date } = request.body
|
||||
const { room_id, type, priority = 'medium', assignee_id, notes, due_date, category = 'housekeeping' } = request.body
|
||||
const { rows } = await db.query(
|
||||
`INSERT INTO housekeeping_tasks
|
||||
(hotel_id, room_id, type, priority, assignee_id, notes, due_date)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING *`,
|
||||
(hotel_id, room_id, type, priority, assignee_id, notes, due_date, category)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING *`,
|
||||
[hotelId, room_id ?? null, type, priority,
|
||||
assignee_id ?? null, notes ?? null, due_date ?? null],
|
||||
assignee_id ?? null, notes ?? null, due_date ?? null, category],
|
||||
)
|
||||
return reply.code(201).send(rows[0])
|
||||
},
|
||||
@@ -91,7 +92,7 @@ const housekeeping: FastifyPluginAsync = async (fastify) => {
|
||||
const hotelId = await getHotelId(slug)
|
||||
if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' })
|
||||
|
||||
const allowed = ['room_id','type','status','priority','assignee_id','notes','due_date']
|
||||
const allowed = ['room_id','type','status','priority','assignee_id','notes','due_date','category']
|
||||
const updates: string[] = []
|
||||
const values: unknown[] = []
|
||||
let idx = 1
|
||||
|
||||
Reference in New Issue
Block a user