ultisuite-client/lib/drive/open-ultidraw-document.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

24 lines
782 B
TypeScript

import { apiClient } from "@/lib/api/client"
import type { DriveFileInfo } from "@/lib/api/types"
import { stashDriveEditorReturnTo } from "@/lib/drive/drive-editor-return"
import { buildDriveDrawEditHref } from "@/lib/drive/drive-url"
import type { OpenDriveItemRouter } from "@/lib/drive/drive-open-item"
export async function openUltidrawDocument(
file: DriveFileInfo,
router: OpenDriveItemRouter
) {
stashDriveEditorReturnTo()
let fileId = file.file_id
if (!fileId) {
const info = await apiClient.get<DriveFileInfo>(
`/drive/files/info${file.path.startsWith("/") ? file.path : `/${file.path}`}`
)
fileId = info.file_id
}
if (!fileId) {
throw new Error("Identifiant du dessin introuvable")
}
router.push(buildDriveDrawEditHref(fileId))
}