ultisuite-client/lib/api/hooks/use-admin-drive-queries.ts
R3D347HR4Y ad1370ea7e
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
feat: enhance configuration and add new demo layouts
- Introduced turbopack alias for canvas in next.config.mjs.
- Updated package.json scripts for development and branding tasks.
- Added new dependencies for Tiptap extensions.
- Implemented new demo layouts for agenda, contacts, drive, and mail applications.
- Enhanced globals.css for improved theming and splash screen animations.
- Added OAuth callback handling for drive mounts.
- Updated layout components to integrate new demo shells and improve structure.
2026-06-12 19:10:24 +02:00

53 lines
1.7 KiB
TypeScript

"use client"
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
import { apiClient } from "@/lib/api/client"
import { useAuthReady } from "@/lib/api/use-auth-ready"
import type { DriveOrgFolder } from "@/lib/api/types"
export function useAdminDriveOrgFolders() {
const { ready, authenticated } = useAuthReady()
return useQuery({
queryKey: ["admin", "drive", "org-folders"],
enabled: ready && authenticated,
queryFn: async () => {
const res = await apiClient.get<{ folders: DriveOrgFolder[] }>("/admin/drive/org-folders")
return res.folders ?? []
},
})
}
export function useAdminDriveOrgFolderMutations() {
const qc = useQueryClient()
const invalidate = () => qc.invalidateQueries({ queryKey: ["admin", "drive", "org-folders"] })
const create = useMutation({
mutationFn: (body: { org_slug: string; mount_point: string; quota_bytes?: number }) =>
apiClient.post<DriveOrgFolder>("/admin/drive/org-folders", body),
onSuccess: invalidate,
})
const update = useMutation({
mutationFn: (args: { id: string; mount_point?: string; quota_bytes?: number }) =>
apiClient.put<DriveOrgFolder>(`/admin/drive/org-folders/${encodeURIComponent(args.id)}`, {
mount_point: args.mount_point,
quota_bytes: args.quota_bytes,
}),
onSuccess: invalidate,
})
const remove = useMutation({
mutationFn: (id: string) =>
apiClient.delete(`/admin/drive/org-folders/${encodeURIComponent(id)}`),
onSuccess: invalidate,
})
const sync = useMutation({
mutationFn: (org_slugs: string[]) =>
apiClient.post<{ folders: DriveOrgFolder[] }>("/admin/drive/org-folders/sync", { org_slugs }),
onSuccess: invalidate,
})
return { create, update, remove, sync }
}