From 9be65337b0d63a79b31ec0273a341450ce93e86c Mon Sep 17 00:00:00 2001 From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com> Date: Wed, 17 Jan 2024 08:55:24 +0300 Subject: [PATCH] fixed error on posting cases --- routes/processes/case.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/routes/processes/case.js b/routes/processes/case.js index 90bdfdc..0872f0e 100644 --- a/routes/processes/case.js +++ b/routes/processes/case.js @@ -7,6 +7,7 @@ const { date } = require("joi"); const { caseAssign } = require("../../models/case_assign"); const { Client } = require("../../models/client"); const { User } = require("../../models/user"); +const { masterFacility } = require("../../models/master_facility"); router.post("/assign", async (req, res) => { let phone_no = req.body.phone_no; @@ -30,6 +31,11 @@ router.post("/assign", async (req, res) => { }, attributes: ["code", "name"] }); + let check_user = await User.findOne({ + where: { + phone_no + } + }); if (!check_client) return res.json({ @@ -42,11 +48,7 @@ router.post("/assign", async (req, res) => { message: `Client ${clinic_number} does not belong to your facility, the client belongs to ${get_facility.name}` }); - let check_user = await User.findOne({ - where: { - phone_no - } - }); + if (!check_user) return res.json({