Merge branch 'preprod' into staging
This commit is contained in:
commit
571251b305
@ -159,13 +159,19 @@ export default class FilesController extends ApiController {
|
|||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const fileEntity = await this.filesService.deleteKeyAndArchive(uid);
|
const fileEntity = await this.filesService.deleteKeyAndArchive(uid);
|
||||||
if (
|
|
||||||
!(fileFoundEntity.document!.files?.find((file) => file.archived_at === null && file.uid !== uid)) &&
|
const isDocumentEmpty = !fileFoundEntity.document!.files?.find((file) => file.archived_at === null && file.uid !== uid);
|
||||||
fileFoundEntity.document!.document_type!.name === "Autres documents"
|
if (isDocumentEmpty && fileFoundEntity.document!.document_type!.name === "Autres documents") {
|
||||||
) {
|
|
||||||
await this.documentService.delete(fileFoundEntity.document!.uid!);
|
await this.documentService.delete(fileFoundEntity.document!.uid!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update document status to 'ASKED' if the deleted file was the last one
|
||||||
|
if (fileFoundEntity.document && fileFoundEntity.document.uid && isDocumentEmpty) {
|
||||||
|
const documentToUpdate = Document.hydrate<Document>(fileFoundEntity.document);
|
||||||
|
documentToUpdate.document_status = "ASKED";
|
||||||
|
this.documentService.update(fileFoundEntity.document.uid, documentToUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
//Hydrate ressource with prisma entity
|
//Hydrate ressource with prisma entity
|
||||||
const file = File.hydrate<File>(fileEntity, { strategy: "excludeAll" });
|
const file = File.hydrate<File>(fileEntity, { strategy: "excludeAll" });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user