Commit Graph
100 Commits
Author SHA1 Message Date
popertots 8574bf2221 feat: enriched edit request system with side-by-side snapshots, calendar preloading, and admin review UI
Backend:
- Add enriched response types (EditSnapshot, EnrichedEditRequest) with original vs proposed snapshots
- Add 4 new GET endpoints for viewing edit requests (user and admin scoped)
- Remove github.com/lib/pq dependency — use native PostgreSQL array scanning
- Clean up edit requests, time blockers, and notifications on booking cancellation
- Validate exceptional closed hours on admin approve (409 Conflict)
- Notification upsert on edit request replace (no duplicate admin notifications)

Frontend:
- New user EditRequestModal with time/services/both modes and lunch protection
- New admin EditRequestModal with side-by-side diff (date/time, services, notes)
- Integrate edit requests into PendingApprovals card and notifications page
- Preload 3 months of availability to prevent calendar snap-back
- Apply lunch protection to isDateUnavailable in BookingFlow and BookingCreateModal
- Fix accessibility: card list items use <button> instead of <div>

Dev & Docs:
- Seed edit requests in local-dev-2.sh
- Update all Obsidian manuals with enriched edit request documentation
- 42 new tests (438/441 passing)
2026-05-26 11:59:07 +01:00
popertotsandSisyphus 3ccc017716 feat: user payment modal and tip route for online payments
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:05:14 +01:00
popertotsandSisyphus 97c9d1643f docs: update all documentation for multi-method payments and saved cards
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:04:53 +01:00
popertotsandSisyphus f553ebad99 fix: booking duration calculation, tip page auth, and UI polish across frontend
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:04:43 +01:00
popertotsandSisyphus 2a8f04e7b3 feat: saved cards management and account cards tab
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:04:21 +01:00
popertotsandSisyphus 785a6dbf6f feat: multi-method payment modal with tip presets and price overrides
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:04:12 +01:00
popertotsandSisyphus 25ece1e0b4 feat: Square client dev mock for online payments and type additions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:04:04 +01:00
popertotsandSisyphus 4a37fd6396 fix: payment API amount precision (pence), partial validation, and create payment method endpoint
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 18:03:55 +01:00
popertots 8cd393f95d docs: update all documentation for Square payment integration
- README: add Square payments to features, expand project structure, update test count
- Overview: mark Square as active, add payment integration + saved cards sections
- Technical Manual: add payment handlers, API endpoints, 4 new DB tables, build tags
- Admin Manual: update Take Payment from stub to live Square Terminal flow
- User Manual: add paying deposits online + leaving tips sections
- Future Work: mark E1-E4 (Square items) as complete
2026-05-23 11:44:39 +01:00
popertots 2e1ab9d745 feat: Square payment integration, booking flow redesign, and timezone/weekday fixes
- Add Square payment integration (mock + handlers + UI): terminal/online payments,
  refunds, tips, saved cards, webhooks. Build-tagged dev/prod clients.
- Redesign booking flow: Step 4 conditional (deposit only), Step 5 confirmation
  screen with booking ID, auto-submit on transition.
- Redesign schedule modal: 2x3 button grid with Pay Deposit/Pay Early logic.
- Add deposit warning banner at Step 1 for users with outstanding deposits.
- Fix weekday conversion bug: Go 0=Sunday vs DB 0=Monday mismatch in 6 locations.
- Fix timezone bug: UTC vs London time in closing hours validation.
- Fix frontend error parsing: plain text backend errors now displayed correctly.
- Fix crypto.randomUUID fallback for environments without Web Crypto.
- Add 7 new regression tests: closing hours, advance check, active booking limit,
  weekday conversion, UTC/London, deposit snapshot, exceptional hours.
- Fix 3 flaky tests: dynamic dates instead of fixed, no-show timing.
2026-05-23 11:29:34 +01:00
popertots bcd5ed2bd9 square mock plan 2026-05-17 11:03:05 +01:00
popertots d0e82e7d79 style: fix indentation in notification preferences section and backlog table formatting 2026-05-17 00:37:21 +01:00
popertots c91be086c1 fix: close unclosed div wrapping notification preferences section 2026-05-17 00:34:34 +01:00
popertots 5c84cd71b8 fix: hide notification preferences section from admin users 2026-05-17 00:28:55 +01:00
popertots b08df624a8 feat: user notification preferences UI and API endpoints
GET/PUT /api/user/notification-preferences with partial update support.
Toggle section in /account Admin tab (Email, SMS, Browser push).
3 new tests: defaults, full update, partial update.
Fix pre-existing timezone bug in exceptional hours tests (Truncate vs time.Date).
Update README, Technical Manual, and gap backlog (#15 struck out).
2026-05-17 00:24:13 +01:00
popertots 7fc58f58d9 feat: admin notification system with priority ordering, bell icon, and /notifications page
Two-tier notification system: new_booking (all public bookings) + pending_booking (notes/today).
Priority-sorted queue, unread count polling, enriched responses with user_name/booking_start_time.
Fix critical bug: edit_requested cleanup was broken (wrong reason string in 3 handlers).
Add 15 new tests covering priority ordering, enrichment, and notification creation flows.
Update Admin Manual, Technical Manual, and gap backlog docs.
2026-05-16 23:41:18 +01:00
popertots c3501ae89a dependancies and docs 2026-05-16 19:06:33 +01:00
popertots 924bf487ed docs: reorganise Obsidian docs from monolith into multi-page knowledge base
Split Crussell Nails.md (822 lines) into 5 focused documents:
- README.md: slimmed to 84 lines (elevator pitch + run instructions)
- Overview.md: expanded landing page with architecture diagram and quick links
- User Manual.md: 358 lines, customer-facing journeys in plain English
- Admin Manual.md: 493 lines, staff operations guide with zero technical jargon
- Technical Manual.md: 736 lines, full API reference, schema, key systems

All user/admin manuals rewritten for non-technical audiences — no API
endpoints, component names, or implementation details.
2026-05-16 19:05:47 +01:00
popertots a4ea994c69 docs: update README, Obsidian docs, and gap backlog for booking edit modal
Reflect new PUT /api/admin/bookings/{id} services endpoint, EditBookingModal
component, and updated test count (306/308). Mark handleEdit() stub resolved
in gap backlog.
2026-05-16 17:32:32 +01:00
popertots 80621e0d77 feat: add booking edit modal for /today page with service management
Replace placeholder BookingModal on the Next Appointment edit button with a
dedicated EditBookingModal that allows admins to add, remove, and override
services on an active booking. Includes backend PUT endpoint with overlap
detection and full test suite (20 tests).
2026-05-16 17:23:00 +01:00
popertots 44259a32ab ui: swap Cancel and Payment button layout in Next Appointment card
Cancel is now half-width (inline with Edit/Extend), Payment is full-width spanning bottom row
2026-05-10 20:02:18 +01:00
popertots aa4a569a43 docs: update README, Obsidian docs, and gap backlog after test optimization
- Update test count: 286/288 passing (was 222/224)
- Document TestMain per-package architecture
- Document TruncateTables optimization (~60% faster)
- Add local-dev-2.sh tee streaming for real-time test output
- Fix flaky admin reserve walk-in tests (time.Now → noon tomorrow)
- Add gap backlog item #51 for completed test optimization work
2026-05-10 19:48:36 +01:00
popertots e73c96b653 refactor: optimize test DB setup — TestMain per package, truncate-only between tests
- Add TestMain to all 10 test packages (schema DROP+CREATE runs once per package)
- Convert per-test setupTestDB to resetTestData (TRUNCATE only, ~60% faster)
- Add 3 missing tables to TruncateTables (booking_edit_requests, exceptional_group_applications, business_settings)
- Remove dead truncateDiscountTables helper
- Consolidate discount_test.go into package bookings (was external test package)
- Update testutils.SetupTestDB to truncate-only
- Fix unused imports across user, bookings, and handlers packages
- Verify: 286 passing, 2 skipped, 0 failures with -count=2 (no state leakage)
2026-05-10 17:27:51 +01:00
popertots 83c62ffb97 feat: edit request time blockers, today closing time, UI polish, and test fixes
- Add time blocker management for booking edit requests
- Add closing_time field to admin today/current-next endpoint
- Update UserBookingModal and CurrentAppointment UI components
- Fix fmt import in bookings_test.go (was missing)
- Fix created_by FK in TestAdminApproveEditRequest_TimeBlockerOverlap
- Update test coverage for edit request time blocker overlap
- Update gap backlog documentation
2026-05-10 16:53:17 +01:00
popertotsandSisyphus f3fb44f401 fix: port slot grouping fixes across all booking journeys
UserBookingModal (reschedule): add lunch protection filtering, validation guard preventing invalid start>end unavailable blocks, composite each keys, and simplified available/unavailable rendering (lunch is invisible to users).

BookingCreateModal (admin): add validation guard for unavailable blocks and fix composite each keys. Admin lunch protection behavior (30min min + amber warning) preserved.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-10 14:26:28 +01:00
popertots e1c815ed09 fix(loyalty): correct stamp accumulation, one-per-day guard, and test coverage
- Handler: apply existing redemption BEFORE incrementing stamps (was creating
  and applying redemption to same booking)
- Handler: guard stamp increment behind bookingTotal > 0 (free bookings don't
  earn stamps)
- Handler: fix global milestone off-by-one (globalCount already includes
  current booking since status updated before discount logic)
- Schema: chk_milestone constraint only requires milestone_unit for anniversary
  type, not per_user_booking_count or global_booking_count
- Tests: rewrite from scratch with 12 focused tests:
  - FullCycle, ExistingRedemptionApplies, OneStampPerDay, ZeroTotalNoStamp,
    CycleRepeats, TimeBasedCampaign, PerUserMilestone, GlobalMilestone,
    AnniversaryMilestone, LoyaltyPriority, NoDiscountOnZeroTotal,
    CampaignMaxRedemptions
- Tests: fix path parameter extraction in makeProgressRequest
- Vendor: go mod tidy + vendor for testify dependency
2026-05-10 13:17:08 +01:00
popertots e7d3a83867 fix: refine unavailable slot grouping validation logic 2026-05-10 12:08:13 +01:00
popertots f1a9d129e6 fix: unique keys for time slot each block to prevent duplicate key errors
- Use type+startTime+endTime composite key instead of startTime alone
- Prevents collisions when available and unavailable slots share start times
2026-05-10 11:57:05 +01:00
popertots 1c237cc97b fix: merge lunch-blocked slots into single unavailable group
- generateGroupedTimeSlots now accepts lunchProtection map parameter
- Lunch-blocked slots treated as unavailable during grouping, not after
- Consecutive lunch-blocked slots merge into one unavailable button
- Admin BookingCreateModal already had this fix; BookingFlow now matches
2026-05-10 11:53:22 +01:00
popertots 41666b0739 fix: full reschedule implementation with real available slots
- Fetch /api/scheduling/working-hours and /api/scheduling/available-hours for reschedule month
- Generate grouped time slots using same logic as BookingFlow (available + unavailable with start-end times)
- DatePicker uses isDateUnavailable based on real availability (no slots = unavailable)
- Time slots show X - Y format (e.g. 9:30 AM - 10:00 AM) matching booking flow
- Unavailable slots shown as disabled buttons
- Today's slots respect 2-hour minimum notice buffer
- Hours fetched on first reschedule open or calendar month change
2026-05-08 22:44:18 +01:00
popertots 6d95eb6dcf fix: match date/time picker style, fix two-row footer layout
- Replace Modal.Footer with plain div to avoid bits-ui class merging (sm:flex-row override)
- DatePicker wrapped in flex items-center justify-center matching BookingCreateModal
- Time picker uses Button elements with fuchsia selection (hover:bg-fuchsia-50, bg-fuchsia-100)
- Generate 30-min time slots from 08:00-18:00 matching salon hours
- Reschedule form container uses bg-gray-50 matching other sections
- Footer: two rows with flex-1 buttons for equal width
2026-05-08 22:27:40 +01:00
popertots 8b539afccc fix: two-row footer layout, use DatePicker for reschedule
- Footer: row 1 has Cancel + Reschedule, row 2 has Add to Calendar + Close
- Replace native datetime-local input with DatePicker component from BookingFlow
- Add native time input for preferred time selection
- Buttons use flex-1 for equal width on mobile
2026-05-08 22:13:13 +01:00
popertots fa10134d41 feat: user booking cancel/reschedule, estimated subtotal wording
- Add Cancel Booking button with confirmation dialog (future bookings only, pending/confirmed status)
- If payments exist, dialog shows warning: amount paid retained as credit towards future appointment
- Add Reschedule button with inline form (date/time picker + optional notes)
- Reschedule submits to POST /api/bookings/{id}/edit-request
- Change 'Amount Due' to 'Estimated Subtotal' for future bookings
- Footer: Cancel (left) | Reschedule, Add to Calendar, Close (right)
- Mobile-first: flex-wrap layout for footer buttons
2026-05-08 22:02:16 +01:00
popertots 968b40b4d9 fix: test migration cleanup for discount types/tables, fix type ordering in init-script
- Add new discount types to testdb.Migrate drop list (campaign_type, milestone_type, etc.)
- Add new discount tables to testdb.Migrate drop order and TruncateTables
- Move discount type definitions to top of init-script.sql with other enums
- Remove duplicate type definitions that were after admin_notification_reason
- Types must be defined before tables that reference them
2026-05-08 19:59:18 +01:00
popertots 79a794de58 fix: remove discount_eligible from booking creation, fix modal scrolling, lower default to 5%
- Remove all discount_eligible checks from CreateBookingHandler and AdminCreateBookingForUserHandler
- Discounts are only calculated at completion/payment time, not at booking time
- Remove discount_eligible from frontend Booking type and pending_redemption from BookingUser
- Remove TestDiscount_EligibilityFlag test (no longer relevant)
- Fix modal scrolling: add max-h-[90vh] overflow-y-auto to match ServicesManagement pattern
- Lower default discount from 10% to 5%
- Clarify max_redemptions label as 'campaign total' (per campaign, not per person)
2026-05-08 18:08:59 +01:00
popertots 5c4041ded9 refactor: move discounts into admin panel as component, rebuild modal with proper field handling
- DiscountsManagement component integrated into admin/+page.svelte
- Removed standalone /admin/discounts route
- Modal rebuilt with toggle buttons for campaign type, conditional field groups
- Milestone unit auto-restricted based on milestone type (bookings-only for count types, months/years for anniversary)
- Mobile-first: card layout on mobile, table on desktop (md: breakpoint)
- Native select elements instead of broken bits-ui Select components
2026-05-08 17:54:05 +01:00
popertots 1f54d8565c feat: loyalty/discount system with milestone campaigns, auto-redemption, and admin UI
- Database: loyalty_redemptions, discount_campaigns, booking_discounts tables
- Backend: auto-create pending redemption at 10 stamps, apply discounts at completion
- Backend: discount_eligible flag on booking creation (user + admin flows)
- Backend: campaign CRUD handlers (GET/POST/PUT/DELETE + stats)
- Backend: milestone campaigns (per-user, global, anniversary)
- Frontend: customer account page shows 'card full' status at 10 stamps
- Frontend: admin discounts page with campaign management UI
- Frontend: TypeScript types for all discount entities
- Tests: 9 integration tests covering loyalty, campaigns, milestones, edge cases
2026-05-08 17:32:20 +01:00
popertots bec4100e4d feat: customer relationship view, idempotency keys, approval decline, seed payments, backlog cleanup
- #3: Wire ApprovalModal handleDecline to POST /api/admin/bookings/{id}/cancel
- #25: New GET /api/admin/users/{id}/relationship endpoint with spend, tips, visits, customer-for duration, top services
- #25: UserModal reorganized — Personal Info, Booking History, Customer Relationship, Loyalty, Patch Tests
- #36: Idempotency keys on user and admin booking creation (UUID header, duplicate detection)
- local-dev-2.sh: seed payments via PL/pgSQL for completed bookings (5 randomized scenarios)
- local-dev-2.sh: shrink guest/time-blocker output, add payments to summary
- Backlog: mark #3/#25/#35/#36/#49 done, plan #36/#45, remove #46/#48, update #45 with milestone campaigns
- Remove notes history table, avg visits/year metric, Account Information, Privacy & Consent from UserModal
2026-05-04 12:20:03 +01:00
popertots 88ee265603 refactor: remove auto deposit penalty on no-shows, add comprehensive tests
- Remove automatic deposits_required=3 on no-shows, give admin flexibility
- Add tests for no-show deposit logic (forgiven, over 24h, under 24h)
- Add tests for reservation cleanup TTL (admin walk-in/call-in 15min)
- Add tests for EXIF GPS data stripping in portfolio images
- Add tests for contact info endpoint
- Add tests for guest account anonymization
2026-05-03 15:59:40 +01:00
popertots 6808752e0d feat: unify walk-in and call-in reservation flows with 15min TTL, guest booking support, and slot awareness
- backend/handlers/bookings/admin_reserve.go:
  - Add explicit reservation_type field ("walkin" | "callin") to request struct
  - Remove TTL-based heuristic for type detection
  - Walk-in: uses duration_minutes, allows null user_id, 1min past grace
  - Call-in: requires service_ids, validates future time, calculates duration from services
  - Both types now use 15-minute TTL

- backend/handlers/scheduling/time-blockers.go:
  - Update CleanupOldReservations: both walkin and callin use 15min TTL (was 10min/60min)

- frontend/WalkInBooking.svelte:
  - Full rewrite of reservation logic
  - If available now and >15min remaining: reserve from now to slot end
  - If <=15min or not available: reserve next full slot
  - Always reserves before opening modal (never open without hold)
  - Passes reservedDuration to modal
  - TTL changed from 5 to 15 minutes

- frontend/WalkInCreateModal.svelte:
  - Replace dead commented-out guest code with working guest creation
  - Guest account created at submit time (not earlier)
  - Phone defaults to +447700900000 if blank
  - Phone field marked optional with helper text
  - Name split into firstName/lastName for backend
  - Validation relaxed: only name required for guests

- frontend/BookingCreateModal.svelte:
  - TTL changed from 60 to 15 minutes
  - Add reservation_type: "callin" to reserve payload
  - Guest creation uses correct firstName/lastName fields
  - Default guest phone to +447700900000
  - Reservation no longer requires selectedUserId (works for guests)

- docs: Update Future Work backlog to mark completed items
2026-05-03 15:09:50 +01:00
popertots bff86a6660 feat: 10 quick wins — account deletion, health check, debug cleanup, UX polish, graceful shutdown
- backend/handlers/user/account.go: Wire DELETE /api/user/account to call
  anonymize_user() for registered users and delete_guest_user() for guests,
  with CardDAV contact cleanup
- backend/handlers/user/profile_test.go: Add TestAccount_DeleteGuest and
  enhance TestAccount_Delete to verify anonymization results
- backend/main.go: Add GET /api/health endpoint with DB ping and S3 status
  check; add HSTS and Referrer-Policy security headers; replace
  http.ListenAndServe with http.Server + graceful SIGTERM/SIGINT shutdown
- frontend/routes/+layout.svelte: Replace alert() with toast notifications
  for email verification flow
- frontend/routes/login/+page.svelte: Replace alert() with toast.info for
  social login prototype buttons
- frontend/booking/BookingFlow.svelte: Remove 2 console.log debug calls;
  add cancellation policy note in Step 3; add timezone policy comment
- frontend/ImageUpload.svelte: Comment out debug console.log
- init-scripts/init-script.sql: Add delete_guest_user() SQL function
- docs: Update README.md and Obsidian notes to reflect completed items
2026-05-01 11:33:27 +01:00
popertots 7b396b7a9d fix: resolve guest booking failures from router conflict, reservation self-block, and closed-day miscalculation
- backend/main.go: Flatten /bookings/* sub-Route to explicit paths to prevent
  RequireAuth middleware from bleeding into OptionalAuth POST /bookings
- backend/handlers/scheduling/time-blockers.go: Exclude RESERVATION:* entries
  from GetTimeBlockersInRange so overlap checks dont reject the users own
  reservation before CreateBookingHandler can delete it
- local-dev-2.sh: Fix open_day to skip Saturday (6) not Monday (1), matching
  working_hours schema; move guest booking dates to +16/+20/+22 days beyond
  the upcoming loop range; add reserve-then-book step mirroring frontend flow
2026-04-30 16:06:51 +01:00
popertotsandSisyphus 819a7afb76 fix: move guest booking dates to avoid slot conflicts with existing seeded bookings
All slots on tomorrow were occupied by existing bookings.
Shifted guest bookings to day 3 and day 5 where specific
slots (B, C, D) are guaranteed free by the upcoming pattern.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:58:22 +01:00
popertotsandSisyphus 861fa5227f refactor: rename Alice to Nina across test and seed scripts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:52:26 +01:00
popertotsandSisyphus acd50e0210 seed: add guest booking scenarios and time blockers
Guest bookings: create 4 guest accounts (3 unique + 1 shared-email),
3 guest bookings across different days, and verify registered-email
collision is properly blocked.

Time blockers: staff meeting, holiday morning block, and late start
block to demonstrate unavailable-time behaviour.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:48:18 +01:00
popertotsandSisyphus a9273be201 feat: wire admin time-blocker routes
Add GET/POST/DELETE /api/admin/time-blockers routes so admin
blockers (staff meetings, holidays, late starts) can be created
and managed via the API.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:48:08 +01:00
popertotsandSisyphus c5b7d9a078 feat: wire slot reservation into all booking flows
Customer flow: reservation fires on Date/Time → Details transition with
re-validation on time slot tap and on 'Next' click to prevent simultaneous
bookings. 5-step flow: Service → Date/Time → Reserve → Details (countdown)
→ Payment & Review → Confirm. Guest users redirected to home on success.

Admin call-in: reserve slot before final submission (60min TTL).
Admin walk-in: reserve slot on modal open (5min TTL).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:45:20 +01:00
popertotsandSisyphus 52ca9b425b test: add guest booking, reservation, and anonymization tests
New tests: guest user creation (success, duplicate email, registered collision),
guest booking flow (success, missing user_id, non-guest user_id, deposit bypass),
reservation lifecycle (logged-in, anonymous, replace, validation, conflict detection,
dual cleanup), anonymization (6mo threshold, pending exclusion).

Fixes: deposit advance rule 48h→24h (stale test), time-based test flakiness
(2h→72h offsets), handler confusion in no-show tests, enum type casting for
booking status.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:45:08 +01:00
popertotsandSisyphus 4f173b04dc feat: dual TTL reservation cleanup and guest account anonymization
CleanupOldReservations now handles four reservation types:
logged-in (1hr), anonymous (10min), admin-walkin (10min), admin-callin (1hr).

AnonymizeStaleGuestAccounts scrubs PII from guest accounts whose last booking
was 6+ months ago and who have no pending/confirmed bookings. Financial records
remain intact — only personal data is wiped (UK GDPR compliance).
Triggered on every GetAvailableHours call.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:44:51 +01:00
popertotsandSisyphus 70cba5e412 feat: add guest booking system and admin slot reservation
Guest flow: CreateGuestUserHandler creates disposable guest accounts on-the-fly.
CreateBookingHandler uses OptionalAuth — accepts authenticated or guest (user_id
in body, validated as account_role='guest'). Guests bypass deposits, patch tests,
and the 24h deposit advance rule.

Admin reserve: AdminReserveSlotHandler supports walk-in (5min TTL) and call-in
(60min TTL) reservations with configurable TTL. Validates against bookings,
blockers, working hours.

Route restructuring: POST /bookings moved to OptionalAuth group. POST /bookings/reserve
added for public reservation. POST /admin/bookings/reserve added for admin.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:44:39 +01:00
popertotsandSisyphus 91dbdb199e schema: relax email UNIQUE to partial unique index for non-guest users
Allows multiple guest accounts to share an email while enforcing
uniqueness for registered users. Enables the disposable guest account pattern.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-30 11:44:27 +01:00
popertotsandSisyphus 16095ea372 chore: add .cgcignore to exclude dependencies and build artifacts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 23:23:44 +01:00
popertotsandSisyphus b6e98353bc test: update cleanup test for new RESERVATION:user: description format
Test was using RESERVATION:{user_id}:timestamp which no longer matches
the dual-TTL cleanup patterns. Updated to RESERVATION:user:{user_id}:{timestamp}.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 23:15:32 +01:00
popertotsandSisyphus b1bc46290f fix: resolve chi route collision on /bookings path
Use direct Post with inline middleware instead of Route group to avoid
duplicate mount path panic with the existing authenticated /bookings Route.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 23:12:54 +01:00
popertotsandSisyphus 6766c6128c feat: wire reserve route, dual TTL cleanup, and booking reservation deletion
Add POST /api/bookings/reserve route with OptionalAuth middleware and rate limiting.
Update CleanupOldReservations to handle dual TTLs: 1hr for logged-in users,
10min for anonymous reservations. Update CreateBookingHandler to also match
anon reservations by start_time for users who register mid-flow.
Add comprehensive tests for reservation creation, validation, conflict detection, and cleanup.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 23:05:48 +01:00
popertotsandSisyphus 2ba7b85d0b feat: add OptionalAuth middleware and slot reservation endpoint
OptionalAuth extracts user info from Bearer token if present,
otherwise passes through without requiring authentication.

ReserveSlotHandler creates temporary time_blockers reservations:
- Logged-in users: max 1 active, 1hr TTL, tracked by user_id
- Anonymous users: global cap of 50, 10min TTL, tracked by IP hash
- Validates slot availability (working hours, booking overlap, blocker overlap)
- Returns reservation ID, start_time, duration, and expires_at

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 22:56:53 +01:00
popertotsandSisyphus 60ec5a0a8c ui: polish navbar visibility and home page greetings
Hide My Schedule link from admin users (they have dashboard instead).
Add 60+ randomized greeting strings split between returning and new users.
Update dev script admin seed name.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 22:56:35 +01:00
popertotsandSisyphus ce1a25f054 fix: remove double image processing in upload handler
Frontend now compresses and strips metadata before upload.
Skip backend re-encoding to preserve quality and reduce latency.
Extract independent extensions for main file vs thumbnail.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 22:56:14 +01:00
popertotsandSisyphus b549716b89 test: fix flaky time_blockers test and improve testdb migration
Un-harden TestTimeBlockers_List dates (now relative to current time) and
update TestCleanupOldReservations to use fixture users instead of hardcoded IDs.
Improve Migrate() to drop types before tables (CASCADE dependency fix) and
add forgiven_no_shows to truncate list. Seed default working hours in admin
booking tests to prevent business-logic check failures.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-29 22:55:58 +01:00
popertots a7c6e90978 fix: improve portfolio and image upload UX
- Fix tag suggestion dropdown positioning to appear below input (not overlay)
- Limit tag suggestions to 4 for cleaner UI
- Add separate X clear button for search tags (distinct from filter clear)
- Ensure img URL parameter is cleared when closing image modal
2026-03-07 23:28:16 +00:00
popertots c7c10bc177 Fixed user cancelation logic 2026-03-07 21:00:16 +00:00
popertots 94adc7f54c test: clarify 1h advance requirement is USER-ONLY, add admin walk-in tests
FIXES:
- Clarified that 1-hour minimum advance requirement applies to USER bookings only
- Admins can create walk-in bookings with no advance notice via AdminCreateBookingForUserHandler
- Updated test comments to reflect this distinction

NEW TESTS ADDED:
- TestAdminBookings_Create_WalkIn: Admin creates booking with < 1h notice (walk-in)
- TestAdminBookings_Create_WalkInWithDeposits: Admin walk-in with outstanding deposits + enforce_deposits=false

TEST SCENARIOS VERIFIED:
✓ User: Cannot book < 1h in advance (400 error)
✓ Admin: CAN book < 1h in advance (walk-in, 201 created)
✓ Admin: Can create walk-ins even with user deposits (with enforce_deposits bypass)
✓ Admin: Can bypass minimum advance requirement

BUILD STATUS:
✓ go build -tags test ./handlers/bookings
✓ go build -tags test ./handlers/admin
✓ go build -tags dev ./main.go

Documentation now clearly distinguishes:
- User journey: 1h minimum advance (universal)
- Admin journey: No minimum advance (accept walk-ins)
2026-03-07 18:05:17 +00:00
popertots 99ab43eefb test: update tests to reflect current behavior changes
UPDATED TEST FILES:

1. backend/handlers/bookings/bookings_test.go (added 6 new tests):
   - TestBookings_Create_MinimumAdvance: Renamed from 48h check, now tests 1h requirement
   - TestBookings_Create_WithNotes_StatusPending: NEW - verifies notes cause 'pending' status
   - TestBookings_Create_WithoutNotes_StatusConfirmed: NEW - verifies auto-approval without notes
   - TestBookings_Create_Within1Hour_ShouldFail: NEW - verifies < 1h bookings are rejected
   - TestBookings_Delete_NoShow24hThreshold: NEW - tests 24h no-show rule & deposit penalty
   - TestBookings_Delete_NoShow_WithForgiveness: NEW - tests forgive_no_show parameter

2. backend/handlers/admin/bookings_test.go (added 2 new tests):
   - TestAdminBookings_Create_EnforceDeposits_Bypass: NEW - admin can bypass deposit checks
   - TestAdminBookings_Create_EnforceDeposits_Enforced: NEW - default enforcement behavior

3. backend/handlers/scheduling/time_blockers_test.go (added 1 new test):
   - TestCleanupOldReservations: NEW - verifies 1h+ old reservations are cleaned up

TEST COVERAGE FOR NEW FEATURES:

✓ 1h minimum advance requirement (universal, not deposit-dependent)
✓ Notes → 'pending' status (auto-approval workflow)
✓ No notes → 'confirmed' status (auto-approved)
✓ 24h no-show threshold (< 24h = penalty, >= 24h = late cancellation)
✓ forgive_no_show parameter (admin can forgive no-shows)
✓ Deposit penalty: set to 3 (not +=3, prevents escalation)
✓ enforce_deposits parameter (admin can bypass checks)
✓ Reservation cleanup (auto-delete > 1h old reservations)

VERIFICATION:
✓ All test code compiles (go build -tags test ./handlers/bookings)
✓ All test code compiles (go build -tags test ./handlers/admin)
✓ All test code compiles (go build -tags test ./handlers/scheduling)
✓ Main build still works (go build -tags dev ./main.go)

TEST EXECUTION (to run):
go test -tags test -v ./handlers/bookings -run TestBookings_Create_WithNotes
go test -tags test -v ./handlers/bookings -run TestBookings_Delete_NoShow
go test -tags test -v ./handlers/admin -run TestAdminBookings_Create_EnforceDeposits
go test -tags test -v ./handlers/scheduling -run TestCleanupOldReservations
2026-03-07 18:02:13 +00:00
popertots f9610c8392 docs: update obsidian deposits section to reflect 24h rule, optional forgiveness, and admin enforcement toggle 2026-03-07 17:46:15 +00:00
popertots 2623b62573 docs: update README with comprehensive deposit system documentation
- Add new '💰 Deposit System' section with full business logic
- Document 24-hour late cancellation rule
- Explain optional forgive_no_show boolean for admin forgiveness
- Explain optional enforce_deposits boolean for admin booking override
- Document no-show accumulation (2+ in 6 months = 3 deposits)
- Document deposit reduction on payment
- Add API examples and implementation files reference
- Update payment_type enum to include all types (deposit, full, tip, balance, partial)
- Add deposit examples showing different scenarios
- Update Simplified Deposits status line with current behavior
- Remove outdated 48h notice reference
2026-03-07 17:41:03 +00:00
popertots c275265794 refactor: update deposit system with 24h no-show rule, optional forgiveness, and admin enforcement toggle
- Change no-show threshold from 12h to 24h for late cancellations
- Add optional forgive_no_show boolean to cancellation endpoint
- Add optional enforce_deposits boolean to admin booking creation
- Set deposits_required = 3 on no-show (not +=3) to prevent escalation
- Implement per-cancellation forgiveness instead of bulk forgiveness
- Remove ForgiveNoShowsForUser() function (now per-event)
- Admin can now bypass deposit checks when needed
- All changes backward compatible (nil defaults to enforce)
2026-03-07 17:39:32 +00:00
popertots faa4d89152 Implement business logic changes: deposits, no-shows, reservations, approval workflow
CHANGES:
Phase 1: Schema
- Change deposits_required default from 3 to 0 for new users
- Add forgiven_no_shows table to track forgiven no-show bookings

Phase 2: No-Show Logic (manage.go)
- CountUnforgivenNoShows(): Count unforgiven no-shows in 6-month period
- ApplyDepositsIfNeeded(): Auto-apply 3 deposits if 2+ no-shows detected
- ForgiveNoShowsForUser(): Clear no-shows and reset deposits on full payment

Phase 3: Slot Reservation System
- Add CleanupOldReservations() to delete 1h+ old reservation blockers
- Call cleanup in GetAvailableHours() on each availability check
- Delete existing user reservation before creating new booking

Phase 4: Minimum Advance Time
- Changed from 48h (deposit-only) to 1h (all users)
- Now universally enforced at booking creation time

Phase 5: Notes-Based Approval Workflow
- If booking has notes (not empty) → status = 'pending' (needs approval)
- If no notes → status = 'confirmed' (auto-approved)
- Uses CASE statement in INSERT for status determination

Phase 6: Late Night Lock
- After 22:00, non-admin users cannot book next morning before 11:00
- Implemented in GetAvailableHours() via artificial blocker subtraction
- Admin users see all times (no restriction)

Phase 7: Admin Notifications
- Notify admin if booking has notes OR is for same day
- All qualifying bookings trigger notification for admin review

VERIFICATION:
✓ Build passes: go build -tags dev ./main.go succeeds
✓ All 7 phases implemented as per dev-approved plan
✓ No breaking changes to existing schemas
✓ Backward compatible with existing booking flow
2026-03-07 16:38:23 +00:00
popertots 2c6dcc066d cron nbtb 2026-03-04 20:36:04 +00:00
popertots 182adaed6d fix nbtb, add tests 2026-03-04 20:12:07 +00:00
popertots 7c3f922725 Fix nbtb, add tests 2026-03-04 20:11:51 +00:00
popertots 29b9776a93 non-booking-time-blockers (nbtb) 2026-03-04 11:38:34 +00:00
popertots 861dd11c5b Deposit tracking 2026-03-03 21:40:39 +00:00
popertots ec2dfb6934 Update frontend to match new tested backend 2026-03-02 22:49:20 +00:00
popertots 1e13ccda05 docs 2026-03-02 22:32:56 +00:00
popertots a7c8837073 Tests 2026-03-02 22:17:43 +00:00
popertots 2f08b37902 Fix tests 2026-03-02 20:25:03 +00:00
popertots 74b6f039c0 Fix tests 2026-03-02 19:57:44 +00:00
popertots dd097c1022 Large manual tests corruption fix 2026-03-02 18:07:13 +00:00
popertots 817d5dd021 Test docstrings 2026-03-02 11:37:31 +00:00
popertots b42b7f898a fix tests 2026-03-02 11:14:06 +00:00
popertots a2e0a8e05c update tests 2026-03-02 11:03:59 +00:00
popertots eac5dccc3c testing update + docs 2026-03-02 10:16:55 +00:00
popertots 803aab7073 test fixes 2026-03-01 16:05:02 +00:00
popertots e00740a8c9 fix edit requests 2026-02-27 16:07:46 +00:00
popertots 72124bac98 partial edit fixes 2026-02-26 20:03:11 +00:00
popertots 4fc84e6d39 update sql functions 2026-02-25 00:39:51 +00:00
popertots 2c94a4d9c3 docs 2026-02-25 00:06:55 +00:00
popertots ea1a80dbda fix: resolve flaky holiday hours test and clean up dev scripts
- Use fixed date (Thursday Feb 26, 2026) instead of dynamic tomorrow
  to avoid timezone-related test flakiness
- Remove orphaned SQL fragment from init-script.sql
- Clean up duplicate color code definitions in local-dev-2.sh
- Add Rustfs data wipe and SabreDAV startup to dev script
- Add composer.lock to .gitignore
2026-02-24 23:42:40 +00:00
popertots c6fe9e92a7 refactor: migrate patch test schema from service-level to dedicated tables
- Remove patch_test_duration_hours from services table
- Add new patch_tests table with service_ids array, notice_duration_hours, expiry_months
- Add new user_patch_tests table linking users to patch_tests with tested_at
- Update services handler to check patch_tests.service_ids for eligibility
- Update booking creation to validate patch test requirements (24h notice, 6mo expiry)
- Update booking completion to extend patch test validity (reset tested_at)
- Update admin handlers for new patch test CRUD operations
- Update test fixtures and test cases for new schema
- Update seeding script to create patch_tests and link to gel services
2026-02-24 22:17:50 +00:00
popertots f59595eeec Refactor patch test system and add booking edit requests
- Replace patch_test_duration_hours on services with separate
  patch_tests table
- Add user_patch_tests table to track user patch test records
- Add booking edit request system: users can request time changes
- Add admin handlers to list, approve, and reject edit requests
- Add validation to prevent editing completed/cancelled bookings
- Add overlap and closed-day checks for booking edits
2026-02-24 17:23:28 +00:00
popertots 89d848ee72 docs 2026-02-23 01:19:53 +00:00
popertots df3439bd70 fix: improve test infrastructure and add ID validation
- Add TestMain to set test env vars and testdb.TruncateTables for test
  isolation
- Add chi routing context to test helpers for path parameter extraction
- Fix SQL error handling to use errors.Is() instead of ==
- Add validators package with ID validation
- Fix admin test middleware chain (RequireAdmin wrapper)
- Update test user inserts to include phone and date_of_birth fields
- Update service delete test to check soft-delete (is_active=false)
- Update holiday hours test to use new schema (weekday, is_open)
- Add phone number validation tests for UK mobile numbers
2026-02-23 00:59:32 +00:00
popertots 355e8a26c1 fix: correct middleware chain in scheduling NonAdmin tests
- RequireAdmin needs RequireAuth to populate context first
- Add mw.RequireAuth wrapper to all NonAdmin test middleware chains
- Tests now properly validate auth before checking admin role
- Tests passing: 30/33 (up from 24/27)
- Remaining failures are handler bugs, not test setup issues
2026-02-22 00:34:53 +00:00
popertots ed5598a59f fix: correct time format assertions in scheduling tests
- Database returns HH:MM:SS format, tests expected HH:MM
- Fix assertions in TestScheduling_GetDefaultHours and TestScheduling_UpdateDefaultHours_Admin
- Tests now pass: 24/27 (up from 18/27)
- Remaining failures are real test logic issues
2026-02-22 00:31:04 +00:00
popertots 03e2d8343e fix: add 5-second buffer after PostgreSQL startup before database operations
- PostgreSQL reports ready (SELECT 1 succeeds) but internal initialization still in progress
- Add explicit 5-second sleep after 'PostgreSQL is ready' message
- Ensures database system fully initialized before creating/seeding test database
- Prevents 'database system is starting up' errors
- Also increase sleep after database creation from 1s to 2s for stability
2026-02-22 00:25:55 +00:00
popertots 2abf6653ba fix: add PostgreSQL startup wait loop before test database setup
- PostgreSQL container takes time to fully initialize after docker compose up
- Previous fix didn't account for container startup time
- Add explicit wait loop (30 second timeout) for PostgreSQL service to be ready
- Only create test database AFTER PostgreSQL itself responds to connections
- Prevents 'database system is starting up' errors
- More robust and handles slower container startup scenarios
2026-02-22 00:24:03 +00:00
popertots fb0a7fa59b fix: test database setup and scheduling test build error
- Add explicit verification loop in local-dev-2.sh to wait for crussell_test database to be ready before running tests (prevents race condition)
- Remove unused 'handler' variable declaration in scheduling_test.go that was breaking the build
- Tests now properly execute without immediate 'database does not exist' errors
- Real test failures are now visible instead of being masked by setup issues
2026-02-22 00:20:28 +00:00
popertots 82ff61cfdd Fix test DB connection - disable SSL
PostgreSQL in Docker requires SSL but tests weren't configured for it.
Adding ?sslmode=disable to the connection string fixes TLS errors.
2026-02-22 00:10:17 +00:00
popertots 9ca102153b Add crussell_test database creation and schema seeding to dev script
- Create crussell_test database after PostgreSQL reset
- Seed test DB schema from init-script.sql so tests can run
- This fixes the TLS connection errors in test runs

Also:
- Fixed color variables in script (C_RESET, C_GREEN, etc.)
2026-02-22 00:06:03 +00:00
popertots 44cac94f64 Fix test setup and middleware chain - Handler tests now passing
- Fix TestRequireRoleMiddleware by chaining RequireAuth before RequireRole (role context requirement)
- Remove unused 'strings' import from testdb.go
- Create crussell_test database in Docker setup
- Tests now properly initialize authentication context for role-based tests

Result: handlers test suite passes (13/13 tests)
Remaining failures in admin/auth/bookings/portfolio/scheduling/services/user packages need further investigation (environment setup, database constraints, endpoint initialization)
2026-02-21 23:50:17 +00:00