mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 16:24:30 +00:00
- Add KiosksManagement component with full CRUD for kiosks - Add ScheduleManagement for staff schedules with break reminders - Update booking flow to allow artist selection by customers - Add staff_services API for assigning services to artists - Update staff management UI with service assignment dialog - Add auto-break reminder when schedule >= 8 hours - Update availability API to filter artists by service - Add kiosk management to Aperture dashboard - Clean up ralphy artifacts and logs
133 lines
2.6 KiB
TypeScript
133 lines
2.6 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { supabaseAdmin } from '@/lib/supabase/admin'
|
|
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: { id: string } }
|
|
) {
|
|
try {
|
|
const { data: kiosk, error } = await supabaseAdmin
|
|
.from('kiosks')
|
|
.select(`
|
|
id,
|
|
device_name,
|
|
display_name,
|
|
api_key,
|
|
ip_address,
|
|
is_active,
|
|
created_at,
|
|
updated_at,
|
|
location:locations (
|
|
id,
|
|
name,
|
|
address
|
|
)
|
|
`)
|
|
.eq('id', params.id)
|
|
.single()
|
|
|
|
if (error || !kiosk) {
|
|
return NextResponse.json(
|
|
{ error: 'Kiosk not found' },
|
|
{ status: 404 }
|
|
)
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
kiosk
|
|
})
|
|
} catch (error) {
|
|
console.error('Kiosk GET error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Internal server error' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|
|
|
|
export async function PUT(
|
|
request: NextRequest,
|
|
{ params }: { params: { id: string } }
|
|
) {
|
|
try {
|
|
const body = await request.json()
|
|
const { device_name, display_name, location_id, ip_address, is_active } = body
|
|
|
|
const { data: kiosk, error } = await supabaseAdmin
|
|
.from('kiosks')
|
|
.update({
|
|
device_name,
|
|
display_name,
|
|
location_id,
|
|
ip_address,
|
|
is_active
|
|
})
|
|
.eq('id', params.id)
|
|
.select(`
|
|
id,
|
|
device_name,
|
|
display_name,
|
|
api_key,
|
|
ip_address,
|
|
is_active,
|
|
created_at,
|
|
updated_at,
|
|
location:locations (
|
|
id,
|
|
name,
|
|
address
|
|
)
|
|
`)
|
|
.single()
|
|
|
|
if (error) {
|
|
return NextResponse.json(
|
|
{ error: error.message },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
kiosk
|
|
})
|
|
} catch (error) {
|
|
console.error('Kiosk PUT error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Internal server error' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|
|
|
|
export async function DELETE(
|
|
request: NextRequest,
|
|
{ params }: { params: { id: string } }
|
|
) {
|
|
try {
|
|
const { error } = await supabaseAdmin
|
|
.from('kiosks')
|
|
.delete()
|
|
.eq('id', params.id)
|
|
|
|
if (error) {
|
|
return NextResponse.json(
|
|
{ error: error.message },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: 'Kiosk deleted successfully'
|
|
})
|
|
} catch (error) {
|
|
console.error('Kiosk DELETE error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Internal server error' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|