Skip to content

Commit

Permalink
added batch email trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaksharma-dev committed Sep 27, 2024
1 parent 1a58d52 commit 78d6117
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/views/Batches/Batch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions src/views/Batches/Batches.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ const Batches = (props) => {
NP.start();
setLoading(true);

console.log("isSearchEnable:", isSearchEnable);
if (isSearchEnable) {
await getBatchesBySearchFilter(
selectedTab,
Expand Down Expand Up @@ -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}`);
Expand Down
4 changes: 2 additions & 2 deletions src/views/Batches/batchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 78d6117

Please sign in to comment.