refactor frontend warren move api

This commit is contained in:
2025-07-30 21:56:50 +02:00
parent 3b141cc7cd
commit 956c0c6f65
4 changed files with 40 additions and 30 deletions

View File

@@ -303,34 +303,23 @@ export async function fetchFile(
export async function moveFile(
warrenId: string,
path: string,
fileName: string,
currentPath: string,
targetPath: string
): Promise<{ success: boolean }> {
if (!path.endsWith('/')) {
path += '/';
}
path += fileName;
if (!targetPath.endsWith('/')) {
targetPath += '/';
}
targetPath += fileName;
const { status } = await useFetch(getApiUrl(`warrens/files/mv`), {
method: 'POST',
headers: getApiHeaders(),
body: JSON.stringify({
warrenId,
path,
targetPath,
path: currentPath,
targetPath: targetPath,
}),
});
if (status.value !== 'success') {
toast.error('Move', {
id: 'MOVE_FILE_TOAST',
description: `Failed to move ${fileName}`,
description: `Failed to move file`,
});
return { success: false };
}
@@ -338,8 +327,8 @@ export async function moveFile(
await refreshNuxtData('current-directory');
toast.success('Rename', {
id: 'RENAME_FILE_TOAST',
description: `Successfully moved ${fileName} to ${targetPath}`,
id: 'MOVE_FILE_TOAST',
description: `Successfully moved file`,
});
return {