diff --git a/src/views/Batches/Batch.jsx b/src/views/Batches/Batch.jsx index 996a5f49..aae34d30 100644 --- a/src/views/Batches/Batch.jsx +++ b/src/views/Batches/Batch.jsx @@ -229,6 +229,10 @@ const Batch = (props) => { NP.start(); updateBatch(Number(id), dataToSave).then(data => { setAlert("Batch updated successfully.", "success"); + if(dataToSave.status === "Enrollment Complete -- To Be Started" || dataToSave.status ==="Complete"){ + dataToSave.id = Number(id); + sendEmailOnCreateBatch(dataToSave); + } }).catch(err => { setAlert("Unable to update batch.", "error"); diff --git a/src/views/Batches/Batches.jsx b/src/views/Batches/Batches.jsx index ac9defb6..655a1915 100644 --- a/src/views/Batches/Batches.jsx +++ b/src/views/Batches/Batches.jsx @@ -427,7 +427,6 @@ const Batches = (props) => { NP.start(); setLoading(true); - console.log("isSearchEnable:", isSearchEnable); if (isSearchEnable) { await getBatchesBySearchFilter( selectedTab, @@ -645,7 +644,11 @@ const Batches = (props) => { setFormErrors(data.data.errors); } else { setAlert("Batch created successfully.", "success"); - sendEmailOnCreateBatch(data.data.data.createBatch.batch.name) + // if(data.data.data.createBatch.status === "Enrollment Complete -- To Be Started"){ + // dataToSave.id = data.data.data.createBatch.batch.id; + // sendEmailOnCreateBatch(dataToSave); + // } + getBatches(); setModalShow(false); history.push(`/batch/${data.data.data.createBatch.batch.id}`); diff --git a/src/views/Batches/batchActions.js b/src/views/Batches/batchActions.js index f4523d77..49a8b53d 100644 --- a/src/views/Batches/batchActions.js +++ b/src/views/Batches/batchActions.js @@ -354,10 +354,10 @@ export const searchStudents = async(searchValue)=>{ /* Send Emails on Creation and Updation */ -export const sendEmailOnCreateBatch = async (batchName) => { +export const sendEmailOnCreateBatch = async (batchInfo) => { let url = `batch/sendEmailONCreationAndUpdate`; return await api.post(url, { - name:batchName + data:batchInfo }).then(data => { return data; }).catch(error => {