Skip to content

Commit

Permalink
Fixed XXS issue and added code to reset some state when modal is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
ydahal1 committed Jan 19, 2024
1 parent bc7fad0 commit db682a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ const AddEditJobMonitoringModal = ({
};

const handleCancel = () => {
form.resetFields();
setIntermittentScheduling({ schedulingType: 'daily', id: uuidv4() });
setCompleteSchedule([]);
form.resetFields();
setDisplayAddJobMonitoringModal(false);
setActiveTab('0');
setVisitedTabs(['0']);
setSelectedMonitoring(null);
setEditingData({ isEditing: false });
setErroneousTabs([]);
setErroneousScheduling(false);
setActiveTab('0');
setMonitoringScope(null);
};

//Render footer buttons based on active tab
Expand Down
16 changes: 14 additions & 2 deletions server/routes/jobmonitoring/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ router.post(
// Validate the req.body
const errors = validationResult(req);
if (!errors.isEmpty()) {
logger.error(errors);
return res.status(400).json({ errors: errors.array() });
}

Expand All @@ -113,11 +114,22 @@ router.post(
payload.approvedAt = null;

//Update the job monitoring
await JobMonitoring.update(req.body, {
const updatedRows = await JobMonitoring.update(req.body, {
where: { id: req.body.id },
returning: true,
});
res.status(200).send(payload);

//If no rows were updated, then the job monitoring does not exist
if (updatedRows[0] === 0) {
return res.status(404).send("Job monitoring not found");
}

//If updated - Get the updated job monitoring
const updatedJob = await JobMonitoring.findByPk(req.body.id);
res.status(200).send(updatedJob);

} catch (err) {
console.log(err)
logger.error(err);
res.status(500).send("Failed to update job monitoring");
}
Expand Down

0 comments on commit db682a3

Please sign in to comment.