Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import { formatHumanDateRange } from "@/utils/date";
import { SLACK_API_POST_MESSAGE } from "./constants";
async function postSlackMessage(text: string): Promise<void> {
const token = process.env.SLACK_BOT_TOKEN || process.env.SLACK_USER_TOKEN;
const channel = process.env.SLACK_DEFAULT_CHANNEL;
if (!token || !channel) return;
await fetch(SLACK_API_POST_MESSAGE, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ channel, text }),
});
}
export async function notifyTimeOffApproved(
employeeName: string,
startDate: string,
endDate: string,
): Promise<void> {
const dateRange = formatHumanDateRange(startDate, endDate);
await postSlackMessage(`${employeeName} will be off ${dateRange}`);
}
|