"use server";

import { serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { MailSetting, MailTemplate } from ".";

export interface MailSave {
    settings: MailSetting[];
    template: MailTemplate;
}

export const saveMail = async (data: MailSave) => {
    return serverFetchJson<MailSetting[]>(`${BASE_API_URL}/mails/save`, {
        method: "POST",
        body: JSON.stringify(data),
        headers: { "Content-Type": "application/json" },
    });
};

export const testEveryone = async () => {
    return serverFetchWithNoContent(`${BASE_API_URL}/mails/testEveryone`, {
        method: "GET",
        // body: JSON.stringify(data),
        headers: { "Content-Type": "application/json" },
    });
};

export const test7th = async () => {
    return serverFetchWithNoContent(`${BASE_API_URL}/mails/test7th`, {
        method: "GET",
        // body: JSON.stringify(data),
        headers: { "Content-Type": "application/json" },
    });
};

export const test15th = async () => {
    return serverFetchWithNoContent(`${BASE_API_URL}/mails/test15th`, {
        method: "GET",
        // body: JSON.stringify(data),
        headers: { "Content-Type": "application/json" },
    });
};

export const testEmail = async () => {
    return serverFetchWithNoContent(`${BASE_API_URL}/mails/test-email`, {
        method: "GET",
        // body: JSON.stringify(data),
        headers: { "Content-Type": "application/json" },
    });
};
