Skip to content

Commit

Permalink
fixed error on assign case
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald-pro committed Jan 26, 2024
1 parent 21b24e7 commit eec559a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions routes/processes/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ router.post("/assign", async (req, res) => {
message: `Phone number: ${phone_no} is not active in the system.`
});

let existing_assigned = await caseAssign.count({
let existing_assigned = await caseAssign.findOne({
where: {
client_id: check_client.id
}
});

if (existing_assigned === 0) {
if (existing_assigned) {
return res.status(400).json({
success: false,
message: `Client ${clinic_number} is already assigned to a case manager`
});
} else {
try {
await caseAssign.create({
client_id: check_client.id,
Expand All @@ -94,11 +99,6 @@ router.post("/assign", async (req, res) => {
message: `Error occurred while assigning a case. Please try again.`
});
}
} else {
return res.status(400).json({
success: false,
message: `Client ${clinic_number} is already assigned to a case manager`
});
}
});

Expand Down

0 comments on commit eec559a

Please sign in to comment.