fix(clients): Show Completed toggle did nothing for tasks older than 7 days
The default task fetch (/api/clients/[id]/tasks) already excludes completed/cancelled/NA tasks older than a 7-day cutoff server-side. The "Show Completed" button only filtered the in-memory task list, so if all completed tasks were older than a week, toggling it revealed nothing — they were never fetched. Wire the toggle to re-fetch with archived=true (bypasses the cutoff) when turning it on, and revert to the default filtered fetch when turning it back off, so it doesn't leak dead-policy tasks into the non-completed view.
This commit is contained in:
parent
6a5006822b
commit
38365e97b5
1 changed files with 11 additions and 1 deletions
|
|
@ -112,6 +112,16 @@ export function ClientDetail({ client, designations, policyGroups = [], allPolic
|
|||
refreshTasks(next)
|
||||
}
|
||||
|
||||
const handleToggleCompleted = () => {
|
||||
const next = !showCompleted
|
||||
setShowCompleted(next)
|
||||
// The default (non-archived) task fetch only includes completed/cancelled/NA tasks
|
||||
// from the last 7 days — anything older needs the archived fetch to actually load.
|
||||
// Revert to the filtered fetch when turning it back off (unless Show Archived is
|
||||
// separately on) so dead-policy tasks pulled in by the archived fetch don't leak in.
|
||||
if (!showArchivedTasks) refreshTasks(next)
|
||||
}
|
||||
|
||||
// Assignments state
|
||||
const [allUsers, setAllUsers] = useState<SimpleUser[]>([])
|
||||
const [claimsUsers, setClaimsUsers] = useState<SimpleUser[]>([])
|
||||
|
|
@ -647,7 +657,7 @@ export function ClientDetail({ client, designations, policyGroups = [], allPolic
|
|||
|
||||
{/* Show completed toggle */}
|
||||
<button
|
||||
onClick={() => setShowCompleted((v) => !v)}
|
||||
onClick={handleToggleCompleted}
|
||||
className={`flex items-center gap-1.5 px-3 py-1.5 rounded transition-colors font-medium ${
|
||||
showCompleted
|
||||
? 'bg-primary text-primary-foreground'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue