Repository navigation
Open
Description
Overview
When a user is clocked in on one team and then selects a different team, the Clock page still shows the Clock In / Break / Clock Out controls for the newly selected team. It is unclear which team the running shift belongs to, and a user can easily believe they are working under the team they are looking at. Clock actions should apply only to the team the user is clocked into, and switching teams should be a deliberate, one-step flow.
Current State
- The active shift (
activeClockEvent) belongs to one team, but the selected team (selectedTeamId) can be a different one (seesrc/lib/useClockToggle.tsandsrc/features/clock/ClockPage.tsx). useClockTogglequietly prefers the active event's team over the selected team (gateTeamId), so Clock Out / Break act on a team other than the one on screen.- Clock In stays available while another team is running, and nothing explains which team the time is being recorded for.
- There is no direct way to move a running shift to another team; the user has to find the original team, clock out, then re-select and clock in.
Proposed Changes
1. Make the Clocked-In Team Unmistakable
- Show the team name prominently wherever clock state is displayed (Clock page, today status card, header/status indicator): "Clocked in to {Team}".
- When the selected team differs from the clocked-in team, show a persistent banner: "You're clocked in to {Team A}. Viewing {Team B}."
- The banner links back to the clocked-in team.
2. Disable Conflicting Clock Actions
- While clocked into Team A, with Team B selected:
- Clock In is disabled, with a reason shown ("Already clocked in to Team A").
- Break and Clock Out are disabled for Team B, so they cannot be mistaken as applying to it.
- Break and Clock Out stay fully available when viewing the clocked-in team.
- Disabled controls get an accessible explanation (
aria-describedby, not just a tooltip).
3. Easy Team Switch
- Add a single Switch to {Team B} action on the banner/disabled controls that:
- Clocks out of Team A (ending any open break),
- Clocks into Team B,
- Shows a confirmation naming both teams.
- Include a short confirmation step stating what will happen before the switch applies.
- If clocking in to Team B needs something the Clock In flow already requires (for example a plan post), continue into that flow rather than failing midway.
- If clocking out of Team A succeeds but clocking in to Team B fails, show a clear error and leave the user in a clearly clocked-out state.
4. Consistency Across Entry Points
- Apply the same rules to every place that starts or stops time: Clock page, ticket timers via
useTicketStart, and any quick-action/header controls. - Share the "which team is the shift on / can this action run here" logic in one place (extending
useClockToggle) instead of duplicating it per component.
5. Quality
- All new text is externalized (
clockStrings.ts) and translatable. - Uses
@mieweb/uicomponents (Alert,Button/ButtonGroup,Badge) and RTL-safe classes. - Add unit tests for the gating logic and an E2E test covering: clock in to Team A, select Team B, controls disabled, switch, shift now on Team B.
Acceptance Criteria
- Clock state always names the team the shift is running under.
- While clocked into Team A, viewing Team B shows a banner identifying both teams.
- Clock In, Break and Clock Out are disabled when viewing a team other than the clocked-in one, with a visible and screen-reader-accessible reason.
- Controls are fully enabled when viewing the clocked-in team.
- A one-step "Switch to {Team B}" action clocks out of Team A and into Team B, with confirmation.
- A failed switch never leaves the user in an ambiguous state, and the error is clear.
- Ticket timer starts and other clock entry points follow the same rules.
- Strings are externalized; the UI works in RTL and dark mode.
- Unit and E2E tests cover the disabled states and the switch flow.
Out of Scope (for Now)
- Clocking into multiple teams at the same time.
- Moving past time entries between teams, or editing the team on completed sessions.
- Changes to timesheet approval or change-request flows.
- Backend changes beyond what the switch needs (clock out then clock in via existing endpoints).
Metadata
Metadata
Assignees
Labels
No labels
Activity