import { Document } from "mongoose";

export interface IDiscountEmail {
    id?: string;
    _id?: string;
    companyId: string;
    discountId: string;
    email: string;
    startDate: Date;
    endDate: Date;
    createdAt: Date;
}

export interface IDiscountEmailDocument extends Omit<IDiscountEmail, "id" | "_id">, Document {
    _id: string;
}

export interface IDiscountsEmailAdapter {
    create(data: Omit<CreateDiscountEmailParams, "sessionUser">): Promise<IDiscountEmail>;
    delete(data: Omit<DeleteDiscountEmailParams, "sessionUser">): Promise<void>;
    find(filters: Omit<FindDiscountsEmailParams, "sessionUser">): Promise<IDiscountEmail[]>;
    findOne(filters: Omit<FindDiscountsEmailParams, "sessionUser">): Promise<IDiscountEmailDocument | null>;
    paginate(filters: PaginateDiscountsEmailParams): Promise<PaginateDiscountsEmailResults>;
}

export type DiscountEmailView = {
    id: string;
    companyId: string;
    discountId: string;
    discountName: string;
    discountType: string;
    discountValue: number;
    discountCode: string;
    email: string;
    startDate: Date;
    endDate: Date;
};

export type FindDiscountsEmailParams = {
    id?: string;
    companyId: string;
    discountId?: string;
    email?: string;
    sessionUser: string;
    searchDate?: Date;
};

export type PaginateDiscountsEmailParams = FindDiscountsEmailParams & {
    page: number;
    limit: number;
};

export type PaginateDiscountsEmailResults = {
    data: IDiscountEmail[];
    page: number;
    pages: number;
};

export type PaginateDiscountsEmailViewResults = {
    data: DiscountEmailView[];
    page: number;
    pages: number;
};

export type CreateDiscountEmailParams = {
    companyId: string;
    discountId: string;
    email: string;
    startDate: Date;
    endDate: Date;
    sessionUser: string;
};

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

export type DeleteDiscountsEmailByCompanyParams = {
    companyId: string;
};

export interface IDiscountsEmailManager {
    discountsEmail: IDiscountsEmailAdapter;
    deleteDiscountsEmailByCompany(data: DeleteDiscountsEmailByCompanyParams): Promise<void>;
    createDiscountEmail(data: CreateDiscountEmailParams): Promise<IDiscountEmail>;
    deleteDiscountEmail(data: DeleteDiscountEmailParams): Promise<void>;
    paginate(data: PaginateDiscountsEmailParams): Promise<PaginateDiscountsEmailViewResults>;
}
