Esatablishment inactive api updated for inactive action
This commit is contained in:
parent
b05320bf90
commit
bdbaca0119
@ -605,6 +605,26 @@ exports.updateEstablishment = async (req, res) => {
|
||||
// update establishment
|
||||
await establishment.update(estData);
|
||||
|
||||
if (req.body.is_active === false) {
|
||||
await EstablishmentUser.update(
|
||||
{
|
||||
is_active : false,
|
||||
updated_by: req.user.id,
|
||||
updated_at: new Date()
|
||||
},
|
||||
{ where: { establishment_id: id } }
|
||||
);
|
||||
|
||||
await EstablishmentProduct.update(
|
||||
{
|
||||
is_active : false,
|
||||
updated_by: req.user.id,
|
||||
updated_at: new Date()
|
||||
},
|
||||
{ where: { establishment_id: id } }
|
||||
);
|
||||
}
|
||||
|
||||
// update user if needed
|
||||
if (establishment_user) {
|
||||
const user = await EstablishmentUser.findOne({where:{establishment_id:id}});
|
||||
@ -613,6 +633,7 @@ exports.updateEstablishment = async (req, res) => {
|
||||
name: establishment_user.name,
|
||||
email: establishment_user.email
|
||||
};
|
||||
|
||||
if (establishment_user.password) {
|
||||
updateUser.password = await bcrypt.hash(establishment_user.password,10);
|
||||
}
|
||||
@ -680,7 +701,6 @@ exports.updateEstablishment = async (req, res) => {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ADD new active products
|
||||
const newItems = incoming.filter(p => !oldIds.includes(p.product_id));
|
||||
|
||||
@ -716,8 +736,6 @@ exports.updateEstablishment = async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return res.json({ status:"success", message:"Updated successfully" , data:"" });
|
||||
|
||||
} catch(err) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user