mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
카테고리 페이지에 파일 제거 버튼 구현
This commit is contained in:
@@ -16,9 +16,9 @@
|
||||
import AddToCategoryBottomSheet from "./AddToCategoryBottomSheet.svelte";
|
||||
import DownloadStatus from "./DownloadStatus.svelte";
|
||||
import {
|
||||
requestFileRemovalFromCategory,
|
||||
requestFileDownload,
|
||||
requestFileAdditionToCategory,
|
||||
requestFileRemovalFromCategory,
|
||||
} from "./service";
|
||||
|
||||
import IconClose from "~icons/material-symbols/close";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { callPostApi } from "$lib/hooks";
|
||||
import { getFileCache, storeFileCache, downloadFile } from "$lib/modules/file";
|
||||
import type { CategoryFileAddRequest, CategoryFileRemoveRequest } from "$lib/server/schemas";
|
||||
import type { CategoryFileAddRequest } from "$lib/server/schemas";
|
||||
|
||||
export { requestCategoryCreation } from "$lib/services/category";
|
||||
export { requestCategoryCreation, requestFileRemovalFromCategory } from "$lib/services/category";
|
||||
|
||||
export const requestFileDownload = async (
|
||||
fileId: number,
|
||||
@@ -23,11 +23,3 @@ export const requestFileAdditionToCategory = async (fileId: number, categoryId:
|
||||
});
|
||||
return res.ok;
|
||||
};
|
||||
|
||||
export const requestFileRemovalFromCategory = async (fileId: number, categoryId: number) => {
|
||||
const res = await callPostApi<CategoryFileRemoveRequest>(
|
||||
`/api/category/${categoryId}/file/remove`,
|
||||
{ file: fileId },
|
||||
);
|
||||
return res.ok;
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import RenameCategoryModal from "./RenameCategoryModal.svelte";
|
||||
import {
|
||||
requestCategoryCreation,
|
||||
requestFileRemovalFromCategory,
|
||||
requestCategoryRename,
|
||||
requestCategoryDeletion,
|
||||
} from "./service";
|
||||
@@ -49,13 +50,17 @@
|
||||
{#if $info}
|
||||
<Category
|
||||
info={$info}
|
||||
onFileClick={({ id }) => goto(`/file/${id}`)}
|
||||
onFileRemoveClick={({ id }) => {
|
||||
requestFileRemovalFromCategory(id, data.id as number);
|
||||
info = getCategoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
|
||||
}}
|
||||
onSubCategoryClick={({ id }) => goto(`/category/${id}`)}
|
||||
onSubCategoryCreateClick={() => (isCreateCategoryModalOpen = true)}
|
||||
onSubCategoryMenuClick={(subCategory) => {
|
||||
selectedSubCategory = subCategory;
|
||||
isSubCategoryMenuBottomSheetOpen = true;
|
||||
}}
|
||||
onFileClick={({ id }) => goto(`/file/${id}`)}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { encryptString } from "$lib/modules/crypto";
|
||||
import type { SelectedCategory } from "$lib/molecules/Categories";
|
||||
import type { CategoryRenameRequest } from "$lib/server/schemas";
|
||||
|
||||
export { requestCategoryCreation } from "$lib/services/category";
|
||||
export { requestCategoryCreation, requestFileRemovalFromCategory } from "$lib/services/category";
|
||||
|
||||
export const requestCategoryRename = async (category: SelectedCategory, newName: string) => {
|
||||
const newNameEncrypted = await encryptString(newName, category.dataKey);
|
||||
|
||||
Reference in New Issue
Block a user