- Add streetAddress/city/state/zipCode fields to OfficeContact (schema + storage + UI)
- Support {officeAddress} variable in batch reminder SMS
- Replace single SMS template field with full CRUD template list (add/rename/edit/delete)
- Store SMS template list under _sms_template_list; first template synced to batch reminder
- Hardcode all AI chat template defaults into codebase (reminder SMS, greetings, fallback)
- Add seed-templates.ts that auto-seeds default templates for all users on server boot
- Update README: note that templates are auto-configured on first boot
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import express, { Request, Response } from "express";
|
|
import { storage } from "../storage";
|
|
|
|
const router = express.Router();
|
|
|
|
// GET /api/office-contact
|
|
router.get("/", async (req: Request, res: Response): Promise<any> => {
|
|
try {
|
|
const userId = req.user?.id;
|
|
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
|
|
|
const record = await storage.getOfficeContact(userId);
|
|
return res.status(200).json(record ?? null);
|
|
} catch (err) {
|
|
return res.status(500).json({ error: "Failed to fetch office contact", details: String(err) });
|
|
}
|
|
});
|
|
|
|
// PUT /api/office-contact
|
|
router.put("/", async (req: Request, res: Response): Promise<any> => {
|
|
try {
|
|
const userId = req.user?.id;
|
|
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
|
|
|
const { officeName, receptionistName, dentistName, phoneNumber, email, fax, streetAddress, city, state, zipCode } = req.body;
|
|
const record = await storage.upsertOfficeContact(userId, {
|
|
officeName: officeName ?? undefined,
|
|
receptionistName: receptionistName ?? undefined,
|
|
dentistName: dentistName ?? undefined,
|
|
phoneNumber: phoneNumber ?? undefined,
|
|
email: email ?? undefined,
|
|
fax: fax ?? undefined,
|
|
streetAddress: streetAddress ?? undefined,
|
|
city: city ?? undefined,
|
|
state: state ?? undefined,
|
|
zipCode: zipCode ?? undefined,
|
|
});
|
|
return res.status(200).json(record);
|
|
} catch (err) {
|
|
return res.status(500).json({ error: "Failed to save office contact", details: String(err) });
|
|
}
|
|
});
|
|
|
|
export default router;
|