Files
Wellspringmanagement01/apps/Backend/src/routes/office-hours.ts
T
GiteadandClaude Sonnet 4.6 2312ad66ca feat: add schedule column labels, office hours enforcement, and appointment move fix
- Schedule columns default to labels A–F (localStorage, per-browser, click to rename)
- Settings → Advanced → Office Hours: configure Doctors (A-C) and Hygienists (D-F) AM/PM hours per weekday
- Gray out schedule slots outside office hours; override dialog for manual exceptions
- Override Office Hours toggle: select specific dates where all slots are open
- Fix appointment move: send only real DB fields to avoid Zod strict-mode rejection of computed fields (hasProcedures, hasClaimWithNumber)
- Fix backend PUT /appointments: safe error logging to prevent Prisma error crashing Node inspect
- Add OfficeHours Prisma model and GET/PUT /api/office-hours route

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 09:15:18 -04:00

38 lines
1.2 KiB
TypeScript

import express, { Request, Response } from "express";
import { storage } from "../storage";
const router = express.Router();
// GET /api/office-hours
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.getOfficeHours(userId);
return res.status(200).json(record ? record.data : null);
} catch (err) {
return res.status(500).json({ error: "Failed to fetch office hours", details: String(err) });
}
});
// PUT /api/office-hours
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 data = req.body;
if (!data || typeof data !== "object") {
return res.status(400).json({ message: "Invalid office hours data" });
}
const record = await storage.upsertOfficeHours(userId, data);
return res.status(200).json(record.data);
} catch (err) {
return res.status(500).json({ error: "Failed to save office hours", details: String(err) });
}
});
export default router;