25 lines
609 B
TypeScript
25 lines
609 B
TypeScript
// utils/api/sendBoardMail.ts
|
|
import type { BoardAccessMode } from '~/types';
|
|
|
|
interface SendBoardMailParams {
|
|
access?: BoardAccessMode;
|
|
subject: string;
|
|
html: string;
|
|
action?: 'created' | 'updated' | 'deleted' | string;
|
|
}
|
|
|
|
const FUNCTION_BASE = 'https://boardmail-edvvp3hbnq-du.a.run.app';
|
|
|
|
export async function sendBoardEmail({
|
|
access = 'public',
|
|
action = 'updated',
|
|
subject,
|
|
html,
|
|
}: SendBoardMailParams): Promise<void> {
|
|
await $fetch(FUNCTION_BASE, {
|
|
method: 'POST',
|
|
body: { access, subject, html, action },
|
|
credentials: access !== 'public' ? 'include' : undefined,
|
|
});
|
|
}
|