IO-771 Reassign documents between jobs.

This commit is contained in:
Patrick Fic
2021-03-16 13:15:26 -07:00
parent c29337c469
commit bf389e4dcb

View File

@@ -54,11 +54,20 @@ export default function JobsDocumentsGalleryReassign({ galleryImages }) {
const res = await axios.post("/media/rename", {
documents: selectedImages.map((i) => {
return { id: i.id, from: i.key, to: i.key.replace("null", jobid) };
//Need to check if the current key folder is null, or another job.
const currentKeys = i.key.split("/");
currentKeys[1] = jobid;
currentKeys.join("/");
return { id: i.id, from: i.key, to: currentKeys.join("/") };
}),
});
console.log(res.data);
res.data
.filter((d) => d.error)
.forEach((d) => {
notification["error"]({ message: t("documents.errors.updating") });
console.error("Error updating job document", d);
});
const proms = [];