import { requestClient } from '#/api/request';

export interface MailData {
    AppId : number;
    ServerId: number;
    PageSize?: number;
    CurrentPage?: number;
    audit_id?: number;
    mail_id?: number;
    title: string;
    subtitle?: string;
    content: string;
    title_en: string;
    subtitle_en?: string;
    content_en: string;
    title_ptbr?: string;
    subTitle_ptbr?: string;
    content_ptbr?: string;
    items : string;
    start_time: number;
    end_time: number;
    register_time: number;
    mail_type: number;
    send_type: number;
    to_uids :string;
    create_time?: number;
    title_es_latam?: string;
    subTitle_es_latam?: string;
    content_es_latam?: string;
    min_level?: number;
    status?: number;
    applicant?: string;
    reviewer?: string;
    review_remark?: string;
    review_time?: number;
}

export interface MailListParam {
    AppId : number;
    ServerId: number;
    PageSize: number;
    CurrentPage: number;
}

export async function getMailListApi(p:MailListParam) {
    return requestClient.post<MailData[]>('/mail/list', p);
}

export async function addMailApi(data:MailData) {
    return requestClient.post('/mail/send', data);
}

export async function approveMailApi(audit_id:number, review_remark = '') {
    return requestClient.post('/mail/approve', { audit_id, review_remark });
}

export async function rejectMailApi(audit_id:number, review_remark = '') {
    return requestClient.post('/mail/reject', { audit_id, review_remark });
}

export async function deleteMailApi(data: Pick<MailData, 'AppId' | 'ServerId' | 'audit_id' | 'mail_id'>) {
    return requestClient.post('/mail/delete', data);
}
