@startsimpli/integrations 0.2.143 → 0.2.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.143",
3
+ "version": "0.2.145",
4
4
  "description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://startsimpli.com",
@@ -679,3 +679,51 @@ describe('TrackerPage — filtering', () => {
679
679
  expect(screen.queryByText(/nothing is owed/i)).toBeNull();
680
680
  });
681
681
  });
682
+
683
+ describe('TrackerPage — paging a large list', () => {
684
+ it('loads the next server page on request and appends it', async () => {
685
+ const pages: Record<number, Commitment[]> = {
686
+ 1: [commitment({ externalId: 'commit:p1', title: 'First page item' })],
687
+ 2: [commitment({ externalId: 'commit:p2', title: 'Second page item' })],
688
+ };
689
+ const seen: number[] = [];
690
+ const api: CommitmentTrackerApi = {
691
+ async listCommitments(query: CommitmentQuery = {}) {
692
+ const page = query.page ?? 1;
693
+ if (query.status) seen.push(page);
694
+ return { count: 2, next: page === 1 ? 'more' : null, previous: null, results: pages[page] ?? [], appliedFilters: [] };
695
+ },
696
+ };
697
+ render(<TrackerPage api={api} scope={SCOPE} now={NOW} />);
698
+ await screen.findByText('First page item');
699
+ expect(screen.queryByText('Second page item')).toBeNull();
700
+ await userEvent.click(screen.getByRole('button', { name: /load more/i }));
701
+ expect(await screen.findByText('Second page item')).toBeInTheDocument();
702
+ expect(screen.getByText('First page item')).toBeInTheDocument();
703
+ expect(seen).toEqual([1, 2]);
704
+ expect(screen.queryByRole('button', { name: /load more/i })).toBeNull();
705
+ });
706
+ });
707
+
708
+ describe('TrackerPage — quick filters', () => {
709
+ it('narrows to overdue, blocked or in progress with one click, and back to all', async () => {
710
+ const rows = [
711
+ commitment({ externalId: 'commit:late', title: 'Late one', dueAt: '2026-08-05T00:00:00Z' }),
712
+ commitment({ externalId: 'commit:blk', title: 'Stuck one', status: 'blocked', statusReason: 'waiting' }),
713
+ commitment({ externalId: 'commit:wip', title: 'Moving one', status: 'in_progress' }),
714
+ ];
715
+ render(<TrackerPage api={makeApi({ rows })} scope={SCOPE} now={NOW} />);
716
+ await screen.findByText('Late one');
717
+ await userEvent.click(screen.getByRole('button', { name: 'Overdue' }));
718
+ expect(screen.getByText('Late one')).toBeInTheDocument();
719
+ expect(screen.queryByText('Stuck one')).toBeNull();
720
+ await userEvent.click(screen.getByRole('button', { name: 'Blocked' }));
721
+ expect(screen.getByText('Stuck one')).toBeInTheDocument();
722
+ expect(screen.queryByText('Late one')).toBeNull();
723
+ await userEvent.click(screen.getByRole('button', { name: 'In progress' }));
724
+ expect(screen.getByText('Moving one')).toBeInTheDocument();
725
+ await userEvent.click(screen.getByRole('button', { name: 'All' }));
726
+ expect(screen.getByText('Late one')).toBeInTheDocument();
727
+ expect(screen.getByText('Stuck one')).toBeInTheDocument();
728
+ });
729
+ });
@@ -28,6 +28,7 @@ import * as React from 'react';
28
28
 
29
29
  import { isStalled, runCoverage, runProgress } from '../../corpus/runs';
30
30
  import { stripMarkdown } from '../Markdown';
31
+ import { isOverdue } from '../../corpus/work-item-logic';
31
32
  import { useTrackerName } from '../../task-tracker/useTrackerName';
32
33
  import type { MemberConnectionsApi } from './types';
33
34
  import { failureMessage, unfilteredMessage } from './work-items';
