diff --git a/src/controllers/07-task-controller.ts b/src/controllers/07-task-controller.ts index 22357b4..77a593b 100644 --- a/src/controllers/07-task-controller.ts +++ b/src/controllers/07-task-controller.ts @@ -32,7 +32,15 @@ import { } from "../services/permission"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; -import { deleteFile, fileLocation, getFile, getPresigned, listFile, setFile } from "../utils/minio"; +import { + deleteFile, + deleteFolder, + fileLocation, + getFile, + getPresigned, + listFile, + setFile, +} from "../utils/minio"; import { queryOrNot } from "../utils/relation"; const MANAGE_ROLES = ["system", "head_of_admin", "admin", "document_checker"]; @@ -429,6 +437,9 @@ export class TaskController extends Controller { if (!record) throw notFoundError("Task Order"); await permissionCheck(req.user, record.registeredBranch); + + await Promise.all([deleteFolder(fileLocation.task.attachment(taskOrderId))]); + await tx.taskOrder.delete({ where: { id: taskOrderId } }); }); } }