exports.sendOtp = async (req, res) => { try { const { phone, name, otpToUse, verificationLink, isExisting } = req.body; if (!phone || !otpToUse) { return res.status(400).json({ success: false, message: 'Phone and OTP required' }); } // Mock WhatsApp API call console.log(`[WhatsApp Mock] Sending OTP ${otpToUse} to ${phone}`); console.log(`[WhatsApp Mock] Verification Link: ${verificationLink}`); // In production, use axios to call the real WhatsApp provider API here. /* await axios.post(process.env.WHATSAPP_API_URL, { to: phone, type: "template", template: { ... } }, { headers: { 'Authorization': `Bearer ${process.env.WHATSAPP_API_KEY}` } }); */ res.json({ success: true, message: 'OTP sent via WhatsApp successfully' }); } catch (error) { console.error('Error sending WhatsApp OTP:', error); res.status(500).json({ success: false, message: 'Failed to send OTP' }); } }; exports.sendReport = async (req, res) => { try { const { phone, name, overallScore, origin } = req.body; if (!phone || overallScore === undefined) { return res.status(400).json({ success: false, message: 'Phone and overallScore required' }); } // Mock WhatsApp API call console.log(`[WhatsApp Mock] Sending Report (Score: ${overallScore}) to ${phone}`); res.json({ success: true, message: 'Report sent via WhatsApp successfully' }); } catch (error) { console.error('Error sending WhatsApp Report:', error); res.status(500).json({ success: false, message: 'Failed to send report' }); } };