export enum TemplateTypes {
    WAP_NEW_APPOINTMENT = "wap-new-appointment",
    WAP_REMINDER = "wap-reminder",
    EMAIL_NEW_APPOINTMENT = "email-new-appointment",
    EMAIL_REMINDER = "email-reminder",
}

export const refactorFields = (text: string) => {
    let newText = text;

    newText = newText.replaceAll("@tx.Cliente", "<---CLIENTE--->");
    newText = newText.replaceAll("@tx.Fecha", "<---FECHA--->");
    newText = newText.replaceAll("@tx.Horario", "<---HORARIO--->");
    newText = newText.replaceAll("@tx.Direccion", "<---DIRECCION--->");
    newText = newText.replaceAll("@tx.Professional", "<---PROFESIONAL--->");
    newText = newText.replaceAll("@tx.Servicio", "<---SERVICIO--->");
    newText = newText.replaceAll("@tx.Precio", "<---PRECIO--->");
    newText = newText.replaceAll("@tx.Organizacion", "<---ORGANIZACION--->");
    newText = newText.replaceAll("@tx.Salto", "<---BR--->");

    return newText;
};

export const unRefactorFields = (text: string) => {
    let newText = text;

    newText = newText.replaceAll("<---CLIENTE--->", "@tx.Cliente");
    newText = newText.replaceAll("<---FECHA--->", "@tx.Fecha");
    newText = newText.replaceAll("<---HORARIO--->", "@tx.Horario");
    newText = newText.replaceAll("<---DIRECCION--->", "@tx.Direccion");
    newText = newText.replaceAll("<---PROFESIONAL--->", "@tx.Professional");
    newText = newText.replaceAll("<---SERVICIO--->", "@tx.Servicio");
    newText = newText.replaceAll("<---PRECIO--->", "@tx.Precio");
    newText = newText.replaceAll("<---ORGANIZACION--->", "@tx.Organizacion");
    newText = newText.replaceAll("<---BR--->", "@tx.Salto");

    return newText;
};

export interface ITemplate {
    id: string;
    _id: string;
    companyId: string;
    name: string;
    code: string;
    type: TemplateTypes;
    template: string;
    createdAt: Date;
}

export type FindTemplatesParams = {
    id?: string;
    companyId: string;
    code?: string;
    name?: string;
    type?: TemplateTypes;
    sessionUser: string;
};

export type PaginateTemplatesParams = FindTemplatesParams & {
    page: number;
    limit: number;
};

export type PaginateTemplatesResults = {
    data: ITemplate[];
    page: number;
    pages: number;
};

export type SaveTemplateParams = {
    templateId?: string;
    companyId: string;
    name: string;
    code: string;
    type: TemplateTypes;
    template: string;
    sessionUser: string;
};

export type DeleteTemplateParams = {
    id: string;
    companyId: string;
    sessionUser: string;
};

export type GetDefaultTemplateParams = {
    type: TemplateTypes;
    companyId: string;
    sessionUser: string;
};
