import { instanceDAOToInstance } from '../../../instances/infrastructure/mappers/instanceMapper';
import { TimeTrackingKiosk } from '../../business/models/timeTrackingKiosk';
import { TimeTrackingKioskDAO } from '../dataAccessObjects/kiosk';

export const mapKioskDAOToModel = (kioskDAO: TimeTrackingKioskDAO): TimeTrackingKiosk => {
    return {
        botAppId: kioskDAO.botAppId,
        createdBy: kioskDAO.createdBy,
        description: kioskDAO.description,
        faceRecognitionBlocking: kioskDAO.faceRecognitionBlocking,
        faceRecognitionEnabled: kioskDAO.faceRecognitionEnabled,
        id: kioskDAO.id,
        instance: kioskDAO.instance ? instanceDAOToInstance(kioskDAO.instance) : null,
        instanceId: kioskDAO.instanceId,
        name: kioskDAO.name,
        pinAuthenticationEnabled: kioskDAO.pinAuthenticationEnabled,
        siteId: kioskDAO.siteId ?? null,
        status: kioskDAO.status,
    };
};

export const mapKioskModelToDAO = (kiosk: TimeTrackingKiosk): TimeTrackingKioskDAO => {
    const kioskDAO = new TimeTrackingKioskDAO({
        createdBy: kiosk.createdBy,
        description: kiosk.description,
        faceRecognitionBlocking: kiosk.faceRecognitionBlocking,
        faceRecognitionEnabled: kiosk.faceRecognitionEnabled,
        instanceId: kiosk.instanceId,
        name: kiosk.name,
        pinAuthenticationEnabled: kiosk.pinAuthenticationEnabled,
        status: kiosk.status,
    });
    if (kiosk.id) {
        kioskDAO.id = kiosk.id;
        kioskDAO.botAppId = kiosk.botAppId;
        kioskDAO.isNewRecord = false;
        kioskDAO.siteId = kiosk.siteId;
    }

    return kioskDAO;
};
