Skip to content

Implement WorkEntryAuditSidebar component #6

@duchacekjan

Description

@duchacekjan

Description

Create a new React component WorkEntryAuditSidebar that renders an overlay audit history sidebar with an accordion timeline. Blocked by #5 (TS contracts and query hook must exist first).

New file: src/uck26-frontend/src/features/work/WorkEntryAuditSidebar.tsx

Props:

interface WorkEntryAuditSidebarProps {
  open: boolean;
  date: string | null;      // "2026-05-06"
  dateLabel: string;        // "Tue 06/05"
  userId?: number;
  year: number;
  month: number;
  onClose: () => void;
}

Behaviour:

  • Overlay <Drawer> from Itixo component library
  • Header: history icon (lucide-react), date label, close button
  • Calls useWorkEntryAudit(year, month, date, userId)
  • Loading state: 3 skeleton divs with animate-pulse
  • Empty state: "No history for this day." centered message
  • Timeline: events ordered descending by performedAt (already sorted from API)
    • Colored dot: green = Create, blue = Update, red = Delete
    • Entry type badge per event: work / holiday / doctor (from entryType field; omit badge when null)
    • Performer name + formatted timestamp
    • Collapsible accordion: index 0 open by default, only one open at a time
    • Create body: list initial field values (field → value)
    • Update body: list changed fields (old → new)
    • Delete body: "Entry removed" tombstone message
  • data-test-id="work-history-sidebar" on root element
  • data-test-id="work-audit-event-{index}" on each timeline card

Reference: documents/work-entry-audit-log/work-entry-audit-log.handover.md § Sidebar component

Acceptance Criteria

  • Test coverage — add Playwright UI tests in src/UCK26.Ui.Tests/WorkPageTests.cs. Auth via POST /api/auth/login + JWT injected into localStorage. Locate all elements via data-test-id only. Required cases:
    • Click data-test-id="work-history-{date}" → assert data-test-id="work-history-sidebar" becomes visible
    • Create a WorkEntry via API for a date, open sidebar for that date → assert data-test-id="work-audit-event-0" is visible
    • Open sidebar for a day with no entries → assert "No history for this day." text visible (sidebar open, no crash)
  • Update README.md — no README changes needed; no new commands or setup steps. State: N/A — component is an internal UI detail.
  • Update CLAUDE.md — in the Solution Structure map under features/work/, add WorkEntryAuditSidebar.tsx with a short comment.
  • Sidebar overlays (does not push) the table — fixed position
  • Slides in/out with CSS transition on open prop change
  • Loading, empty, and populated states all render correctly
  • Entry type badge (work / holiday / doctor) rendered per event when entryType is non-null
  • Accordion: latest event expanded by default, only one open at a time
  • data-test-id="work-history-sidebar" on root, data-test-id="work-audit-event-{index}" on each event card
  • TypeScript strict mode passes (npm run lint)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions