init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { http } from '@/api/http'
|
||||
import type { ActiveSet, AttractionSet } from '@/api/types'
|
||||
|
||||
export async function fetchSets(areaId: string): Promise<AttractionSet[]> {
|
||||
const resp = await http.get<AttractionSet[]>(`/admin/areas/${areaId}/sets`)
|
||||
return resp.data
|
||||
}
|
||||
|
||||
export async function createSet(areaId: string, name: string): Promise<AttractionSet> {
|
||||
const resp = await http.post<AttractionSet>(`/admin/areas/${areaId}/sets`, { name })
|
||||
return resp.data
|
||||
}
|
||||
|
||||
export async function renameSet(id: string, name: string): Promise<AttractionSet> {
|
||||
const resp = await http.patch<AttractionSet>(`/admin/sets/${id}`, { name })
|
||||
return resp.data
|
||||
}
|
||||
|
||||
/** Полная замена состава; порядок id задаёт порядок элементов. */
|
||||
export async function putSetItems(id: string, attractionIds: string[]): Promise<AttractionSet> {
|
||||
const resp = await http.put<AttractionSet>(`/admin/sets/${id}/items`, { attractionIds })
|
||||
return resp.data
|
||||
}
|
||||
|
||||
export async function removeSetItem(id: string, attractionId: string): Promise<void> {
|
||||
await http.delete(`/admin/sets/${id}/items/${attractionId}`)
|
||||
}
|
||||
|
||||
export async function activateSet(id: string): Promise<AttractionSet> {
|
||||
const resp = await http.post<AttractionSet>(`/admin/sets/${id}/activate`)
|
||||
return resp.data
|
||||
}
|
||||
|
||||
export async function archiveSet(id: string): Promise<AttractionSet> {
|
||||
const resp = await http.post<AttractionSet>(`/admin/sets/${id}/archive`)
|
||||
return resp.data
|
||||
}
|
||||
|
||||
/** Публичный активный набор зоны — единственный способ прочитать состав набора. */
|
||||
export async function fetchActiveSet(areaId: string): Promise<ActiveSet> {
|
||||
const resp = await http.get<ActiveSet>(`/areas/${areaId}/active-set`)
|
||||
return resp.data
|
||||
}
|
||||
Reference in New Issue
Block a user