/**
 * NotificationManager: Handles WhatsApp notifications for Curio
 */

const whatsappService = require('./whatsappService');

class NotificationManager {
    constructor() {
        this.notificationsSent = [];
    }

    async sendRescheduleAlert(patientPhone, tenantName, oldTime, newTime) {
        this.notificationsSent.push({ phone: patientPhone, type: 'reschedule', timestamp: new Date() });
        return await whatsappService.sendRescheduleOffer(patientPhone, tenantName, oldTime, newTime);
    }
    
    async sendTokenNotification(patientPhone, tokenData) {
        this.notificationsSent.push({ phone: patientPhone, type: 'token', timestamp: new Date() });
        return await whatsappService.sendTokenConfirmation(
            patientPhone, 
            tokenData.token, 
            tokenData.clinicName, 
            tokenData.slotTime, 
            tokenData.fee
        );
    }
    
    async sendQueueUpdate(patientPhone, clinicName, position, eta) {
        this.notificationsSent.push({ phone: patientPhone, type: 'queue', timestamp: new Date() });
        return await whatsappService.sendQueueUpdate(patientPhone, clinicName, position, eta);
    }

    getRecentNotifications() {
        return this.notificationsSent;
    }
}

module.exports = new NotificationManager();