@@ -155,6 +156,8 @@ export function TrackerPage({
155
156
 
156
157
  const [rows, setRows] = React.useState<Commitment[]>([]);
157
158
  const [total, setTotal] = React.useState(0);
159
+ const [pageNo, setPageNo] = React.useState(1);
160
+ const [loadingMore, setLoadingMore] = React.useState(false);
158
161
  const [applied, setApplied] = React.useState<string[]>([]);
159
162
  const [loading, setLoading] = React.useState(true);
160
163
  const [error, setError] = React.useState('');
@@ -190,6 +193,7 @@ export function TrackerPage({
190
193
  try {
191
194
  const page = await apiRef.current.listCommitments(query);
192
195
  setRows(page.results);
196
+ setPageNo(1);
193
197
  setTotal(page.count);
194
198
  setApplied(page.appliedFilters ?? []);
195
199
  if (page.results.length > 0) {
@@ -209,6 +213,25 @@ export function TrackerPage({
209
213
  }
210
214
  }, [query]);
211
215
 
216
+ /** The next SERVER page of what is owed, appended; the list never loads in one piece. */
217
+ const loadMore = React.useCallback(async () => {
218
+ setLoadingMore(true);
219
+ try {
220
+ const next = pageNo + 1;
221
+ const page = await apiRef.current.listCommitments({ ...query, page: next });
222
+ setRows((prev) => {
223
+ const seen = new Set(prev.map((r) => r.externalId));
224
+ return [...prev, ...page.results.filter((r) => !seen.has(r.externalId))];
225
+ });
226
+ setPageNo(next);
227
+ setTotal(page.count);
228
+ } catch (err) {
229
+ setError(failureMessage(err));
230
+ } finally {
231
+ setLoadingMore(false);
232
+ }
233
+ }, [pageNo, query]);
234
+
212
235
  const loadDone = React.useCallback(async () => {
213
236
  try {
214
237
  const page = await apiRef.current.listCommitments({ status: ['done', 'dropped'], withFocus: true, pageSize: 50 });
@@ -315,14 +338,19 @@ export function TrackerPage({
315
338
  }, [canQueue, pollMs, maxAutoResumes, scope.orgId, sweepEpoch]);
316
339
 
317
340
  const [filterText, setFilterText] = React.useState('');
341
+ type QuickKey = 'all' | 'overdue' | 'blocked' | 'in_progress';
342
+ const [quick, setQuick] = React.useState<QuickKey>('all');
318
343
  /** Client-side narrowing over the loaded page: title, owner, subject or project name. */
319
344
  const matches = React.useCallback((r: Commitment) => {
345
+ if (quick === 'overdue' && !isOverdue(r, clock)) return false;
346
+ if (quick === 'blocked' && r.status !== 'blocked') return false;
347
+ if (quick === 'in_progress' && r.status !== 'in_progress') return false;
320
348
  const q = filterText.trim().toLowerCase();
321
349
  if (!q) return true;
322
350
  const project = r.focusId ? projectNames[r.focusId] ?? '' : '';
323
351
  return [r.title, r.ownerName, r.subject, project, r.detail].some((v) => (v ?? '').toLowerCase().includes(q));
324
- }, [filterText, projectNames]);
325
- const filtering = filterText.trim().length > 0;
352
+ }, [filterText, quick, clock, projectNames]);
353
+ const filtering = filterText.trim().length > 0 || quick !== 'all';
326
354
  const groups = React.useMemo(
327
355
  () => groupTracker(rows.filter(matches), { now: clock, timeZone }),
328
356
  [rows, matches, clock, timeZone],
@@ -417,7 +445,17 @@ export function TrackerPage({
417
445
  placeholder="Filter to-dos by title, owner or project…" aria-label="Filter to-dos"
418
446
  />
419
447
  ) : null}
420
- {filtering && owed === 0 && rows.length > 0 ? <p className={cn.muted}>No to-dos match “{filterText.trim()}”.</p> : null}
448
+ {rows.length > 0 ? (
449
+ <div className="flex flex-wrap gap-2" role="group" aria-label="Quick filters">
450
+ {([['all', 'All'], ['overdue', 'Overdue'], ['blocked', 'Blocked'], ['in_progress', 'In progress']] as Array<[QuickKey, string]>).map(([key, label]) => (
451
+ <button
452
+ key={key} type="button" aria-pressed={quick === key} onClick={() => setQuick(key)}
453
+ className={`rounded-full border px-3 py-1 text-xs ${quick === key ? 'border-gray-900 bg-gray-900 text-white' : 'border-gray-300 text-gray-700'}`}
454
+ >{label}</button>
455
+ ))}
456
+ </div>
457
+ ) : null}
458
+ {filtering && owed === 0 && rows.length > 0 ? <p className={cn.muted}>No to-dos match{filterText.trim() ? ` “${filterText.trim()}”` : ' this filter'}.</p> : null}
421
459
  <div className="flex flex-wrap items-center gap-3">
422
460
  <p className={cn.muted} data-testid="tracker-summary">
423
461
  {loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
@@ -507,7 +545,12 @@ export function TrackerPage({
507
545
  ) : null))}
508
546
 
509
547
  {total > rows.length ? (
510
- <p className={cn.muted}>Showing the first {rows.length} of {total} open items.</p>
548
+ <p className={cn.muted}>
549
+ Showing {rows.length} of {total} open items.{' '}
550
+ <button type="button" className="text-blue-700 underline disabled:opacity-50" disabled={loadingMore} onClick={() => void loadMore()}>
551
+ {loadingMore ? 'Loading…' : 'Load more'}
552
+ </button>
553
+ </p>
511
554
  ) : null}
512
555
 
513
556
  {c.stale ? (