ultisuite-client/lib/api/hooks/use-public-share-mutations.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

71 lines
2.1 KiB
TypeScript

"use client"
import { useMutation, useQueryClient } from "@tanstack/react-query"
import {
createPublicShareFolder,
deletePublicShareItem,
renamePublicShareItem,
uploadPublicShareFile,
} from "@/lib/api/public-share-mutations"
import type { useDriveMutations } from "@/lib/api/hooks/use-drive-queries"
export function usePublicShareMutations(token: string, password?: string) {
const qc = useQueryClient()
const invalidate = () => qc.invalidateQueries({ queryKey: ["public-share", token] })
const createFolder = useMutation({
mutationFn: (path: string) => createPublicShareFolder(token, path, password),
onSuccess: invalidate,
})
const deleteFile = useMutation({
mutationFn: (path: string) => deletePublicShareItem(token, path, password),
onSuccess: invalidate,
})
const rename = useMutation({
mutationFn: (body: { path: string; new_name: string }) =>
renamePublicShareItem(token, body.path, body.new_name, password),
onSuccess: invalidate,
})
const upload = useMutation({
mutationFn: ({ targetPath, file }: { targetPath: string; file: File }) =>
uploadPublicShareFile(token, targetPath, file, password),
onSuccess: invalidate,
})
return {
createFolder,
deleteFile,
rename,
uploadFile: async (targetPath: string, file: File) => {
await upload.mutateAsync({ targetPath, file })
},
}
}
/** Drive-compatible mutations for context menus on public shares. */
export function usePublicShareMenuMutations(
token: string,
password?: string
): ReturnType<typeof useDriveMutations> {
const qc = useQueryClient()
const base = usePublicShareMutations(token, password)
const noop = useMutation({ mutationFn: async () => {} })
return {
createFolder: base.createFolder,
deleteFile: base.deleteFile,
rename: base.rename,
move: noop,
copy: noop,
favorite: noop,
restore: noop,
deleteTrash: noop,
emptyTrash: noop,
createShare: noop,
deleteShare: noop,
lookupShareRecipient: noop,
createFile: noop,
invalidate: () => qc.invalidateQueries({ queryKey: ["public-share", token] }),
} as ReturnType<typeof useDriveMutations>
}