import { TimeTrackingUserSetting, TimeTrackingUserSettingForCreation } from '../../../business/models/timeTracking/timeTrackingUserSetting';
import { TimeTrackingUserSettingDAO } from '../../dataAccessObjects/timeTracking/timeTrackingUserSetting';

export const mapTimeTrackingUserSettingDAOToModel = (timeTrackingUserSetting: TimeTrackingUserSettingDAO): TimeTrackingUserSetting => {
    return new TimeTrackingUserSetting({
        createdAt: timeTrackingUserSetting.createdAt,
        id: timeTrackingUserSetting.id,
        instanceId: timeTrackingUserSetting.instanceId,
        kioskPin: timeTrackingUserSetting.kioskPin ?? null,
        updatedAt: timeTrackingUserSetting.updatedAt,
        userId: timeTrackingUserSetting.userId,
    });
};

export const mapTimeTrackingUserSettingModelToDAO = (
    timeTrackingUserSetting: TimeTrackingUserSetting | TimeTrackingUserSettingForCreation,
): TimeTrackingUserSettingDAO => {
    const timeTrackingUserSettingDAO = new TimeTrackingUserSettingDAO({
        instanceId: timeTrackingUserSetting.instanceId,
        kioskPin: timeTrackingUserSetting.kioskPin,
        userId: timeTrackingUserSetting.userId,
    });
    if (timeTrackingUserSetting instanceof TimeTrackingUserSetting) {
        timeTrackingUserSettingDAO.id = timeTrackingUserSetting.id;
        timeTrackingUserSettingDAO.isNewRecord = false;
    }
    return timeTrackingUserSettingDAO;
};
