- Updated .env.example to include configuration for OnlyOffice Document Server. - Modified the workspace configuration to remove the drive-suite path. - Adjusted TypeScript environment imports for consistency. - Enhanced Next.js configuration to disable canvas in Webpack. - Updated package.json to include new dependencies for OnlyOffice and PDF.js. - Added global styles for OnlyOffice theme integration in the CSS. - Created new layout and page components for the Drive feature, including public sharing and editing functionalities. - Updated metadata handling across various layouts to reflect the new app structure.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
'use client'
|
|
|
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
import { apiClient } from '../client'
|
|
import { useAuthReady } from '../use-auth-ready'
|
|
import type {
|
|
ApiToken,
|
|
ApiTokenCreated,
|
|
CreateApiTokenPayload,
|
|
} from '../types'
|
|
|
|
export function useApiTokens() {
|
|
const { ready, authenticated } = useAuthReady()
|
|
|
|
return useQuery({
|
|
queryKey: ['api-tokens'],
|
|
queryFn: async () => {
|
|
const res = await apiClient.get<ApiToken[] | { tokens: ApiToken[] }>(
|
|
'/mail/api-tokens'
|
|
)
|
|
return Array.isArray(res) ? res : (res.tokens ?? [])
|
|
},
|
|
staleTime: 30_000,
|
|
enabled: ready && authenticated,
|
|
retry: 1,
|
|
})
|
|
}
|
|
|
|
export function useCreateApiToken() {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationFn: (payload: CreateApiTokenPayload) =>
|
|
apiClient.post<ApiTokenCreated>('/mail/api-tokens', payload),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['api-tokens'] })
|
|
},
|
|
})
|
|
}
|
|
|
|
export function useRevokeApiToken() {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationFn: (tokenId: string) =>
|
|
apiClient.delete(`/mail/api-tokens/${tokenId}`),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['api-tokens'] })
|
|
},
|
|
})
|
|
}
|