chore: update remove file function logic (#1259)
* chore: update remove file function logic * fix: workspace file delete endpoint
This commit is contained in:
parent
d09f410f21
commit
e7af3da115
4 changed files with 18 additions and 24 deletions
|
|
@ -9,6 +9,8 @@ import { useDropzone } from "react-dropzone";
|
|||
import { Transition, Dialog } from "@headlessui/react";
|
||||
// services
|
||||
import fileServices from "services/file.service";
|
||||
// hooks
|
||||
import useWorkspaceDetails from "hooks/use-workspace-details";
|
||||
// ui
|
||||
import { PrimaryButton, SecondaryButton } from "components/ui";
|
||||
// icons
|
||||
|
|
@ -35,6 +37,8 @@ export const ImageUploadModal: React.FC<Props> = ({
|
|||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
const { workspaceDetails } = useWorkspaceDetails();
|
||||
|
||||
const onDrop = useCallback((acceptedFiles: File[]) => {
|
||||
setImage(acceptedFiles[0]);
|
||||
}, []);
|
||||
|
|
@ -62,12 +66,7 @@ export const ImageUploadModal: React.FC<Props> = ({
|
|||
setIsImageUploading(false);
|
||||
setImage(null);
|
||||
|
||||
if (value) {
|
||||
const index = value.indexOf(".com");
|
||||
const asset = value.substring(index + 5);
|
||||
|
||||
fileServices.deleteUserFile(asset);
|
||||
}
|
||||
if (value) fileServices.deleteUserFile(value);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
|
@ -81,12 +80,7 @@ export const ImageUploadModal: React.FC<Props> = ({
|
|||
setIsImageUploading(false);
|
||||
setImage(null);
|
||||
|
||||
if (value) {
|
||||
const index = value.indexOf(".com");
|
||||
const asset = value.substring(index + 5);
|
||||
|
||||
fileServices.deleteFile(asset);
|
||||
}
|
||||
if (value && workspaceDetails) fileServices.deleteFile(workspaceDetails.id, value);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue