feat(admin): add update functionality for areas, categories, and teams in admin panel

This commit is contained in:
gabdevele
2026-06-15 14:53:51 +02:00 Unverified
parent 486cded844
commit caa014b33f
4 changed files with 261 additions and 24 deletions
+13
View File
@@ -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,
}