@startsimpli/integrations 0.2.139 → 0.2.140

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.139",
3
+ "version": "0.2.140",
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",
54
53
  "@startsimpli/auth": "^0.4.50",
55
- "@startsimpli/utils": "^0.4.17"
54
+ "@startsimpli/utils": "^0.4.17",
55
+ "@startsimpli/ui": "^0.4.171"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -627,3 +627,22 @@ describe('TrackerPage — opening a to-do', () => {
627
627
  expect(onOpenDocument).not.toHaveBeenCalled();
628
628
  });
629
629
  });
630
+
631
+ describe('TrackerPage — adding a to-do', () => {
632
+ it('adds a to-do from a quick-add box and re-reads the list', async () => {
633
+ const createCommitment = vi.fn(async () => ROWS[0]);
634
+ let calls = 0;
635
+ const api = { ...makeApi({ onQuery: () => { calls += 1; } }), createCommitment } as CommitmentTrackerApi;
636
+ render(<TrackerPage api={api} scope={SCOPE} />);
637
+ await screen.findByText('Chase the inventor for comments on 2148');
638
+ await userEvent.type(screen.getByRole('textbox', { name: /add a to-do/i }), 'Call the notary{Enter}');
639
+ expect(createCommitment).toHaveBeenCalledWith(expect.objectContaining({ title: 'Call the notary' }));
640
+ await vi.waitFor(() => expect(calls).toBeGreaterThan(1));
641
+ });
642
+
643
+ it('offers no quick-add when the api cannot create', async () => {
644
+ render(<TrackerPage api={makeApi()} scope={SCOPE} />);
645
+ await screen.findByText('Chase the inventor for comments on 2148');
646
+ expect(screen.queryByRole('textbox', { name: /add a to-do/i })).toBeNull();
647
+ });
648
+ });
@@ -335,6 +335,25 @@ export function TrackerPage({
335
335
  }
336
336
  }, [doneOpen, loadDone]);
337
337
  const canWrite = Boolean(api.updateCommitment);
338
+ const canAdd = Boolean(api.createCommitment);
339
+ const [draftTitle, setDraftTitle] = React.useState('');
340
+ const [adding, setAdding] = React.useState(false);
341
+ /** Quick-add: a title is enough; everything else is edited on the detail page. */
342
+ const addTodo = async () => {
343
+ const title = draftTitle.trim();
344
+ if (!title || adding) return;
345
+ setAdding(true);
346
+ setError('');
347
+ try {
348
+ await apiRef.current.createCommitment!({ title });
349
+ setDraftTitle('');
350
+ await loadRef.current();
351
+ } catch (err) {
352
+ setError(failureMessage(err));
353
+ } finally {
354
+ setAdding(false);
355
+ }
356
+ };
338
357
  const open = (item: Commitment) => {
339
358
  if (onOpenItem) { onOpenItem(item); return; }
340
359
  const doc = item.mentions[0]?.documentId;
@@ -372,6 +391,16 @@ export function TrackerPage({
372
391
 
373
392
  return (
374
393
  <div className={cn.root}>
394
+ {canAdd ? (
395
+ <form className="flex gap-2" onSubmit={(e) => { e.preventDefault(); void addTodo(); }}>
396
+ <input
397
+ className={`${cn.input} flex-1`} value={draftTitle} disabled={adding}
398
+ onChange={(e) => setDraftTitle(e.target.value)}
399
+ placeholder="Add a to-do…" aria-label="Add a to-do"
400
+ />
401
+ <button type="submit" className={cn.secondaryButton} disabled={adding || !draftTitle.trim()}>Add</button>
402
+ </form>
403
+ ) : null}
375
404
  <div className="flex flex-wrap items-center gap-3">
376
405
  <p className={cn.muted} data-testid="tracker-summary">
377
406
  {loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}