Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4540,6 +4540,9 @@ Since v2.9282 the Job Mode card's header counts the bids of the day so far while
That count is the clock out's own, the bids the person changed with a kept list winning, read from the person's own day for the roles that work on bids, and a day with no bid yet keeps the job's header.
A press on it opens **Your bids today** in a window, read when it opens, with **Keep my list · N bids** (`clock/BidDayKeepWindow.tsx`, the window *Done for the day* opens too).
An empty list names a typed note only on the clock out's sheet, and everywhere else it names the next press that is there (`bidDayEmptyWords`).
Since v2.9283 the office job's row in My time's **This week detail** and **Last week detail** reads **Bids · 7** when any of its days kept a list, with the office job on hover, and counts the bids of those days (`lib/dashboard/myTimeWeekBids.ts`, `hooks/useMyTimeWeekBids.ts`, the person's answers of 2026-12-03).
Opened, that row draws one line of labels above its notes, the first three and **All 7 bids** (`dashboard/MyTimeWeekBidLabels.tsx`), and a label carries no hours, since how a day's hours fall on its bids is punch list #475's question.
Its notes leave out the list a clock out wrote into them before v2.9158 (`weekRowTypedNotes`).

**Database**: `user_bid_activity`, `bid_day_entries`, `bump_user_bid_activity`, `get_my_bid_day`, `save_my_bid_day` · kernels `lib/bids/bidInFront.ts`, `lib/clock/bidDay.ts`, `lib/clock/bidDayLabels.ts` · hooks `useBidActivityBeat`, `useClockOutBidDay`, `useSessionsBidDay` · guides `/help/clock-out-with-the-bids-of-the-day`, `/help/approve-my-teams-hours`

Expand Down
53 changes: 53 additions & 0 deletions docs/recent-features/v2.9283.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# v2.9283 — My Time: a week at the office reads as the bids you kept (2026-12-03)

Punch list #469, the week's office-job row. Client only. No migration, no function change, nothing owed on prod. It reads `bid_day_entries` through the read People → Hours already makes (`fetchKeptBidDays`), under the same row policies.

## What was asked

The owner, 2026-12-02: a day spent on bids is to look like the bids worked on, not like the office job the clock was on. The card named *the week's office-job row reading as bids* and drew nothing for it.

## What the row is

My time's *This week detail* and *Last week detail* are one row a job for the whole week, with that job's hours, opened to the notes typed that week with hours a note. It is not one row a session. So the office job's row is a week's row.

## The calls, and the person's answers (2026-12-03)

- **What the row says:** its label reads *Bids · 7* with the office job on hover. Opened, it shows the typed notes with their hours as before, and one line of labels above them. No hours on a bid. The pick.
- **A week where only some days kept a list:** the row reads as bids when any of its days kept a list, and counts the bids of those days. The pick.
- **Punch list #473's gap line on the week's list:** not drawn there. The pick. That card's line was closed in v2.9282's change.

## What it does

- The office job's row reads **Bids · N** in the job's place when a day it covers kept a list. Its hover reads *Bids · N, on* and the office job.
- N is the bids kept on the days the row covers: days with a session on the office job, in that week. A bid kept on two days counts once. A bid taken off a list is not counted.
- Opened, the row draws one line of labels above its notes: three at most, then **All N bids**, which turns to **Fewer**. A label is the bid's colour, its number, its name and what was done. Solid is a changed bid. Dashed is an opened or added one.
- **No label carries hours.** How a day's hours fall on its bids is punch list #475's question, and this row does not answer it.
- A week with no kept list, a row on a job in the field and the *No job or bid* row read as before.

## How

- New kernel `src/lib/dashboard/myTimeWeekBids.ts`: `weekOfficeRowBids` (the days the row covers, the bids kept on them, the order and what was done, the label over `bidDayJobWords`) and `weekRowTypedNotes` (a note without the list an old clock out wrote, same notes added).
- New hook `src/hooks/useMyTimeWeekBids.ts`: the office job's id once and only when a session of the two weeks sits on a job, then one read of the kept rows for both weeks and the bids' names, only when a session sits on the office job. A read that fails leaves every row as its job.
- New `src/components/dashboard/MyTimeWeekBidLabels.tsx`: the line of labels.
- `DashboardMyTimeSection.tsx`: the hook, and `renderBreakdownList` takes the office row's bids.

## Chosen in the build, to be read by the owner

- **A label on this row is not a press.** The bid opens from People → Hours and from the Bids page.
- **What was done** on a bid reads from the day that gave it the most time.
- **On a person's own section** the reads are made only for a role that works on bids. On another person's section the row policies decide who gets rows, as on People → Hours.
- **Old notes.** A note that a clock out filled with the list before v2.9158 shows only its typed part on this row, and notes that then read the same are one line.

## Tests

- `myTimeWeekBids.test.ts` (7 cases): any day kept, only the row's days and week, a bid taken off, the order and the words, no hours on a label, and the typed notes.
- `DashboardMyTimeSection.weekBids.render.test.tsx` (3 cases): the label, the hover, the labels line with its press, the notes under it, one read for the person alone, a week with no list, and no read off the office job or for a role that does not work on bids.
- Not seen in a browser: this thread signs in to nothing.

## Words

The guide `see-the-time-i-have-added-up` has a new section, *Read the week job by job*. The glossary's *Bids of the day*. The card `to-dos/bids-on-my-time/README.md`: built, with what the build chose and the look.

## The look owed

On the card under *The look owed for the week's row*. It needs a day with a kept list on the office job: the real sign-in as a ZZ Test person who works on bids that the card's other looks wait on.
48 changes: 40 additions & 8 deletions src/components/DashboardMyTimeSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { PersonalTimeOffModal } from './PersonalTimeOffModal'
import { DashboardMyTimePicture } from './dashboard/DashboardMyTimePicture'
import { MyTimeCanWorkLine } from './dashboard/MyTimeCanWorkLine'
import { MyTimeBidDay } from './dashboard/MyTimeBidDay'
import { MyTimeWeekBidLabels } from './dashboard/MyTimeWeekBidLabels'
import { useMyTimeWeekBids } from '../hooks/useMyTimeWeekBids'
import { worksOnBids } from '../lib/clock/bidDay'
import { weekRowTypedNotes, type WeekOfficeRowBids } from '../lib/dashboard/myTimeWeekBids'
import { MY_TIME_WEEKS, buildMyTimeWeeks, myTimeSessionSeconds, type MyTimeDay, type MyTimeWeek } from '../lib/dashboard/myTimeWeeks'
import { payWeeksEndingAt } from '../lib/people/utilization'
import { useLedgerPrefixMap } from '../contexts/LedgerDisplayPrefixContext'
Expand All @@ -24,13 +28,19 @@ function formatHours(seconds: number): string {
function renderBreakdownList(
items: BreakdownItem[],
expandedKeys: Set<string>,
onToggleKey: (key: string) => void
onToggleKey: (key: string) => void,
/** The office job's row reading as its bids (punch list #469), or null to draw every row as its job. */
officeBids: WeekOfficeRowBids | null = null,
/** The bids as an old clock out's list named them, left out of that row's notes. */
listNames: readonly string[] = [],
) {
return (
<ul style={{ listStyle: 'none', padding: 0, margin: '0.5rem 0 0', border: '1px solid var(--border)', borderRadius: 8, overflow: 'hidden' }}>
{items.map((item, idx) => {
const hasChildren = item.children && item.children.length > 0
const isExpanded = hasChildren && expandedKeys.has(item.key)
const bids = officeBids && item.type === 'job' && item.jobId === officeBids.jobId ? officeBids : null
const children = bids && item.children ? weekRowTypedNotes(item.children, listNames) : (item.children ?? [])
const isLastItem = idx === items.length - 1
const hasSubRows = hasChildren && isExpanded
return (
Expand Down Expand Up @@ -60,14 +70,19 @@ function renderBreakdownList(
</span>
<span style={{ display: 'flex', alignItems: 'center', gap: '0.35rem', flex: 1, minWidth: 0 }}>
<span aria-hidden style={{ flexShrink: 0 }}>{isExpanded ? '▼' : '▶'}</span>
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }} title={item.label}>
{item.label}
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }} title={bids ? `${bids.label}, on ${item.label}` : item.label} data-week-row-bids={bids ? '' : undefined}>
{bids ? bids.label : item.label}
</span>
</span>
</button>
{hasSubRows && (
<ul style={{ listStyle: 'none', padding: 0, margin: 0, background: 'var(--bg-page)' }}>
{item.children!.map((sub, subIdx) => {
{bids ? (
<li>
<MyTimeWeekBidLabels labels={bids.labels} />
</li>
) : null}
{children.map((sub, subIdx) => {
const truncated = sub.notes.length > 50 ? sub.notes.slice(0, 47) + '…' : sub.notes
return (
<li
Expand All @@ -79,7 +94,7 @@ function renderBreakdownList(
gap: '0.5rem',
padding: '0.3rem 0.75rem 0.3rem 1.25rem',
fontSize: '0.8125rem',
borderBottom: subIdx < item.children!.length - 1 ? '1px solid var(--border)' : 'none',
borderBottom: subIdx < children.length - 1 ? '1px solid var(--border)' : 'none',
}}
>
<span style={{ fontVariantNumeric: 'tabular-nums', flexShrink: 0, color: 'var(--text-faint)', minWidth: '5rem' }}>
Expand Down Expand Up @@ -156,7 +171,7 @@ type Props = {

export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disableDayEditor = false, onWeekSeconds }: Props) {
const prefixMap = useLedgerPrefixMap()
const { user: authUser } = useAuth()
const { user: authUser, role } = useAuth()
const myTimeSubjectDisplayName = useMemo(() => {
if (authUser?.id === userId) return displayNameFromAuthUser(authUser)?.trim() || 'You'
return 'User'
Expand Down Expand Up @@ -190,6 +205,23 @@ export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disab
const selectedWeek = chosenWeek != null && chosenWeek >= 0 && chosenWeek < weeks.length ? chosenWeek : currentWeek
const showsLastWeek = currentWeek > 0 && selectedWeek === currentWeek - 1

// The office job's row of this week and of last week reads as its bids where a day kept a list (punch list #469).
// On a person's own section the read is made only for a role that works on bids. On another's, row policies decide.
const detailWeeks = useMemo(() => {
if (!read) return []
const payWeeks = payWeeksEndingAt(read.todayYmd, MY_TIME_WEEKS)
return payWeeks.slice(-2).map((w) => ({ start: w.start, end: w.end }))
}, [read])
const weekBids = useMyTimeWeekBids({
enabled: authUser?.id === userId ? worksOnBids(role) : true,
userId,
sessions: read?.sessions ?? null,
weeks: detailWeeks,
prefixMap,
})
const thisWeekStart = detailWeeks[detailWeeks.length - 1]?.start ?? ''
const lastWeekStart = detailWeeks.length > 1 ? (detailWeeks[0]?.start ?? '') : ''

const myTimeModalSessions = useMemo(() => (editorDate && read ? read.sessions.filter((s) => s.work_date === editorDate) : []), [editorDate, read])

useEffect(() => {
Expand Down Expand Up @@ -583,15 +615,15 @@ export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disab
else next.add(key)
return next
})
})
}, weekBids.rowOf(lastWeekStart), weekBids.listNames)
: renderBreakdownList(breakdown, expandedKeys, (key) => {
setExpandedKeys((prev) => {
const next = new Set(prev)
if (next.has(key)) next.delete(key)
else next.add(key)
return next
})
}))}
}, weekBids.rowOf(thisWeekStart), weekBids.listNames))}
</>
)}
<div
Expand Down
152 changes: 152 additions & 0 deletions src/components/DashboardMyTimeSection.weekBids.render.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// @vitest-environment jsdom
/**
* Punch list #469, the week's office-job row on My time. The week's detail is one row a job. Where a day on the
* office job kept a list of bids, that row reads 'Bids · 4' with the office job on hover, and opens to one line of
* labels above the notes typed that week. Every job, bid and note here is made up.
*/
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, screen, waitFor, within } from '@testing-library/react'

const OFFICE = '00000000-0000-0000-0000-00000000aaaa'
const FIELD = '00000000-0000-0000-0000-00000000bbbb'
const h = vi.hoisted(() => ({
role: 'estimator',
sessions: [] as Array<Record<string, unknown>>,
kept: vi.fn(),
names: vi.fn(),
officeJob: vi.fn(),
}))

vi.mock('../lib/supabase', async () => {
const { makeSupabaseStub } = await import('../test/renderSmokeMocks')
const stub = makeSupabaseStub()
const answer = (data: unknown) => {
const b: Record<string, unknown> = {}
for (const m of ['select', 'eq', 'is', 'gte', 'lte', 'in', 'order', 'range', 'limit']) b[m] = () => b
b.then = (f?: (v: unknown) => unknown, r?: (e: unknown) => unknown) => Promise.resolve({ data, error: null }).then(f, r)
return b
}
return {
supabase: {
...stub,
from: (table: string) => (table === 'clock_sessions' ? answer(h.sessions) : stub.from()),
rpc: (name: string) =>
name === 'get_jobs_ledger_by_ids'
? answer([
{ id: '00000000-0000-0000-0000-00000000aaaa', hcp_number: '100', click_number: '', job_name: 'ZZ Test Office', job_address: '1 Test St', service_type_id: null },
{ id: '00000000-0000-0000-0000-00000000bbbb', hcp_number: '502', click_number: '', job_name: 'ZZ Test Field Job', job_address: '2 Test St', service_type_id: null },
])
: stub.rpc(),
},
}
})
vi.mock('../hooks/useAuth', async () => {
const { makeUseAuthValue } = await import('../test/renderSmokeMocks')
const useAuth = () => makeUseAuthValue({ role: h.role })
return { useAuth, useOptionalAuth: useAuth }
})
vi.mock('../lib/clock/bidDayLabelsIo', () => ({ fetchKeptBidDays: h.kept, fetchBidLabelNames: h.names }))
vi.mock('../lib/overheadOfficeJobSettings', () => ({ fetchOverheadOfficeJobLedgerIdFromAppSettings: h.officeJob }))
vi.mock('../lib/bids/bidJobsOpenedIo', () => ({ loadJobsOpenedFromBids: async () => [] }))

import { renderWithProviders, SMOKE_AUTH_USER_ID } from '../test/renderSmokeMocks'
import { todayYmdInAppTz } from '../utils/dateUtils'
import DashboardMyTimeSection from './DashboardMyTimeSection'

const today = todayYmdInAppTz()
const session = (id: string, job: string, notes: string, hoursAgo: number) => ({
id,
clocked_in_at: new Date(Date.now() - hoursAgo * 3_600_000).toISOString(),
clocked_out_at: new Date(Date.now() - (hoursAgo - 1) * 3_600_000).toISOString(),
work_date: today,
notes,
job_ledger_id: job,
bid_id: null,
approved_at: null,
origin: 'manual',
salary_segment_index: null,
})
const bid = (n: number) => `0b1d0000-0000-4000-8000-0000000b${n}`
const keptRow = (n: number, over: Record<string, unknown> = {}) => ({ user_id: SMOKE_AUTH_USER_ID, work_date: today, bid_id: bid(n), state: 'kept', source: 'app', seen_seconds: 600 + n, tabs: ['pricing'], changes: 2, seen: null, ...over })
const nameRow = (n: number) => ({ id: bid(n), bid_number: `${n}`, project_name: `ZZ Test Bid ${n}`, service_type_id: null })

function draw() {
renderWithProviders(<DashboardMyTimeSection userId={SMOKE_AUTH_USER_ID} hoursDaysCorrect={new Set()} />)
}

async function openDetail() {
fireEvent.click(await screen.findByRole('button', { name: /This week detail/ }))
}

afterEach(() => {
cleanup()
h.role = 'estimator'
h.sessions = []
h.kept.mockReset()
h.names.mockReset()
h.officeJob.mockReset()
})

describe('DashboardMyTimeSection — the week’s office-job row reading as bids (punch list #469)', { timeout: 15_000 }, () => {
it('says Bids · 4 in the office job’s place, with the job on hover, and draws the labels above the notes', async () => {
h.sessions = [session('s1', OFFICE, 'Called the GC', 5), session('s2', FIELD, 'Set the tub', 3)]
h.officeJob.mockResolvedValue(OFFICE)
h.kept.mockResolvedValue([keptRow(412), keptRow(431), keptRow(398, { changes: 0, tabs: ['submission-followup'] }), keptRow(420, { source: 'person', seen_seconds: null, tabs: [], changes: 0 })])
h.names.mockResolvedValue([nameRow(412), nameRow(431), nameRow(398), nameRow(420)])
draw()
await openDetail()
const row = await screen.findByText('Bids · 4')
expect(row.getAttribute('title')).toMatch(/^Bids · 4, on .*100.*ZZ Test Office/)
// The field job's row keeps its job.
expect(screen.getByText(/ZZ Test Field Job/)).toBeTruthy()

const line = screen.getByTestId('my-time-week-bid-labels')
const shown = [...line.querySelectorAll('[data-label-kind]')]
expect(shown.map((l) => l.getAttribute('data-label-kind'))).toEqual(['changed', 'changed', 'opened'])
expect(line.textContent).toContain('ZZ Test Bid 431')
expect(line.textContent).toContain('priced')
expect(line.textContent).not.toMatch(/hrs|minutes/)
// The notes typed that week stay under the labels, with their hours.
expect(screen.getByText('Called the GC')).toBeTruthy()

fireEvent.click(within(line).getByRole('button', { name: 'All 4 bids' }))
expect(line.querySelectorAll('[data-label-kind]')).toHaveLength(4)
expect(within(line).getByRole('button', { name: 'Fewer' })).toBeTruthy()
// One read of the kept rows for the weeks on screen, for this person alone.
expect(h.kept).toHaveBeenCalledTimes(1)
expect(h.kept.mock.calls[0]![0]).toEqual([SMOKE_AUTH_USER_ID])
})

it('leaves the row as the office job in a week that kept no list', async () => {
h.sessions = [session('s1', OFFICE, 'Called the GC', 5)]
h.officeJob.mockResolvedValue(OFFICE)
h.kept.mockResolvedValue([])
draw()
await openDetail()
await screen.findByText(/ZZ Test Office/)
await waitFor(() => expect(h.kept).toHaveBeenCalled())
expect(screen.queryByText(/^Bids · /)).toBeNull()
expect(screen.queryByTestId('my-time-week-bid-labels')).toBeNull()
expect(h.names).not.toHaveBeenCalled()
})

it('reads no kept list for a week with no day on the office job, or for a role that does not work on bids', async () => {
h.sessions = [session('s2', FIELD, 'Set the tub', 3)]
h.officeJob.mockResolvedValue(OFFICE)
draw()
await openDetail()
await screen.findByText(/ZZ Test Field Job/)
await waitFor(() => expect(h.officeJob).toHaveBeenCalled())
expect(h.kept).not.toHaveBeenCalled()
cleanup()

h.officeJob.mockClear()
h.role = 'helpers'
h.sessions = [session('s1', OFFICE, 'Swept the shop', 5)]
draw()
await openDetail()
await screen.findByText(/ZZ Test Office/)
expect(h.officeJob).not.toHaveBeenCalled()
expect(h.kept).not.toHaveBeenCalled()
})
})
Loading
Loading