import { IPlan } from "./Plans.model";

export enum MP_SUBS_STATUS {
    PENDING = "pending",
    AUTHORIZED = "authorized",
    PAUSED = "paused",
    CANCELLED = "cancelled",
}

const getSubStatusText = (status: string | undefined): string => {
    switch (status) {
        case MP_SUBS_STATUS.PENDING:
            return "PENDIENTE";
        case MP_SUBS_STATUS.AUTHORIZED:
            return "ACTIVO";
        case MP_SUBS_STATUS.PAUSED:
            return "PAUSADA";
        case MP_SUBS_STATUS.CANCELLED:
            return "CANCELADA";
        default:
            return "ACTIVO";
    }
};

export enum MP_PRE_APPROVAL_STATUS {
    READY_TO_START = "ready_to_start",
    NO_PAYER_EMAIL = "no_payer_email",
}

export { getSubStatusText };

export type CreateMPPreApprovalParams = {
    planId: string;
    sessionUser: string;
    months: number;
};

export type CancellPlanSuscriptionParams = {
    sessionUser: string;
};

export type MPPreApprovalResponse = {
    init_point: string;
    status: MP_PRE_APPROVAL_STATUS;
};

export type GetSubscriptionInitPointParams = {
    sessionUser: string;
};

export interface GetSuscriptionInitPointResponse {
    init_point: string;
}

export interface ISubscriptionInfo {
    id?: string;
    plan: IPlan;
    startDate?: Date;
    endDate?: Date;
    isActive?: boolean;
    autoRenew?: boolean;
    mpStatus?: string;
    mpDateCreated?: Date;
}
export const DefaultSubscriptionModel: ISubscriptionInfo = {
    id: "",
    plan: {
        name: "",
        description: "",
        features: [],
        code: "",
        price: 0,
        annualPrice: 0,
        id: "",
        mailNotifications: false,
        smsNotifications: false,
        wapNotifications: false,
        bot: false,
        active: false,
        dateLimit: false,
        limitOrganizations: 0,
        limitEmployees: 0,
        limitServices: 0,
        limitAppointments: 0,
        limitClients: 0,
        limitRepeats: 0,
        payments: false,
        discount3Months: 0,
        discount6Months: 0,
        discount12Months: 0,
    },
    isActive: false,
    mpDateCreated: new Date(),
    mpStatus: "",
    startDate: new Date(),
    endDate: new Date(),
    autoRenew: false,
};
