feat: 完善课程订阅
This commit is contained in:
@@ -3,6 +3,8 @@ import { ref } from 'vue'
|
||||
import type {
|
||||
TimeSlotWithBookingStatus,
|
||||
BookingWithDetails,
|
||||
BookingWithUser,
|
||||
BookingStatusHistory,
|
||||
CreateBookingDto,
|
||||
} from '@mp-pilates/shared'
|
||||
import { get, post, put } from '../utils/request'
|
||||
@@ -68,6 +70,51 @@ export const useBookingStore = defineStore('booking', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Admin methods ──────────────────────────────────────────────────────
|
||||
|
||||
async function fetchAllAdminBookings(
|
||||
page = 1,
|
||||
limit = 20,
|
||||
status?: string,
|
||||
): Promise<ServerPaginatedResult<BookingWithUser>> {
|
||||
const params: Record<string, unknown> = { page, limit }
|
||||
if (status) params.status = status
|
||||
|
||||
const paginated = await get<ServerPaginatedResult<BookingWithUser>>('/admin/bookings', params)
|
||||
return paginated
|
||||
}
|
||||
|
||||
async function confirmBooking(bookingId: string, remark?: string) {
|
||||
const result = await put<BookingWithDetails>(`/booking/${bookingId}/confirm`, {
|
||||
remark,
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
async function completeBooking(bookingId: string, remark?: string) {
|
||||
const result = await put<BookingWithDetails>(`/booking/${bookingId}/complete`, {
|
||||
remark,
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
async function markNoShow(bookingId: string, remark?: string) {
|
||||
const result = await put<BookingWithDetails>(`/booking/${bookingId}/noshow`, {
|
||||
remark,
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
async function fetchBookingHistory(bookingId: string): Promise<BookingStatusHistory[]> {
|
||||
const result = await get<BookingStatusHistory[]>(`/booking/${bookingId}/history`)
|
||||
return result
|
||||
}
|
||||
|
||||
async function fetchBookingById(bookingId: string) {
|
||||
const result = await get<BookingWithDetails | BookingWithUser>(`/booking/${bookingId}`)
|
||||
return result
|
||||
}
|
||||
|
||||
return {
|
||||
slots,
|
||||
myBookings,
|
||||
@@ -79,5 +126,11 @@ export const useBookingStore = defineStore('booking', () => {
|
||||
cancelBooking,
|
||||
fetchMyBookings,
|
||||
fetchUpcomingBookings,
|
||||
fetchAllAdminBookings,
|
||||
confirmBooking,
|
||||
completeBooking,
|
||||
markNoShow,
|
||||
fetchBookingHistory,
|
||||
fetchBookingById,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user