mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 02:48:21 +00:00
refactor(authz): move to domain-based authz and flatten routes
This commit is contained in:
@@ -55,15 +55,15 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
initialMessage.message in AI_PLACEHOLDERS
|
||||
|
||||
const { data: polledMessage } = useQuery({
|
||||
queryKey: ['teams', teamId, 'comments', initialMessage.id],
|
||||
queryKey: ['comments', initialMessage.id],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].comments[':commentId'].$get({
|
||||
param: { teamId: teamId!, commentId: initialMessage.id! },
|
||||
const res = await client.api.comments[':commentId'].$get({
|
||||
param: { commentId: initialMessage.id! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch comment')
|
||||
return (await res.json()) as CommentInfo
|
||||
},
|
||||
enabled: !!teamId && isRunning,
|
||||
enabled: isRunning,
|
||||
refetchInterval: (query) => {
|
||||
const data = query.state.data as CommentInfo
|
||||
if (data && (!data.message || !(data.message in AI_PLACEHOLDERS))) {
|
||||
@@ -97,15 +97,15 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
const isAdmin = me?.role === 'owner'
|
||||
|
||||
const { data: logs, isLoading: isLogsLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'agent-sessions', message.sessionId, 'entries'],
|
||||
queryKey: ['agent-sessions', message.sessionId, 'entries'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId']['agent-sessions'][':sessionId'].entries.$get({
|
||||
param: { teamId: teamId!, sessionId: message.sessionId! },
|
||||
const res = await client.api['agent-sessions'][':sessionId'].entries.$get({
|
||||
param: { sessionId: message.sessionId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch session logs')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: isLogsOpen && !!message.sessionId && !!teamId,
|
||||
enabled: isLogsOpen && !!message.sessionId,
|
||||
})
|
||||
|
||||
const renderFormattedMessage = (text: string) => {
|
||||
|
||||
@@ -128,8 +128,8 @@ export function FileBrowser({
|
||||
const { data: shareLinksData } = useQuery({
|
||||
queryKey: ['shares', teamId, projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].shares.$get({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].shares.$get({
|
||||
param: { projectId },
|
||||
query: { first: '100' },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share links')
|
||||
@@ -240,16 +240,16 @@ export function FileBrowser({
|
||||
day: 'numeric',
|
||||
})
|
||||
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].shares.$post({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].shares.$post({
|
||||
param: { projectId },
|
||||
json: { name },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to create share link')
|
||||
const share = await res.json()
|
||||
|
||||
// Add assets to the new share link
|
||||
const assetsRes = await client.api.teams[':teamId'].shares[':shareId'].assets.$post({
|
||||
param: { teamId, shareId: share.id },
|
||||
const assetsRes = await client.api.shares[':shareId'].assets.$post({
|
||||
param: { shareId: share.id },
|
||||
json: { assetIds: items.map((i) => i.id!) },
|
||||
})
|
||||
if (!assetsRes.ok) throw new Error('Failed to add assets to share link')
|
||||
@@ -273,8 +273,8 @@ export function FileBrowser({
|
||||
|
||||
const { mutate: addToShareLink } = useMutation({
|
||||
mutationFn: async ({ shareId, items }: { shareId: string; items: AssetInfo[] }) => {
|
||||
const res = await client.api.teams[':teamId'].shares[':shareId'].assets.$post({
|
||||
param: { teamId, shareId },
|
||||
const res = await client.api.shares[':shareId'].assets.$post({
|
||||
param: { shareId },
|
||||
json: { assetIds: items.map((i) => i.id!) },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to add assets')
|
||||
|
||||
@@ -87,8 +87,8 @@ export function FileCard({
|
||||
const { data: polledItem } = useQuery({
|
||||
queryKey: ['file', teamId, item.id],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].$get({
|
||||
param: { teamId: teamId || '', fileId: item.id || '' },
|
||||
const res = await client.api.files[':fileId'].$get({
|
||||
param: { fileId: item.id || '' },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch file')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
|
||||
@@ -66,8 +66,8 @@ export function FileListItem({
|
||||
const { data: polledItem } = useQuery({
|
||||
queryKey: ['file', teamId, item.id],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].$get({
|
||||
param: { teamId: teamId || '', fileId: item.id || '' },
|
||||
const res = await client.api.files[':fileId'].$get({
|
||||
param: { fileId: item.id || '' },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch file')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
|
||||
@@ -58,15 +58,15 @@ export function FileBrowserToolbar({
|
||||
const isCollection = !!collection
|
||||
|
||||
const { data: folderInfo } = useQuery({
|
||||
queryKey: ['folders', teamId, assetId],
|
||||
queryKey: ['folders', assetId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId, folderId: assetId },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: assetId },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch folder')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
},
|
||||
enabled: isCollection && !!teamId && !!assetId,
|
||||
enabled: isCollection && !!assetId,
|
||||
})
|
||||
|
||||
const { data: members } = useQuery({
|
||||
|
||||
@@ -28,7 +28,7 @@ export function useFileActions({
|
||||
const [itemsToDelete, setItemsToDelete] = useState<AssetInfo[]>([])
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const $createFolder = client.api.teams[':teamId'].folders.$post
|
||||
const $createFolder = client.api.folders.$post
|
||||
const { mutate: createFolder } = useMutation<
|
||||
InferResponseType<typeof $createFolder, 200>,
|
||||
Error,
|
||||
@@ -41,7 +41,7 @@ export function useFileActions({
|
||||
},
|
||||
})
|
||||
|
||||
const $renameFolder = client.api.teams[':teamId'].folders[':folderId'].$put
|
||||
const $renameFolder = client.api.folders[':folderId'].$put
|
||||
const { mutate: renameFolder } = useMutation<
|
||||
InferResponseType<typeof $renameFolder, 200>,
|
||||
Error,
|
||||
@@ -54,7 +54,7 @@ export function useFileActions({
|
||||
},
|
||||
})
|
||||
|
||||
const $renameFile = client.api.teams[':teamId'].files[':fileId'].$put
|
||||
const $renameFile = client.api.files[':fileId'].$put
|
||||
const { mutate: renameFile } = useMutation<
|
||||
InferResponseType<typeof $renameFile, 200>,
|
||||
Error,
|
||||
@@ -67,7 +67,7 @@ export function useFileActions({
|
||||
},
|
||||
})
|
||||
|
||||
const $deleteFiles = client.api.teams[':teamId'].files.$delete
|
||||
const $deleteFiles = client.api.files.$delete
|
||||
const { mutate: deleteFiles } = useMutation<void, Error, InferRequestType<typeof $deleteFiles>>({
|
||||
mutationFn: async (request) => {
|
||||
const res = await $deleteFiles(request)
|
||||
@@ -75,7 +75,7 @@ export function useFileActions({
|
||||
},
|
||||
})
|
||||
|
||||
const $deleteFolders = client.api.teams[':teamId'].folders.$delete
|
||||
const $deleteFolders = client.api.folders.$delete
|
||||
const { mutate: deleteFolders } = useMutation<
|
||||
InferResponseType<typeof $deleteFolders>,
|
||||
Error,
|
||||
@@ -88,7 +88,7 @@ export function useFileActions({
|
||||
},
|
||||
})
|
||||
|
||||
const $restoreFiles = client.api.teams[':teamId'].files.restore.$post
|
||||
const $restoreFiles = client.api.files.restore.$post
|
||||
const { mutate: restoreFiles } = useMutation<void, Error, InferRequestType<typeof $restoreFiles>>(
|
||||
{
|
||||
mutationFn: async (request) => {
|
||||
@@ -98,7 +98,7 @@ export function useFileActions({
|
||||
},
|
||||
)
|
||||
|
||||
const $restoreFolders = client.api.teams[':teamId'].folders.restore.$post
|
||||
const $restoreFolders = client.api.folders.restore.$post
|
||||
const { mutate: restoreFolders } = useMutation<
|
||||
InferResponseType<typeof $restoreFolders>,
|
||||
Error,
|
||||
@@ -121,7 +121,7 @@ export function useFileActions({
|
||||
|
||||
if (fileIds.length > 0) {
|
||||
deleteFiles(
|
||||
{ param: { teamId: teamId }, json: { ids: fileIds } },
|
||||
{ json: { ids: fileIds } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -134,7 +134,7 @@ export function useFileActions({
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
deleteFolders(
|
||||
{ param: { teamId: teamId }, json: { ids: folderIds } },
|
||||
{ json: { ids: folderIds } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -160,7 +160,7 @@ export function useFileActions({
|
||||
|
||||
if (fileIds.length > 0) {
|
||||
restoreFiles(
|
||||
{ param: { teamId: teamId }, json: { ids: fileIds } },
|
||||
{ json: { ids: fileIds } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -173,7 +173,7 @@ export function useFileActions({
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
restoreFolders(
|
||||
{ param: { teamId: teamId }, json: { ids: folderIds } },
|
||||
{ json: { ids: folderIds } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -195,7 +195,7 @@ export function useFileActions({
|
||||
|
||||
const handleNewFolder = (name: string) => {
|
||||
createFolder(
|
||||
{ param: { teamId: teamId }, json: { name, parentId: assetId } },
|
||||
{ json: { name, parentId: assetId } },
|
||||
{
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -215,7 +215,7 @@ export function useFileActions({
|
||||
const onRenameSubmit = (item: AssetInfo, newName: string) => {
|
||||
if (item.type === 'folder') {
|
||||
renameFolder(
|
||||
{ param: { teamId: teamId, folderId: item.id! }, json: { name: newName } },
|
||||
{ param: { folderId: item.id! }, json: { name: newName } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -230,7 +230,7 @@ export function useFileActions({
|
||||
} else {
|
||||
renameFile(
|
||||
{
|
||||
param: { teamId: teamId, fileId: item.id! },
|
||||
param: { fileId: item.id! },
|
||||
json: { name: newName },
|
||||
},
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ export default function FileSystemManager({
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
const { loadedProjectId, setFields } = useFieldStore()
|
||||
const $patchMetadata = client.api.teams[':teamId'].files[':fileId'].metadata.$patch
|
||||
const $patchMetadata = client.api.files[':fileId'].metadata.$patch
|
||||
const { mutate: patchMetadata } = useMutation<
|
||||
InferResponseType<typeof $patchMetadata>,
|
||||
Error,
|
||||
@@ -132,10 +132,10 @@ export default function FileSystemManager({
|
||||
const { data: folderInfo } = isRecentlyDeleted
|
||||
? { data: undefined }
|
||||
: useQuery({
|
||||
queryKey: ['folders', teamId, assetId],
|
||||
queryKey: ['folders', assetId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId, folderId: assetId },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: assetId },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch folder')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
@@ -206,8 +206,8 @@ export default function FileSystemManager({
|
||||
return { data: [], pageInfo: { total: 0 } }
|
||||
}
|
||||
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].search.$post({
|
||||
param: { teamId: teamId, folderId: assetId },
|
||||
const res = await client.api.folders[':folderId'].search.$post({
|
||||
param: { folderId: assetId },
|
||||
json: {
|
||||
assetType: 'folder',
|
||||
after: pageParam as string,
|
||||
@@ -248,8 +248,8 @@ export default function FileSystemManager({
|
||||
return (await res.json()) as unknown as AssetInfoPaginatedList
|
||||
}
|
||||
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].search.$post({
|
||||
param: { teamId: teamId, folderId: assetId },
|
||||
const res = await client.api.folders[':folderId'].search.$post({
|
||||
param: { folderId: assetId },
|
||||
json: {
|
||||
assetType: 'file',
|
||||
after: pageParam as string,
|
||||
@@ -370,7 +370,7 @@ export default function FileSystemManager({
|
||||
const handleSaveField = (fileId: string, fieldId: string, value: unknown) => {
|
||||
patchMetadata(
|
||||
{
|
||||
param: { teamId: teamId, fileId: fileId },
|
||||
param: { fileId: fileId },
|
||||
json: [{ key: fieldId, value }] as InferRequestType<typeof $patchMetadata>['json'],
|
||||
},
|
||||
{
|
||||
@@ -378,7 +378,6 @@ export default function FileSystemManager({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [
|
||||
'folders',
|
||||
teamId,
|
||||
assetId,
|
||||
'children',
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@ import { Button } from './ui/button'
|
||||
import { ScrollArea } from './ui/scroll-area'
|
||||
|
||||
interface FileViewerLeftSidebarProps {
|
||||
teamId: string
|
||||
projectId: string
|
||||
currentAssetId: string
|
||||
parentFolderId: string
|
||||
@@ -18,7 +17,6 @@ interface FileViewerLeftSidebarProps {
|
||||
}
|
||||
|
||||
export const FileViewerLeftSidebar: FC<FileViewerLeftSidebarProps> = ({
|
||||
teamId,
|
||||
projectId,
|
||||
currentAssetId,
|
||||
parentFolderId,
|
||||
@@ -34,7 +32,6 @@ export const FileViewerLeftSidebar: FC<FileViewerLeftSidebarProps> = ({
|
||||
const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } = useInfiniteQuery({
|
||||
queryKey: [
|
||||
'folders',
|
||||
teamId,
|
||||
parentFolderId,
|
||||
'children',
|
||||
{
|
||||
@@ -42,8 +39,8 @@ export const FileViewerLeftSidebar: FC<FileViewerLeftSidebarProps> = ({
|
||||
},
|
||||
],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].children.$get({
|
||||
param: { teamId: teamId, folderId: parentFolderId },
|
||||
const res = await client.api.folders[':folderId'].children.$get({
|
||||
param: { folderId: parentFolderId },
|
||||
query: {
|
||||
assetType: 'file',
|
||||
after: pageParam,
|
||||
|
||||
@@ -99,7 +99,7 @@ export function FileViewerRightSidebar({
|
||||
} = useInfiniteQuery({
|
||||
queryKey: isPublic
|
||||
? ['shares', shareId, 'files', file?.id, 'comments']
|
||||
: ['teams', teamId, 'files', file?.id, 'comments'],
|
||||
: ['files', file?.id, 'comments'],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
if (isPublic) {
|
||||
const password = localStorage.getItem(`share_pwd_${shareId}`) || ''
|
||||
@@ -117,8 +117,8 @@ export function FileViewerRightSidebar({
|
||||
if (!res.ok) throw new Error('Failed to fetch comments')
|
||||
return await res.json()
|
||||
} else {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].comments.$get({
|
||||
param: { teamId: teamId, fileId: file!.id! },
|
||||
const res = await client.api.files[':fileId'].comments.$get({
|
||||
param: { fileId: file!.id! },
|
||||
query: { after: pageParam as string },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch comments')
|
||||
@@ -168,8 +168,8 @@ export function FileViewerRightSidebar({
|
||||
if (!res.ok) throw new Error('Failed to create comment')
|
||||
return await res.json()
|
||||
} else {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].comments.$post({
|
||||
param: { teamId: teamId, fileId: file!.id! },
|
||||
const res = await client.api.files[':fileId'].comments.$post({
|
||||
param: { fileId: file!.id! },
|
||||
json: {
|
||||
message: text,
|
||||
attachmentIds: attachmentIds,
|
||||
@@ -185,7 +185,7 @@ export function FileViewerRightSidebar({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: isPublic
|
||||
? ['shares', shareId, 'files', file?.id, 'comments']
|
||||
: ['teams', teamId, 'files', file?.id, 'comments'],
|
||||
: ['files', file?.id, 'comments'],
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
@@ -54,35 +54,35 @@ export function FolderTree({
|
||||
})
|
||||
|
||||
const { data: shareLinksData } = useQuery({
|
||||
queryKey: ['shares', teamId, projectId],
|
||||
queryKey: ['shares', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].shares.$get({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].shares.$get({
|
||||
param: { projectId },
|
||||
query: { first: '100' },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share links')
|
||||
return (await res.json()) as unknown as { data: ShareLinkInfo[] }
|
||||
},
|
||||
enabled: !!teamId && !!projectId,
|
||||
enabled: !!projectId,
|
||||
})
|
||||
|
||||
const { data: collectionsData } = useQuery({
|
||||
queryKey: ['collections', teamId, projectId],
|
||||
queryKey: ['collections', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].collections.$get({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].collections.$get({
|
||||
param: { projectId },
|
||||
query: { first: '100' },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch collections')
|
||||
return (await res.json()) as unknown as { data: CollectionInfo[] }
|
||||
},
|
||||
enabled: !!teamId && !!projectId,
|
||||
enabled: !!projectId,
|
||||
})
|
||||
|
||||
const { mutate: createCollection } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].collections.$post({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].collections.$post({
|
||||
param: { projectId },
|
||||
json: {
|
||||
name: 'Untitled Collection',
|
||||
filter: {
|
||||
@@ -98,7 +98,7 @@ export function FolderTree({
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['collections', teamId, projectId] })
|
||||
queryClient.invalidateQueries({ queryKey: ['collections', projectId] })
|
||||
toast.success('Collection created')
|
||||
navigate({
|
||||
to: '/projects/$projectId/collections/$collectionId',
|
||||
@@ -112,8 +112,8 @@ export function FolderTree({
|
||||
|
||||
const { mutate: createShareLink } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].shares.$post({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].shares.$post({
|
||||
param: { projectId },
|
||||
json: {
|
||||
name: new Date().toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
@@ -126,7 +126,7 @@ export function FolderTree({
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shares', teamId, projectId] })
|
||||
queryClient.invalidateQueries({ queryKey: ['shares', projectId] })
|
||||
toast.success('Share link created')
|
||||
navigate({
|
||||
to: '/projects/$projectId/shares/$shareId',
|
||||
@@ -362,7 +362,6 @@ function FolderTreeItem({
|
||||
} = useInfiniteQuery<AssetInfoPaginatedList>({
|
||||
queryKey: [
|
||||
'folders',
|
||||
teamId,
|
||||
folder.id,
|
||||
'children',
|
||||
{
|
||||
@@ -370,8 +369,8 @@ function FolderTreeItem({
|
||||
},
|
||||
],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].children.$get({
|
||||
param: { teamId: teamId, folderId: folder.id },
|
||||
const res = await client.api.folders[':folderId'].children.$get({
|
||||
param: { folderId: folder.id },
|
||||
query: {
|
||||
assetType: 'folder',
|
||||
after: pageParam as string,
|
||||
|
||||
@@ -161,7 +161,7 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel
|
||||
resetEditor(data)
|
||||
},
|
||||
})
|
||||
const $put = client.api.projects[':projectId'].fields[':fieldId'].$put
|
||||
const $put = client.api.fields[':fieldId'].$put
|
||||
const { mutate: updateField } = useMutation<
|
||||
InferResponseType<typeof $put>,
|
||||
Error,
|
||||
@@ -179,7 +179,7 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel
|
||||
updateFields(newFields)
|
||||
},
|
||||
})
|
||||
const $delete = client.api.projects[':projectId'].fields[':fieldId'].$delete
|
||||
const $delete = client.api.fields[':fieldId'].$delete
|
||||
const { mutate: deleteField } = useMutation<
|
||||
InferResponseType<typeof $delete>,
|
||||
Error,
|
||||
@@ -287,7 +287,7 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel
|
||||
const handleSaveEdit = () => {
|
||||
if (!selectedField) return
|
||||
updateField({
|
||||
param: { projectId: projectId, fieldId: selectedField.id! },
|
||||
param: { fieldId: selectedField.id! },
|
||||
json: {
|
||||
config: {
|
||||
...selectedField.config,
|
||||
@@ -303,7 +303,7 @@ export function ManageFieldsDialog({ projectId, open, onOpenChange }: ManageFiel
|
||||
const handleDelete = () => {
|
||||
if (!selectedField) return
|
||||
if (confirm('Are you sure you want to delete this field?')) {
|
||||
deleteField({ param: { projectId: projectId, fieldId: selectedField.id! } })
|
||||
deleteField({ param: { fieldId: selectedField.id! } })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro
|
||||
},
|
||||
})
|
||||
|
||||
const $put = client.api.teams[':teamId'].projects[':projectId'].$put
|
||||
const $put = client.api.projects[':projectId'].$put
|
||||
const { mutate: updateProject } = useMutation<
|
||||
InferResponseType<typeof $put>,
|
||||
Error,
|
||||
@@ -81,7 +81,7 @@ export function ProjectDialog({ open, onOpenChange, mode, teamId, project }: Pro
|
||||
>({
|
||||
mutationFn: async (payload) => {
|
||||
const res = await $put({
|
||||
param: { teamId: teamId, projectId: project!.id! },
|
||||
param: { projectId: project!.id! },
|
||||
json: payload,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update project')
|
||||
|
||||
@@ -108,8 +108,8 @@ export function SearchFilterDialog({
|
||||
}
|
||||
if (!name) name = 'Untitled Collection'
|
||||
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].collections.$post({
|
||||
param: { teamId, projectId },
|
||||
const res = await client.api.projects[':projectId'].collections.$post({
|
||||
param: { projectId },
|
||||
json: {
|
||||
name,
|
||||
filter: {
|
||||
@@ -125,7 +125,7 @@ export function SearchFilterDialog({
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['collections', teamId, projectId] })
|
||||
queryClient.invalidateQueries({ queryKey: ['collections', projectId] })
|
||||
toast.success('Collection saved')
|
||||
onOpenChange(false)
|
||||
navigate({
|
||||
@@ -141,8 +141,8 @@ export function SearchFilterDialog({
|
||||
const { data: searchResults, isLoading } = useQuery({
|
||||
queryKey: ['search-preview', teamId, assetId, combinedConditions],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].search.$post({
|
||||
param: { teamId, folderId: assetId },
|
||||
const res = await client.api.folders[':folderId'].search.$post({
|
||||
param: { folderId: assetId },
|
||||
json: {
|
||||
assetType: undefined,
|
||||
conditions: combinedConditions,
|
||||
|
||||
@@ -144,8 +144,8 @@ export function AgentFormDialog({
|
||||
const { data: models, isLoading: isModelsLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'providers', selectedProviderId, 'models'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].providers[':id'].models.$get({
|
||||
param: { teamId, id: selectedProviderId! },
|
||||
const res = await client.api.providers[':id'].models.$get({
|
||||
param: { id: selectedProviderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch models')
|
||||
return await res.json()
|
||||
@@ -174,8 +174,8 @@ export function AgentFormDialog({
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: async ({ id, values }: { id: string; values: AgentFormValues }) => {
|
||||
const res = await client.api.teams[':teamId'].agents[':agentId'].$put({
|
||||
param: { teamId, agentId: id },
|
||||
const res = await client.api.agents[':agentId'].$put({
|
||||
param: { agentId: id },
|
||||
json: values,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update agent')
|
||||
|
||||
@@ -82,8 +82,8 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
|
||||
const deleteAgentMutation = useMutation({
|
||||
mutationFn: async (agentId: string) => {
|
||||
const res = await client.api.teams[':teamId'].agents[':agentId'].$delete({
|
||||
param: { teamId, agentId },
|
||||
const res = await client.api.agents[':agentId'].$delete({
|
||||
param: { agentId },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to delete agent')
|
||||
},
|
||||
@@ -112,8 +112,8 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
|
||||
soul?: string
|
||||
skills?: string[]
|
||||
}) => {
|
||||
const res = await client.api.teams[':teamId'].agents[':agentId'].$put({
|
||||
param: { teamId: params.teamId, agentId: params.agentId },
|
||||
const res = await client.api.agents[':agentId'].$put({
|
||||
param: { agentId: params.agentId },
|
||||
json: {
|
||||
name: params.name,
|
||||
type: params.type,
|
||||
|
||||
@@ -105,8 +105,8 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
||||
const { data: editingModels, isLoading: isModelsLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'providers', editingProviderId, 'models'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].providers[':id'].models.$get({
|
||||
param: { teamId, id: editingProviderId! },
|
||||
const res = await client.api.providers[':id'].models.$get({
|
||||
param: { id: editingProviderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch models')
|
||||
return await res.json()
|
||||
@@ -150,8 +150,8 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
||||
// Update Mutation
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: async ({ id, values }: { id: string; values: ProviderFormValues }) => {
|
||||
const res = await client.api.teams[':teamId'].providers[':id'].$put({
|
||||
param: { teamId, id },
|
||||
const res = await client.api.providers[':id'].$put({
|
||||
param: { id },
|
||||
json: {
|
||||
config: values.config,
|
||||
models: values.models,
|
||||
@@ -173,8 +173,8 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
||||
// Delete Mutation
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
const res = await client.api.teams[':teamId'].providers[':id'].$delete({
|
||||
param: { teamId, id },
|
||||
const res = await client.api.providers[':id'].$delete({
|
||||
param: { id },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to delete provider')
|
||||
return await res.json()
|
||||
|
||||
@@ -57,8 +57,8 @@ export const SkillsConfigCard: React.FC<SkillsConfigCardProps> = ({ teamId }) =>
|
||||
// Delete Skill
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
const res = await client.api.teams[':teamId'].skills[':id'].$delete({
|
||||
param: { teamId, id },
|
||||
const res = await client.api.skills[':id'].$delete({
|
||||
param: { id },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to delete skill')
|
||||
},
|
||||
@@ -499,8 +499,8 @@ const ConfigSkillDialog = ({
|
||||
|
||||
setIsSaving(true)
|
||||
try {
|
||||
const res = await client.api.teams[':teamId'].skills[':id'].config.$patch({
|
||||
param: { teamId, id: skill.id },
|
||||
const res = await client.api.skills[':id'].config.$patch({
|
||||
param: { id: skill.id },
|
||||
json: { config: finalConfig },
|
||||
})
|
||||
if (!res.ok) {
|
||||
|
||||
@@ -43,8 +43,8 @@ export default function ShareManager({
|
||||
const { data: shareLink } = useQuery({
|
||||
queryKey: ['share', shareId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].shares[':shareId'].$get({
|
||||
param: { teamId, shareId },
|
||||
const res = await client.api.shares[':shareId'].$get({
|
||||
param: { shareId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share link')
|
||||
return (await res.json()) as unknown as ShareLinkInfo
|
||||
@@ -101,8 +101,8 @@ export default function ShareManager({
|
||||
} = useInfiniteQuery<AssetInfoPaginatedList>({
|
||||
queryKey: ['folder-children', teamId, currentFolderId, 'folder'],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].children.$get({
|
||||
param: { teamId, folderId: currentFolderId! },
|
||||
const res = await client.api.folders[':folderId'].children.$get({
|
||||
param: { folderId: currentFolderId! },
|
||||
query: {
|
||||
assetType: 'folder',
|
||||
after: pageParam as string,
|
||||
@@ -124,8 +124,8 @@ export default function ShareManager({
|
||||
} = useInfiniteQuery<AssetInfoPaginatedList>({
|
||||
queryKey: ['folder-children', teamId, currentFolderId, 'file'],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].children.$get({
|
||||
param: { teamId, folderId: currentFolderId! },
|
||||
const res = await client.api.folders[':folderId'].children.$get({
|
||||
param: { folderId: currentFolderId! },
|
||||
query: {
|
||||
assetType: 'file',
|
||||
after: pageParam as string,
|
||||
@@ -198,11 +198,11 @@ export default function ShareManager({
|
||||
onClearSelection: handleClearSelection,
|
||||
})
|
||||
|
||||
const $removeFromShare = client.api.teams[':teamId'].shares[':shareId'].assets[':assetId'].$delete
|
||||
const $removeFromShare = client.api.shares[':shareId'].assets[':assetId'].$delete
|
||||
const { mutate: removeFromShare } = useMutation({
|
||||
mutationFn: async (assetId: string) => {
|
||||
const res = await $removeFromShare({
|
||||
param: { teamId, shareId, assetId },
|
||||
param: { shareId, assetId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to remove')
|
||||
},
|
||||
@@ -306,7 +306,7 @@ export default function ShareManager({
|
||||
}
|
||||
/>
|
||||
<div style={{ width: rightSidebarWidth }} className="flex-shrink-0">
|
||||
<ShareSettingsSidebar teamId={teamId} shareLink={shareLink} />
|
||||
<ShareSettingsSidebar shareLink={shareLink} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -20,11 +20,10 @@ import React, { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { DateTimePicker } from '@/ui/components/datetime-picker'
|
||||
interface ShareSettingsSidebarProps {
|
||||
teamId: string
|
||||
shareLink: ShareLinkInfo
|
||||
}
|
||||
|
||||
export function ShareSettingsSidebar({ teamId, shareLink }: ShareSettingsSidebarProps) {
|
||||
export function ShareSettingsSidebar({ shareLink }: ShareSettingsSidebarProps) {
|
||||
const queryClient = useQueryClient()
|
||||
const [password, setPassword] = useState('')
|
||||
const [expireAt, setExpireAt] = useState<Date | undefined>(
|
||||
@@ -45,18 +44,18 @@ export function ShareSettingsSidebar({ teamId, shareLink }: ShareSettingsSidebar
|
||||
enabled: !!shareLink.projectId,
|
||||
})
|
||||
|
||||
const $updateShare = client.api.teams[':teamId'].shares[':shareId'].$put
|
||||
const $updateShare = client.api.shares[':shareId'].$put
|
||||
const { mutate: updateShare } = useMutation({
|
||||
mutationFn: async (json: UpdateShareLinkRequest) => {
|
||||
const res = await $updateShare({
|
||||
param: { teamId, shareId: shareLink.id },
|
||||
param: { shareId: shareLink.id },
|
||||
json,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shares', teamId, shareLink.projectId] })
|
||||
queryClient.invalidateQueries({ queryKey: ['shares', shareLink.projectId] })
|
||||
queryClient.invalidateQueries({ queryKey: ['share', shareLink.id] })
|
||||
toast.success('Settings updated')
|
||||
},
|
||||
|
||||
@@ -44,7 +44,7 @@ export function useFileSystemDnd({
|
||||
},
|
||||
})
|
||||
|
||||
const $reorderFolder = client.api.teams[':teamId'].folders[':folderId'].order.$patch
|
||||
const $reorderFolder = client.api.folders[':folderId'].order.$patch
|
||||
const { mutate: reorderFolder } = useMutation<
|
||||
InferResponseType<typeof $reorderFolder, 200>,
|
||||
Error,
|
||||
@@ -57,7 +57,7 @@ export function useFileSystemDnd({
|
||||
},
|
||||
})
|
||||
|
||||
const $reorderFile = client.api.teams[':teamId'].files[':fileId'].order.$patch
|
||||
const $reorderFile = client.api.files[':fileId'].order.$patch
|
||||
const { mutate: reorderFile } = useMutation<
|
||||
InferResponseType<typeof $reorderFile, 200>,
|
||||
Error,
|
||||
@@ -70,7 +70,7 @@ export function useFileSystemDnd({
|
||||
},
|
||||
})
|
||||
|
||||
const $addAssetToShare = client.api.teams[':teamId'].shares[':shareId'].assets.$post
|
||||
const $addAssetToShare = client.api.shares[':shareId'].assets.$post
|
||||
const { mutate: addAssetToShare } = useMutation<
|
||||
{ addedCount: number },
|
||||
Error,
|
||||
@@ -128,7 +128,7 @@ export function useFileSystemDnd({
|
||||
|
||||
addAssetToShare(
|
||||
{
|
||||
param: { teamId, shareId },
|
||||
param: { shareId },
|
||||
json: { assetIds },
|
||||
},
|
||||
{
|
||||
@@ -139,7 +139,7 @@ export function useFileSystemDnd({
|
||||
toast.success(`Added ${data.addedCount} item(s) to share link`)
|
||||
}
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['shares', teamId, projectId],
|
||||
queryKey: ['shares', projectId],
|
||||
})
|
||||
onClearSelection()
|
||||
},
|
||||
@@ -178,8 +178,7 @@ export function useFileSystemDnd({
|
||||
if (isFolder) {
|
||||
reorderFolder(
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
param: { teamId: teamId, folderId: draggedId } as any,
|
||||
param: { folderId: draggedId },
|
||||
json:
|
||||
position === 'before'
|
||||
? { beforeIndex: targetItem.sortIndex ?? undefined }
|
||||
@@ -201,8 +200,7 @@ export function useFileSystemDnd({
|
||||
} else {
|
||||
reorderFile(
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
param: { teamId: teamId, fileId: draggedId } as any,
|
||||
param: { fileId: draggedId },
|
||||
json:
|
||||
position === 'before'
|
||||
? { beforeIndex: targetItem.sortIndex ?? undefined }
|
||||
|
||||
@@ -16,13 +16,11 @@ const projectInfoQueryOptions = (projectId: string) => ({
|
||||
},
|
||||
})
|
||||
|
||||
const collectionInfoQueryOptions = (teamId: string, projectId: string, collectionId: string) => ({
|
||||
queryKey: ['collections', teamId, projectId, collectionId],
|
||||
const collectionInfoQueryOptions = (collectionId: string) => ({
|
||||
queryKey: ['collections', collectionId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].collections[
|
||||
':collectionId'
|
||||
].$get({
|
||||
param: { teamId, projectId, collectionId },
|
||||
const res = await client.api.collections[':collectionId'].$get({
|
||||
param: { collectionId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch collection')
|
||||
return await res.json()
|
||||
@@ -40,17 +38,14 @@ function CollectionPage() {
|
||||
const { data: projectInfo } = useSuspenseQuery(projectInfoQueryOptions(projectId))
|
||||
|
||||
const { data: collection, refetch: refetchCollection } = useQuery({
|
||||
...collectionInfoQueryOptions(teamId || '', projectId, collectionId),
|
||||
enabled: !!teamId,
|
||||
...collectionInfoQueryOptions(collectionId),
|
||||
})
|
||||
|
||||
const { mutate: updateCollection } = useMutation({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
mutationFn: async (updates: { name?: string; filter?: any }) => {
|
||||
const res = await client.api.teams[':teamId'].projects[':projectId'].collections[
|
||||
':collectionId'
|
||||
].$patch({
|
||||
param: { teamId: teamId!, projectId, collectionId },
|
||||
const res = await client.api.collections[':collectionId'].$patch({
|
||||
param: { collectionId },
|
||||
json: updates,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update collection')
|
||||
@@ -64,15 +59,15 @@ function CollectionPage() {
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryKey: ['folders', rootFolderId!],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: rootFolderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch folder')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
enabled: !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder || !collection) {
|
||||
|
||||
@@ -34,7 +34,7 @@ function FileViewPage() {
|
||||
const [leftSidebarWidth, setLeftSidebarWidth] = useState(280)
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const [annotations, setAnnotations] = useState<Annotation[]>([])
|
||||
const $patchMetadata = client.api.teams[':teamId'].files[':fileId'].metadata.$patch
|
||||
const $patchMetadata = client.api.files[':fileId'].metadata.$patch
|
||||
const { mutate: patchMetadata } = useMutation<
|
||||
InferResponseType<typeof $patchMetadata>,
|
||||
Error,
|
||||
@@ -65,10 +65,10 @@ function FileViewPage() {
|
||||
isError: isStackError,
|
||||
isFetching: isStackFetching,
|
||||
} = useQuery({
|
||||
queryKey: ['teams', teamId, 'files', fileId],
|
||||
queryKey: ['files', fileId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].$get({
|
||||
param: { teamId: teamId!, fileId: fileId },
|
||||
const res = await client.api.files[':fileId'].$get({
|
||||
param: { fileId: fileId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch stack')
|
||||
return await res.json()
|
||||
@@ -83,10 +83,10 @@ function FileViewPage() {
|
||||
isError: isVersionError,
|
||||
isFetching: isVersionFetching,
|
||||
} = useQuery({
|
||||
queryKey: ['teams', teamId, 'files', versionAssetId],
|
||||
queryKey: ['files', versionAssetId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].$get({
|
||||
param: { teamId: teamId!, fileId: versionAssetId! },
|
||||
const res = await client.api.files[':fileId'].$get({
|
||||
param: { fileId: versionAssetId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch version')
|
||||
return await res.json()
|
||||
@@ -96,10 +96,10 @@ function FileViewPage() {
|
||||
})
|
||||
|
||||
const { data: versionsList } = useQuery({
|
||||
queryKey: ['projects', projectId, 'version_stacks', fileId, 'versions'],
|
||||
queryKey: ['version_stacks', fileId, 'versions'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].version_stacks[':stackId'].versions.$get({
|
||||
param: { projectId: projectId, stackId: fileId },
|
||||
const res = await client.api.version_stacks[':stackId'].versions.$get({
|
||||
param: { stackId: fileId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch versions')
|
||||
return await res.json()
|
||||
@@ -180,13 +180,13 @@ function FileViewPage() {
|
||||
if (!teamId) return
|
||||
patchMetadata(
|
||||
{
|
||||
param: { teamId: teamId, fileId: activeFileId },
|
||||
param: { fileId: activeFileId },
|
||||
json: [{ key: fieldId, value }] as InferRequestType<typeof $patchMetadata>['json'],
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'files', activeFileId],
|
||||
queryKey: ['files', activeFileId],
|
||||
})
|
||||
},
|
||||
},
|
||||
@@ -216,7 +216,6 @@ function FileViewPage() {
|
||||
<>
|
||||
<div style={{ width: leftSidebarWidth }} className="flex-shrink-0">
|
||||
<FileViewerLeftSidebar
|
||||
teamId={teamId!}
|
||||
projectId={projectId}
|
||||
currentAssetId={activeFileId}
|
||||
parentFolderId={
|
||||
|
||||
@@ -29,15 +29,15 @@ function FolderPage() {
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryKey: ['folders', rootFolderId!],
|
||||
queryFn: () =>
|
||||
(async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: rootFolderId! },
|
||||
})
|
||||
return await res.json()
|
||||
})(),
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
enabled: !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
|
||||
@@ -29,15 +29,15 @@ function ProjectPage() {
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryKey: ['folders', rootFolderId!],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: rootFolderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch folder')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
enabled: !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
|
||||
@@ -29,15 +29,15 @@ function RecentlyDeletedPage() {
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryKey: ['folders', rootFolderId!],
|
||||
queryFn: () =>
|
||||
(async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: rootFolderId! },
|
||||
})
|
||||
return await res.json()
|
||||
})(),
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
enabled: !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
|
||||
@@ -29,15 +29,15 @@ function SharePage() {
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryKey: ['folders', rootFolderId!],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
const res = await client.api.folders[':folderId'].$get({
|
||||
param: { folderId: rootFolderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch folder')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
enabled: !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
|
||||
Reference in New Issue
Block a user