diff --git a/frontend/src/components/OfficeHome.tsx b/frontend/src/components/OfficeHome.tsx index 4a072dc..3679ead 100644 --- a/frontend/src/components/OfficeHome.tsx +++ b/frontend/src/components/OfficeHome.tsx @@ -26,8 +26,9 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank }: Office useEffect(() => { // Fetch all files from root directory (as a simple way to find recent files of this type) // Or we could use a search endpoint. For now we will fetch the root directory and filter. - api.listFiles('.') - .then(files => { + api.listDirectory('.') + .then(data => { + const files: FileItem[] = data.files || []; const ext = type === 'docs' ? '.docx' : '.pptx'; const filtered = files .filter(f => !f.is_dir && f.name.endsWith(ext) && !f.is_trashed) @@ -44,8 +45,8 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank }: Office const handleCreateBlank = async () => { try { - const res = await api.client.post('/onlyoffice/create', { type: type === 'docs' ? 'word' : 'slide' }); - const { path, name } = res.data; + const res = await api.createOnlyOfficeFile(type === 'docs' ? 'word' : 'slide'); + const { path, name } = res; const newFile: FileItem = { name, diff --git a/frontend/src/components/OnlyOfficeEditor.tsx b/frontend/src/components/OnlyOfficeEditor.tsx index df5ba62..aae595c 100644 --- a/frontend/src/components/OnlyOfficeEditor.tsx +++ b/frontend/src/components/OnlyOfficeEditor.tsx @@ -24,8 +24,8 @@ export default function OnlyOfficeEditor({ file, type, onClose }: OnlyOfficeEdit useEffect(() => { // We need a short-lived download token to pass to the Document Server - api.client.get('/auth/download-token') - .then(res => setDownloadToken(res.data.token)) + api.createDownloadToken() + .then((token: string) => setDownloadToken(token)) .catch(console.error); }, [file.path]); diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 730a6aa..080b818 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -468,6 +468,15 @@ class ApiClient { } return url; } + + // --- OnlyOffice --- + async createOnlyOfficeFile(type: 'word' | 'slide') { + const res = await this.request('/api/onlyoffice/create', { + method: 'POST', + body: { type }, + }); + return res.json(); + } } export const api = new ApiClient();