@startsimpli/integrations 0.2.142 → 0.2.144

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.142",
3
+ "version": "0.2.144",
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",
@@ -50,9 +50,9 @@
50
50
  "react-native": ">=0.74.0",
51
51
  "@startsimpli/ui-native": ">=0.1.12",
52
52
  "react-native-safe-area-context": ">=4.0.0",
53
- "@startsimpli/ui": "^0.4.171",
53
+ "@startsimpli/auth": "^0.4.50",
54
54
  "@startsimpli/utils": "^0.4.17",
55
- "@startsimpli/auth": "^0.4.50"
55
+ "@startsimpli/ui": "^0.4.171"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -661,3 +661,46 @@ describe('TrackerPage — done fold and blocked reason', () => {
661
661
  expect(await screen.findByText(/Waiting on DNS/)).toBeInTheDocument();
662
662
  });
663
663
  });
664
+
665
+ describe('TrackerPage — filtering', () => {
666
+ it('narrows the list by title, owner or project as you type, and says when nothing matches', async () => {
667
+ render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} projectNames={{}} />);
668
+ await screen.findByText('Chase the inventor for comments on 2148');
669
+ const box = screen.getByRole('searchbox', { name: /filter to-dos/i });
670
+ await userEvent.type(box, 'equity');
671
+ expect(screen.getByText('Send the equity sheet to Harry Holcomb')).toBeInTheDocument();
672
+ expect(screen.queryByText('Chase the inventor for comments on 2148')).toBeNull();
673
+ await userEvent.clear(box);
674
+ await userEvent.type(box, 'rae');
675
+ expect(screen.getByText('Chase the inventor for comments on 2148')).toBeInTheDocument();
676
+ await userEvent.clear(box);
677
+ await userEvent.type(box, 'zzzz');
678
+ expect(screen.getByText(/no to-dos match/i)).toBeInTheDocument();
679
+ expect(screen.queryByText(/nothing is owed/i)).toBeNull();
680
+ });
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
+ });
@@ -155,6 +155,8 @@ export function TrackerPage({
155
155
 
156
156
  const [rows, setRows] = React.useState<Commitment[]>([]);
157
157
  const [total, setTotal] = React.useState(0);
158
+ const [pageNo, setPageNo] = React.useState(1);
159
+ const [loadingMore, setLoadingMore] = React.useState(false);
158
160
  const [applied, setApplied] = React.useState<string[]>([]);
159
161
  const [loading, setLoading] = React.useState(true);
160
162
  const [error, setError] = React.useState('');
@@ -190,6 +192,7 @@ export function TrackerPage({
190
192
  try {
191
193
  const page = await apiRef.current.listCommitments(query);
192
194
  setRows(page.results);
195
+ setPageNo(1);
193
196
  setTotal(page.count);
194
197
  setApplied(page.appliedFilters ?? []);
195
198
  if (page.results.length > 0) {
@@ -209,6 +212,25 @@ export function TrackerPage({
209
212
  }
210
213
  }, [query]);
211
214
 
215
+ /** The next SERVER page of what is owed, appended; the list never loads in one piece. */
216
+ const loadMore = React.useCallback(async () => {
217
+ setLoadingMore(true);
218
+ try {
219
+ const next = pageNo + 1;
220
+ const page = await apiRef.current.listCommitments({ ...query, page: next });
221
+ setRows((prev) => {
222
+ const seen = new Set(prev.map((r) => r.externalId));
223
+ return [...prev, ...page.results.filter((r) => !seen.has(r.externalId))];
224
+ });
225
+ setPageNo(next);
226
+ setTotal(page.count);
227
+ } catch (err) {
228
+ setError(failureMessage(err));
229
+ } finally {
230
+ setLoadingMore(false);
231
+ }
232
+ }, [pageNo, query]);
233
+
212
234
  const loadDone = React.useCallback(async () => {
213
235
  try {
214
236
  const page = await apiRef.current.listCommitments({ status: ['done', 'dropped'], withFocus: true, pageSize: 50 });
@@ -314,13 +336,22 @@ export function TrackerPage({
314
336
  // `sweepEpoch` re-arms the poll after the button starts a new one.
315
337
  }, [canQueue, pollMs, maxAutoResumes, scope.orgId, sweepEpoch]);
316
338
 
339
+ const [filterText, setFilterText] = React.useState('');
340
+ /** Client-side narrowing over the loaded page: title, owner, subject or project name. */
341
+ const matches = React.useCallback((r: Commitment) => {
342
+ const q = filterText.trim().toLowerCase();
343
+ if (!q) return true;
344
+ const project = r.focusId ? projectNames[r.focusId] ?? '' : '';
345
+ return [r.title, r.ownerName, r.subject, project, r.detail].some((v) => (v ?? '').toLowerCase().includes(q));
346
+ }, [filterText, projectNames]);
347
+ const filtering = filterText.trim().length > 0;
317
348
  const groups = React.useMemo(
318
- () => groupTracker(rows, { now: clock, timeZone }),
319
- [rows, clock, timeZone],
349
+ () => groupTracker(rows.filter(matches), { now: clock, timeZone }),
350
+ [rows, matches, clock, timeZone],
320
351
  );
321
352
  const doneGroups = React.useMemo(
322
- () => (doneRows ? groupTracker(doneRows, { now: clock, timeZone }).done : []),
323
- [doneRows, clock, timeZone],
353
+ () => (doneRows ? groupTracker(doneRows.filter(matches), { now: clock, timeZone }).done : []),
354
+ [doneRows, matches, clock, timeZone],
324
355
  );
325
356
 
326
357
  /** One write, then the list is re-read: the server is the source of what is owed. */
@@ -401,6 +432,14 @@ export function TrackerPage({
401
432
  <button type="submit" className={cn.secondaryButton} disabled={adding || !draftTitle.trim()}>Add</button>
402
433
  </form>
403
434
  ) : null}
435
+ {rows.length > 0 ? (
436
+ <input
437
+ type="search" className={`${cn.input} w-full`} value={filterText}
438
+ onChange={(e) => setFilterText(e.target.value)}
439
+ placeholder="Filter to-dos by title, owner or project…" aria-label="Filter to-dos"
440
+ />
441
+ ) : null}
442
+ {filtering && owed === 0 && rows.length > 0 ? <p className={cn.muted}>No to-dos match “{filterText.trim()}”.</p> : null}
404
443
  <div className="flex flex-wrap items-center gap-3">
405
444
  <p className={cn.muted} data-testid="tracker-summary">
406
445
  {loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
@@ -468,7 +507,7 @@ export function TrackerPage({
468
507
  {sweep ? <SweepPanel sweep={sweep} now={clock} classNames={cn} onOpenDocument={onOpenDocument} /> : null}
469
508
  {run ? <RunSummary result={run} classNames={cn} onOpenDocument={onOpenDocument} /> : null}
470
509
 
471
- {!loading && owed === 0 && c.stale === 0 ? (
510
+ {!loading && owed === 0 && c.stale === 0 && !filtering ? (
472
511
  <p className={cn.muted}>
473
512
  {workspaceHasAny === false
474
513
  ? 'Nothing has been pulled out of your meetings yet. Connect a source, then run “Pull from meetings”.'
@@ -490,7 +529,12 @@ export function TrackerPage({
490
529
  ) : null))}
491
530
 
492
531
  {total > rows.length ? (
493
- <p className={cn.muted}>Showing the first {rows.length} of {total} open items.</p>
532
+ <p className={cn.muted}>
533
+ Showing {rows.length} of {total} open items.{' '}
534
+ <button type="button" className="text-blue-700 underline disabled:opacity-50" disabled={loadingMore} onClick={() => void loadMore()}>
535
+ {loadingMore ? 'Loading…' : 'Load more'}
536
+ </button>
537
+ </p>
494
538
  ) : null}
495
539
 
496
540
  {c.stale ? (