- Implemented API endpoints for listing and updating recurring booking groups. - Added handlers for listing and updating recurring groups in the backend. - Created frontend components for displaying and editing recurring bookings. - Enhanced booking provider to manage recurring groups and their states. - Updated API client to include new methods for recurring bookings. - Introduced new validation schemas for updating recurring groups. - Added UI elements for managing recurring bookings in the booking interface.
104 lines
3.0 KiB
TypeScript
104 lines
3.0 KiB
TypeScript
import type {
|
|
AdminBooking,
|
|
CancelPublicBookingInput,
|
|
CreateAdminBookingInput,
|
|
CreatePublicBookingInput,
|
|
ListRecurringGroupsResponse,
|
|
PublicAvailabilityResponse,
|
|
PublicBooking,
|
|
PublicBookingConfirmation,
|
|
RecurringBookingGroup,
|
|
UpdateAdminBookingStatusInput,
|
|
UpdateRecurringGroupInput,
|
|
} from '@repo/api-contract';
|
|
import type { CreateRecurringBookingInput } from '@repo/api-contract';
|
|
import { http } from '../http';
|
|
|
|
export async function getAvailability(
|
|
complexSlug: string,
|
|
params: { date: string; sportId?: string }
|
|
) {
|
|
const response = await http.get<PublicAvailabilityResponse>(
|
|
`/api/public-bookings/complex/${complexSlug}/availability`,
|
|
{ params }
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function createPublic(complexSlug: string, payload: CreatePublicBookingInput) {
|
|
const response = await http.post<PublicBooking>(
|
|
`/api/public-bookings/complex/${complexSlug}`,
|
|
payload
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function getConfirmation(complexSlug: string, bookingCode: string) {
|
|
const response = await http.get<PublicBookingConfirmation>(
|
|
`/api/public-bookings/complex/${complexSlug}/confirmation/${bookingCode}`
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function listByComplex(complexId: string, params: { fromDate: string }) {
|
|
const response = await http.get<{ bookings: AdminBooking[] }>(
|
|
`/api/admin-bookings/complex/${complexId}`,
|
|
{ params }
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function createAdmin(complexId: string, payload: CreateAdminBookingInput) {
|
|
const response = await http.post<AdminBooking>(
|
|
`/api/admin-bookings/complex/${complexId}`,
|
|
payload
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function createRecurring(complexId: string, payload: CreateRecurringBookingInput) {
|
|
const response = await http.post<RecurringBookingGroup>(
|
|
`/api/admin-bookings/complex/${complexId}/recurring`,
|
|
payload
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function cancelRecurringGroup(groupId: string) {
|
|
const response = await http.post<{ ok: boolean }>(
|
|
`/api/admin-bookings/recurring/${groupId}/cancel`
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function listRecurringGroups(complexId: string) {
|
|
const response = await http.get<ListRecurringGroupsResponse>(
|
|
`/api/admin-bookings/complex/${complexId}/recurring`
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function updateRecurringGroup(groupId: string, payload: UpdateRecurringGroupInput) {
|
|
const response = await http.patch<RecurringBookingGroup>(
|
|
`/api/admin-bookings/recurring/${groupId}`,
|
|
payload
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function cancelPublic(complexSlug: string, payload: CancelPublicBookingInput) {
|
|
const response = await http.post<PublicBooking>(
|
|
`/api/public-bookings/complex/${complexSlug}/cancel`,
|
|
payload
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
export async function updateStatus(bookingId: string, payload: UpdateAdminBookingStatusInput) {
|
|
const response = await http.patch<AdminBooking>(
|
|
`/api/admin-bookings/${bookingId}/status`,
|
|
payload
|
|
);
|
|
return response.data;
|
|
}
|