feat: categories + tariffs — migration, API routes, frontend integration
This commit is contained in:
@@ -344,6 +344,36 @@ export const api = {
|
||||
req<void>('DELETE', `/api/hotels/${slug}/rental-bookings/${id}`),
|
||||
},
|
||||
|
||||
// ── Categories ────────────────────────────────────────────────────────────
|
||||
categories: {
|
||||
list: (slug: string) =>
|
||||
req<CategoryApi[]>('GET', `/api/hotels/${slug}/categories`),
|
||||
|
||||
create: (slug: string, data: CategoryPayload) =>
|
||||
req<CategoryApi>('POST', `/api/hotels/${slug}/categories`, data),
|
||||
|
||||
update: (slug: string, id: string, data: Partial<CategoryPayload>) =>
|
||||
req<CategoryApi>('PATCH', `/api/hotels/${slug}/categories/${id}`, data),
|
||||
|
||||
delete: (slug: string, id: string) =>
|
||||
req<void>('DELETE', `/api/hotels/${slug}/categories/${id}`),
|
||||
},
|
||||
|
||||
// ── Tariffs ───────────────────────────────────────────────────────────────
|
||||
tariffs: {
|
||||
list: (slug: string) =>
|
||||
req<TariffApi[]>('GET', `/api/hotels/${slug}/tariffs`),
|
||||
|
||||
create: (slug: string, data: TariffPayload) =>
|
||||
req<TariffApi>('POST', `/api/hotels/${slug}/tariffs`, data),
|
||||
|
||||
update: (slug: string, id: string, data: Partial<TariffPayload>) =>
|
||||
req<TariffApi>('PATCH', `/api/hotels/${slug}/tariffs/${id}`, data),
|
||||
|
||||
delete: (slug: string, id: string) =>
|
||||
req<void>('DELETE', `/api/hotels/${slug}/tariffs/${id}`),
|
||||
},
|
||||
|
||||
// ── NetUP IPTV ────────────────────────────────────────────────────────────
|
||||
netup: {
|
||||
getSettings: (slug: string) =>
|
||||
@@ -614,6 +644,56 @@ export interface RentalObjectPayload {
|
||||
sort_order?: number
|
||||
}
|
||||
|
||||
export interface CategoryApi {
|
||||
id: string
|
||||
hotel_id: string
|
||||
name: string
|
||||
description: string
|
||||
color: string
|
||||
amenities: string[]
|
||||
photos: string[]
|
||||
sort_order: number
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface CategoryPayload {
|
||||
name: string
|
||||
description?: string
|
||||
color?: string
|
||||
amenities?: string[]
|
||||
photos?: string[]
|
||||
sort_order?: number
|
||||
}
|
||||
|
||||
export interface TariffApi {
|
||||
id: string
|
||||
hotel_id: string
|
||||
name: string
|
||||
code: string
|
||||
meal_plan: string
|
||||
inclusions: string[]
|
||||
modifier_type: 'fixed' | 'percent'
|
||||
modifier_value: number
|
||||
min_nights: number
|
||||
cancellation_policy: 'flexible' | 'moderate' | 'strict' | 'nonrefundable'
|
||||
description: string
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface TariffPayload {
|
||||
name: string
|
||||
code: string
|
||||
meal_plan?: string
|
||||
inclusions?: string[]
|
||||
modifier_type?: string
|
||||
modifier_value?: number
|
||||
min_nights?: number
|
||||
cancellation_policy?: string
|
||||
description?: string
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
function toHotelPayload(h: HotelPayload): Record<string, unknown> {
|
||||
const out: Record<string, unknown> = {}
|
||||
if (h.name !== undefined) out.name = h.name
|
||||
|
||||
Reference in New Issue
Block a user