feat(admin): add update functionality for areas, categories, and teams in admin panel
This commit is contained in:
@@ -3,6 +3,7 @@ import type {
|
||||
ModerationListResponse,
|
||||
OkResponse,
|
||||
OverviewStatsResponse, TeamListResponse, UpdateModerationRequest,
|
||||
UpdateAreaRequest, UpdateCategoryRequest, UpdateTeamRequest,
|
||||
UpdateUserBanRequest, UpdateUserRolesRequest,
|
||||
UserListResponse
|
||||
} from "~/types/api";
|
||||
@@ -26,17 +27,26 @@ export const useAdmin = () => {
|
||||
const createArea = (body: CreateAreaRequest) =>
|
||||
useApiFetch<OkResponse>('/api/v1/admin/areas', { method: 'POST', body })
|
||||
|
||||
const updateArea = (id: number, body: UpdateAreaRequest) =>
|
||||
useApiFetch<OkResponse>(`/api/v1/admin/areas/${id}`, { method: 'PATCH', body })
|
||||
|
||||
const getCategories = () =>
|
||||
useApiFetch<CategoryListResponse>('/api/v1/admin/categories', { method: 'GET' })
|
||||
|
||||
const createCategory = (body: CreateCategoryRequest) =>
|
||||
useApiFetch<OkResponse>('/api/v1/admin/categories', { method: 'POST', body })
|
||||
|
||||
const updateCategory = (id: number, body: UpdateCategoryRequest) =>
|
||||
useApiFetch<OkResponse>(`/api/v1/admin/categories/${id}`, { method: 'PATCH', body })
|
||||
|
||||
const getTeams = () =>
|
||||
useApiFetch<TeamListResponse>('/api/v1/admin/teams', { method: 'GET' })
|
||||
|
||||
const createTeam = (body: CreateTeamRequest) =>
|
||||
useApiFetch<OkResponse>('/api/v1/admin/teams', { method: 'POST', body })
|
||||
|
||||
const updateTeam = (id: number, body: UpdateTeamRequest) =>
|
||||
useApiFetch<OkResponse>(`/api/v1/admin/teams/${id}`, { method: 'PATCH', body })
|
||||
|
||||
const getModerationFlags = (query?: { status?: string; page?: number; per_page?: number }) =>
|
||||
useApiFetch<ModerationListResponse>('/api/v1/admin/moderation', { method: 'GET', query })
|
||||
@@ -51,10 +61,13 @@ export const useAdmin = () => {
|
||||
updateUserRoles,
|
||||
getAreas,
|
||||
createArea,
|
||||
updateArea,
|
||||
getCategories,
|
||||
createCategory,
|
||||
updateCategory,
|
||||
getTeams,
|
||||
createTeam,
|
||||
updateTeam,
|
||||
getModerationFlags,
|
||||
updateModerationFlag,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user