added base examples and drills

This commit is contained in:
2026-05-20 17:42:01 -06:00
parent 9bf788d9ef
commit 4fc0d851e7
40 changed files with 802 additions and 1 deletions
@@ -0,0 +1,33 @@
const fs = require("fs");
function sendReminder(filePath, userId, channel) {
const raw = fs.readFileSync(filePath, "utf8");
const state = JSON.parse(raw);
const user = state.users.find((item) => item.id === userId);
if (!user) {
throw new Error("User not found");
}
if (!user.remindersEnabled) {
return { sent: false, reason: "disabled" };
}
const hour = new Date().getHours();
if (hour < 8 || hour > 20) {
return { sent: false, reason: "quiet-hours" };
}
if (channel === "sms" && !user.phoneNumber) {
return { sent: false, reason: "missing-phone" };
}
user.lastReminderAt = new Date().toISOString();
fs.writeFileSync(filePath, JSON.stringify(state, null, 2));
console.log("Sent reminder", userId, channel);
return { sent: true, channel };
}
module.exports = { sendReminder };