- Rebrand all user-facing text to AgendaMax - Fix sidebar scrolling: card container no longer overflows html (flex h-full min-h-0) - Fix calendar toolbar hover: active buttons keep readable contrast - Sticky calendar toolbar (month/week/day always visible on scroll) - Seed guarantees 2-4 appointments per day for current week (Mon-Sat)
4.6 KiB
4.6 KiB
Task 13 Report — SettingsPage (auto-assign + working hours editor)
Files changed
- CREATED
src/lib/workingHours.ts— exportsDEFAULT_WH,DAYS,parseWh. Pure data/helpers, no React/UI. - MODIFIED
src/pages/SettingsPage.tsx:- Added
Wand2,Clockto the lucide-react imports. - Imported
DEFAULT_WH,DAYS,parseWhfrom../lib/workingHours. - Added local
whstate (useState<Record<number, {start,end}|null>>(DEFAULT_WH)). - Replaced the
useEffectso it now also callssetWh(parseWh(data.settings.working_hours)). - Extended the PATCH
api.settings.updatepayload withauto_assign_specialist(0/1) andworking_hours: wh(object). - Added, inside the "Reservas online" card (after the URL/slug block): a "Asignar especialista automáticamente" checkbox (Wand2 icon) and a "Horario del negocio" block rendering
<WorkingHoursEditor value={wh} onChange={setWh} />. - Added a local
WorkingHoursEditorsubcomponent (per-day on/off + start/end<input type="time">, "Cerrado" label when off).
- Added
Typecheck / build
npm run typecheck→ 0 errors.npm run build→ succeeded (vite build OK, all chunks emitted).
Runtime smoke
- Not executed in this subagent session (subagent has no browser; dev server would need to be started manually by the orchestrator). The plan's Task 13 Step 4 lists this as the runtime check:
- Boot
npm run dev, login owner →/settings. - Toggle the auto-assign checkbox; edit working hours (e.g. Saturday on 10:00–14:00); Save; reload.
- Expect: GET
/settingsreflectsauto_assign_specialist=1andworking_hours='{"1":{"start":"09:00","end":"20:00"},...,6:{...},7:null}'(or whatever was entered). - Expect on
/b/<slug>: wizard collapses to 3 steps (Servicio/Horario/Datos) when toggle is on, and the slot list is constrained to the configured working hours (e.g. Saturday shows only 10:00–14:00 slots).
- Boot
- Backend prerequisites (must already be in place for persistence to work): Task 7 must have run —
FIELDSwhitelist inserver/routes/settings.tsincludesauto_assign_specialistandworking_hours, both SELECTs return them, and the PATCH handler serializes the object → JSON string and coerces the boolean to 0/1. If Task 7 has NOT been applied yet, the PATCH will silently drop both fields (whitelist) and persistence will not occur.
Deviations
- Improvement applied (per task spec):
DEFAULT_WH/DAYS/parseWhlive insrc/lib/workingHours.tsfrom the start, imported by SettingsPage — instead of being defined inline here and refactored out in Task 14. Task 14 (EmployeeModal) will import the same helpers. - No other deviations from plan Task 13.
WorkingHoursEditorstays a local component inside SettingsPage (not exported fromworkingHours.ts).
Self-review
- Does the PATCH send
working_hoursas an object? Yes —working_hours: whwherewhis aRecord<number, {start,end}|null>. Backend (Task 7 Step 1) is responsible forJSON.stringify-ing it before SQL. Sinceapi.settings.updateis typedany, TS does not complain. - Does
parseWhhandle the JSON-string returned by GET? Yes — whenvis a string itJSON.parses it (catching syntax errors → null), and when null/non-object it falls back to{...DEFAULT_WH}. It also tolerates partial maps (missing day keys →null). - Does the editor toggle per day? Yes —
toggle(n)flipsvalue[n]betweennulland{start:"09:00", end:"18:00"}; when off, the day row shows "Cerrado". - First-load safety:
whinitialises fromDEFAULT_WH, so even before the GET resolves the editor renders sane values (Lun–Vie 09–20, Sáb/Dom closed) rather than crashing onundefined. - Scope discipline: only
src/lib/workingHours.ts(new) andsrc/pages/SettingsPage.tsxwere touched.EmployeesPage.tsx,BookingPage.tsx, CSS, and any backend files were left alone. - No commit performed (per CRITICAL constraint #1).
Concerns / handoff notes for orchestrator
- Backend coupling: this task is only the UI half. Persistence depends on Task 7 having extended
FIELDS+ SELECTs + the serialization block inserver/routes/settings.ts. Verify Task 7 landed before doing the runtime smoke. auto_assign_specialistinitial value from GET: backend returns it as 0/1 (INTEGER). The checkbox does!!f.auto_assign_specialistwhich coerces correctly. PATCH sendsf.auto_assign_specialist ? 1 : 0, also correct.- Visual check: the new "auto-assign" checkbox + working-hours block sit inside the existing
space-y-4 p-5 pt-0container of the "Reservas online" card, so vertical rhythm is preserved without further CSS work.