updated and added notification section

This commit is contained in:
ROSHAN GARG 2024-08-07 11:32:27 +05:30
parent 62a4e904df
commit 2d1e461510

View File

@ -201,6 +201,16 @@ export const updateKycStatus = async (req, res) => {
return res.status(403).json({ message: "Access denied" }); return res.status(403).json({ message: "Access denied" });
} }
if (status === "reject") {
await rejectKYC(req.user._id, rejectionReason);
await Notification.create({
title: "KYC Rejected",
msg: rejectionReason,
kyc_ref: kyc._id,
added_for: req.user._id,
userType: req.userType,
});
}
// Update the status // Update the status
if (status) { if (status) {
kyc.status = status; kyc.status = status;
@ -209,7 +219,7 @@ export const updateKycStatus = async (req, res) => {
// Add rejection reason to notes if status is reject // Add rejection reason to notes if status is reject
if (kyc.status === "reject" || status === "reject") { if (kyc.status === "reject" || status === "reject") {
// kyc.rejection_reason = rejectionReason; // kyc.rejection_reason = rejectionReason;
await rejectKYC(req.user._id, rejectionReason);
kyc.notes.push({ kyc.notes.push({
message: rejectionReason, message: rejectionReason,
user: user, user: user,