@baack-software/baack-ts-crm 0.0.2 → 0.0.3

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.
Files changed (112) hide show
  1. package/dist/backend.d.ts +29 -1
  2. package/dist/backend.d.ts.map +1 -1
  3. package/dist/backend.js +95 -0
  4. package/dist/backend.js.map +1 -1
  5. package/dist/crm-client.d.ts +55 -13
  6. package/dist/crm-client.d.ts.map +1 -1
  7. package/dist/crm-client.js +99 -15
  8. package/dist/crm-client.js.map +1 -1
  9. package/dist/deal-order.d.ts +42 -0
  10. package/dist/deal-order.d.ts.map +1 -0
  11. package/dist/deal-order.js +80 -0
  12. package/dist/deal-order.js.map +1 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/invoices.d.ts +7 -0
  18. package/dist/invoices.d.ts.map +1 -1
  19. package/dist/invoices.js +20 -2
  20. package/dist/invoices.js.map +1 -1
  21. package/dist/period.d.ts +15 -2
  22. package/dist/period.d.ts.map +1 -1
  23. package/dist/period.js +27 -1
  24. package/dist/period.js.map +1 -1
  25. package/dist/pipeline.d.ts +6 -0
  26. package/dist/pipeline.d.ts.map +1 -1
  27. package/dist/pipeline.js +18 -0
  28. package/dist/pipeline.js.map +1 -1
  29. package/dist/react/ChoiceCombobox.d.ts +36 -0
  30. package/dist/react/ChoiceCombobox.d.ts.map +1 -0
  31. package/dist/react/ChoiceCombobox.js +105 -0
  32. package/dist/react/ChoiceCombobox.js.map +1 -0
  33. package/dist/react/DealsBoard.d.ts +22 -3
  34. package/dist/react/DealsBoard.d.ts.map +1 -1
  35. package/dist/react/DealsBoard.js +53 -4
  36. package/dist/react/DealsBoard.js.map +1 -1
  37. package/dist/react/Details.d.ts +40 -7
  38. package/dist/react/Details.d.ts.map +1 -1
  39. package/dist/react/Details.js +180 -23
  40. package/dist/react/Details.js.map +1 -1
  41. package/dist/react/Forms.d.ts +148 -17
  42. package/dist/react/Forms.d.ts.map +1 -1
  43. package/dist/react/Forms.js +365 -75
  44. package/dist/react/Forms.js.map +1 -1
  45. package/dist/react/Sales.d.ts +25 -6
  46. package/dist/react/Sales.d.ts.map +1 -1
  47. package/dist/react/Sales.js +114 -30
  48. package/dist/react/Sales.js.map +1 -1
  49. package/dist/react/SidePanel.d.ts +10 -0
  50. package/dist/react/SidePanel.d.ts.map +1 -1
  51. package/dist/react/SidePanel.js +14 -2
  52. package/dist/react/SidePanel.js.map +1 -1
  53. package/dist/react/index.d.ts +1 -0
  54. package/dist/react/index.d.ts.map +1 -1
  55. package/dist/react/index.js +1 -0
  56. package/dist/react/index.js.map +1 -1
  57. package/dist/react/parts.d.ts +12 -2
  58. package/dist/react/parts.d.ts.map +1 -1
  59. package/dist/react/parts.js +25 -2
  60. package/dist/react/parts.js.map +1 -1
  61. package/dist/react/pipeline-choice.d.ts +19 -0
  62. package/dist/react/pipeline-choice.d.ts.map +1 -0
  63. package/dist/react/pipeline-choice.js +39 -0
  64. package/dist/react/pipeline-choice.js.map +1 -0
  65. package/dist/react/text.d.ts +89 -2
  66. package/dist/react/text.d.ts.map +1 -1
  67. package/dist/react/text.js +89 -2
  68. package/dist/react/text.js.map +1 -1
  69. package/dist/react/ui/badge.d.ts +1 -1
  70. package/dist/react/ui/button.d.ts +2 -2
  71. package/dist/react/views.d.ts +33 -11
  72. package/dist/react/views.d.ts.map +1 -1
  73. package/dist/react/views.js +96 -27
  74. package/dist/react/views.js.map +1 -1
  75. package/dist/sales.d.ts +28 -3
  76. package/dist/sales.d.ts.map +1 -1
  77. package/dist/sales.js +33 -10
  78. package/dist/sales.js.map +1 -1
  79. package/dist/store.d.ts +31 -12
  80. package/dist/store.d.ts.map +1 -1
  81. package/dist/store.js +82 -21
  82. package/dist/store.js.map +1 -1
  83. package/dist/target.d.ts +2 -1
  84. package/dist/target.d.ts.map +1 -1
  85. package/dist/target.js +6 -2
  86. package/dist/target.js.map +1 -1
  87. package/dist/types.d.ts +24 -0
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/backend.ts +131 -1
  92. package/src/crm-client.ts +162 -19
  93. package/src/deal-order.ts +116 -0
  94. package/src/index.ts +1 -0
  95. package/src/invoices.ts +22 -2
  96. package/src/period.ts +41 -2
  97. package/src/pipeline.ts +21 -0
  98. package/src/react/ChoiceCombobox.tsx +227 -0
  99. package/src/react/DealsBoard.tsx +171 -4
  100. package/src/react/Details.tsx +608 -31
  101. package/src/react/Forms.tsx +1006 -139
  102. package/src/react/Sales.tsx +332 -44
  103. package/src/react/SidePanel.tsx +19 -10
  104. package/src/react/index.ts +1 -0
  105. package/src/react/parts.tsx +56 -4
  106. package/src/react/pipeline-choice.ts +54 -0
  107. package/src/react/text.ts +90 -2
  108. package/src/react/views.tsx +222 -32
  109. package/src/sales.ts +57 -10
  110. package/src/store.ts +136 -27
  111. package/src/target.ts +5 -2
  112. package/src/types.ts +28 -0
@@ -1,4 +1,6 @@
1
+ import { type DealFilter, type DealOrder } from '../deal-order.ts';
1
2
  import type { Deal, Pipeline, PipelineStage } from '../types.ts';
3
+ import type { CrmChoice } from './Forms.tsx';
2
4
  import { type CrmNames } from './format.ts';
3
5
  import { type CrmText } from './text.ts';
4
6
  /** Picks the stage a deal is at; moving it is one choice, so it works from the keyboard as well as by pointer. */
@@ -11,12 +13,29 @@ export declare function StageSelect({ deal, pipeline, onMove, disabled, text, cl
11
13
  className?: string | undefined;
12
14
  }): import("react").JSX.Element;
13
15
  /**
14
- * Deals as a board, one column per pipeline stage with its count and value. Each deal can be opened, and moved with
15
- * its stage picker.
16
+ * Filters for the deals board, as the tasks view has (words, outcome, assignee and company), and the order of each
17
+ * column's deals: weighted, by size or by urgency (see `sortDeals`). Controlled; apply them with `filterDeals`.
16
18
  */
17
- export declare function DealsBoard({ deals, pipeline, names, onOpen, onMove, selected, saving, sample, text, }: {
19
+ export declare function DealFilters({ value, onChange, order, onOrder, team, companies, shown, text, }: {
20
+ value: DealFilter;
21
+ onChange: (filter: DealFilter) => void;
22
+ order: DealOrder;
23
+ onOrder: (order: DealOrder) => void;
24
+ team?: readonly CrmChoice[] | undefined;
25
+ companies?: readonly CrmChoice[] | undefined;
26
+ /** How many deals the filters leave, announced as they change. */
27
+ shown?: number | undefined;
28
+ text?: Partial<CrmText> | undefined;
29
+ }): import("react").JSX.Element;
30
+ /**
31
+ * Deals as a board, one column per pipeline stage with its count and value, each column in `order` (weighted to start
32
+ * with). Each deal can be opened, and moved with its stage picker.
33
+ */
34
+ export declare function DealsBoard({ deals, pipeline, names, onOpen, onMove, selected, saving, sample, order, text, }: {
18
35
  deals: readonly Deal[];
19
36
  pipeline: Pipeline;
37
+ /** How each column's deals are ordered. */
38
+ order?: DealOrder | undefined;
20
39
  names?: CrmNames | undefined;
21
40
  onOpen?: ((deal: Deal) => void) | undefined;
22
41
  onMove?: ((deal: Deal, stage: PipelineStage) => void) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"DealsBoard.d.ts","sourceRoot":"","sources":["../../src/react/DealsBoard.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAA6D,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvG,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAInD,kHAAkH;AAClH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,SAAS,GACV,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,I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EAClB,IAAI,GACL,EAAE;IACD,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5C,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAClE,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,iCAAiC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACzC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;CACrC,+BAqGA"}
@@ -1,12 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from 'cn';
3
+ import { Search, X } from 'lucide-react';
4
+ import { useId } from 'react';
5
+ import { DEAL_ORDERS, sortDeals } from "../deal-order.js";
3
6
  import { addMoney } from "../money.js";
4
7
  import { dealCompany, dealOutcome, orderedStages } from "../pipeline.js";
5
8
  import { companyNameOf, formatDate, formatMaybeMoney, formatTotals } from "./format.js";
6
9
  import { OutcomeBadge, SampleDataBadge } from "./parts.js";
7
10
  import { recordItemId } from "./SidePanel.js";
8
11
  import { withText } from "./text.js";
12
+ import { Button } from "./ui/button.js";
9
13
  import { Card, CardContent, CardHeader, CardTitle } from "./ui/card.js";
14
+ import { Input } from "./ui/input.js";
15
+ import { Label } from "./ui/label.js";
10
16
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select.js";
11
17
  /** Picks the stage a deal is at; moving it is one choice, so it works from the keyboard as well as by pointer. */
12
18
  export function StageSelect({ deal, pipeline, onMove, disabled, text, className, }) {
@@ -18,14 +24,57 @@ export function StageSelect({ deal, pipeline, onMove, disabled, text, className,
18
24
  onMove(deal, stage);
19
25
  }, children: [_jsx(SelectTrigger, { size: "sm", "aria-label": `${words.moveTo}: ${deal.title}`, className: className, children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: stages.map((stage) => (_jsx(SelectItem, { value: stage.urn, children: stage.name }, stage.urn))) })] }));
20
26
  }
27
+ const ANY = '__any__';
28
+ const NONE = '__none__';
29
+ const ORDER_WORDS = {
30
+ weighted: 'orderWeighted',
31
+ size: 'orderSize',
32
+ urgency: 'orderUrgency',
33
+ };
34
+ const OUTCOMES = [
35
+ { outcome: 'OPEN', label: 'outcomeOpen' },
36
+ { outcome: 'WON', label: 'outcomeWon' },
37
+ { outcome: 'LOST', label: 'outcomeLost' },
38
+ ];
39
+ /** A labelled select of a filter or order, with "any" as `ANY` and "none" as `NONE`. */
40
+ function ToolbarSelect({ label, value, onChange, options, className, }) {
41
+ const id = useId();
42
+ return (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: id, children: label }), _jsxs(Select, { value: value, onValueChange: onChange, children: [_jsx(SelectTrigger, { id: id, className: className, children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: options.map((option) => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value))) })] })] }));
43
+ }
44
+ /**
45
+ * Filters for the deals board, as the tasks view has (words, outcome, assignee and company), and the order of each
46
+ * column's deals: weighted, by size or by urgency (see `sortDeals`). Controlled; apply them with `filterDeals`.
47
+ */
48
+ export function DealFilters({ value, onChange, order, onOrder, team = [], companies = [], shown, text, }) {
49
+ const words = withText(text);
50
+ const set = (key, next) => {
51
+ const { [key]: _removed, ...rest } = value;
52
+ onChange(next === undefined ? rest : { ...rest, [key]: next });
53
+ };
54
+ const pick = (selected) => (selected === ANY ? undefined : selected === NONE ? null : selected);
55
+ const current = (selected) => selected === undefined ? ANY : selected === null ? NONE : selected;
56
+ const active = Object.values(value).some((field) => field !== undefined && field !== '');
57
+ return (_jsxs("div", { role: "search", "aria-label": words.filterDeals, className: "flex flex-wrap items-end gap-3", children: [_jsxs("div", { className: "relative min-w-48 flex-1", children: [_jsx(Search, { "aria-hidden": "true", className: "text-muted-foreground absolute top-1/2 left-2.5 size-4 -translate-y-1/2" }), _jsx(Input, { type: "search", "aria-label": words.filterDeals, placeholder: words.filterDeals, value: value.text ?? '', onChange: (event) => set('text', event.target.value || undefined), className: "pl-8" })] }), _jsx(ToolbarSelect, { label: words.outcome, value: value.outcome ?? ANY, onChange: (selected) => set('outcome', selected === ANY ? undefined : selected), options: [
58
+ { value: ANY, label: words.allOutcomes },
59
+ ...OUTCOMES.map(({ outcome, label }) => ({ value: outcome, label: words[label] })),
60
+ ], className: "w-36" }), _jsx(ToolbarSelect, { label: words.assignee, value: current(value.assignee), onChange: (selected) => set('assignee', pick(selected)), options: [
61
+ { value: ANY, label: words.anyone },
62
+ { value: NONE, label: words.unassigned },
63
+ ...team.map((person) => ({ value: person.urn, label: person.name })),
64
+ ], className: "w-44" }), companies.length > 0 && (_jsx(ToolbarSelect, { label: words.company, value: current(value.company), onChange: (selected) => set('company', pick(selected)), options: [
65
+ { value: ANY, label: words.allCompanies },
66
+ { value: NONE, label: words.noCompany },
67
+ ...companies.map((company) => ({ value: company.urn, label: company.name })),
68
+ ], className: "w-44" })), _jsx(ToolbarSelect, { label: words.sortBy, value: order, onChange: (selected) => onOrder(selected), options: DEAL_ORDERS.map((option) => ({ value: option, label: words[ORDER_WORDS[option]] })), className: "w-36" }), active && (_jsxs(Button, { variant: "ghost", size: "sm", onClick: () => onChange({}), children: [_jsx(X, { "aria-hidden": "true" }), words.clearFilters] })), shown !== undefined && (_jsxs("p", { "aria-live": "polite", className: "sr-only", children: [shown, " ", words.dealsShown] }))] }));
69
+ }
21
70
  /**
22
- * Deals as a board, one column per pipeline stage with its count and value. Each deal can be opened, and moved with
23
- * its stage picker.
71
+ * Deals as a board, one column per pipeline stage with its count and value, each column in `order` (weighted to start
72
+ * with). Each deal can be opened, and moved with its stage picker.
24
73
  */
25
- export function DealsBoard({ deals, pipeline, names, onOpen, onMove, selected, saving, sample, text, }) {
74
+ export function DealsBoard({ deals, pipeline, names, onOpen, onMove, selected, saving, sample, order = 'weighted', text, }) {
26
75
  const words = withText(text);
27
76
  return (_jsxs("section", { "aria-label": `${pipeline.name}: ${words.deals}`, className: "grid gap-3", children: [sample && (_jsx("div", { children: _jsx(SampleDataBadge, { text: text }) })), _jsx("div", { tabIndex: 0, "aria-label": pipeline.name, className: "flex gap-3 overflow-x-auto rounded-xl pb-2", children: orderedStages(pipeline).map((stage) => {
28
- const here = deals.filter((deal) => deal.workflowStage?.urn === stage.urn);
77
+ const here = sortDeals(deals.filter((deal) => deal.workflowStage?.urn === stage.urn), order);
29
78
  const value = here.reduce((totals, deal) => addMoney(totals, deal.targetValue), {});
30
79
  return (_jsxs("section", { "aria-labelledby": `stage-${stage.urn}`, className: "bg-muted/50 flex w-64 shrink-0 flex-col gap-2 rounded-xl p-2", children: [_jsxs("header", { className: "px-1 pt-1", children: [_jsxs("h3", { id: `stage-${stage.urn}`, className: "flex items-baseline justify-between gap-2 text-sm font-semibold", children: [stage.name, _jsx("span", { className: "text-muted-foreground font-normal tabular-nums", children: here.length })] }), _jsx("p", { className: "text-muted-foreground text-xs tabular-nums", children: formatTotals(value) })] }), here.length === 0 ? (_jsx("p", { className: "text-muted-foreground px-1 py-4 text-center text-xs", children: words.noDeals })) : (_jsx("ul", { className: "grid gap-2", children: here.map((deal) => (_jsx("li", { children: _jsxs(Card, { size: "sm", className: cn(saving?.has(deal.urn) && 'opacity-60', selected === deal.urn && 'ring-primary ring-2'), children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-sm", children: onOpen ? (_jsx("button", { type: "button", id: recordItemId(deal.urn), "aria-current": selected === deal.urn ? 'true' : undefined, className: "text-left hover:underline", onClick: () => onOpen(deal), children: deal.title })) : (deal.title) }) }), _jsxs(CardContent, { className: "grid gap-2 text-xs", children: [_jsxs("p", { className: "text-muted-foreground flex items-center justify-between gap-2", children: [_jsx("span", { children: companyNameOf(names, dealCompany(deal)?.urn) ?? words.unnamed }), dealOutcome(deal) !== 'OPEN' && (_jsx(OutcomeBadge, { outcome: dealOutcome(deal), label: dealOutcome(deal) === 'WON' ? words.outcomeWon : words.outcomeLost }))] }), _jsxs("p", { className: "flex justify-between gap-2", children: [_jsx("span", { className: "font-medium tabular-nums", children: formatMaybeMoney(deal.targetValue) }), _jsx("span", { className: "text-muted-foreground", children: formatDate(deal.closeTimestamp ?? deal.targetCloseTimestamp) })] }), onMove && (_jsx(StageSelect, { deal: deal, pipeline: pipeline, onMove: onMove, disabled: saving?.has(deal.urn), text: text, className: "w-full" }))] })] }) }, deal.urn))) }))] }, stage.urn));
31
80
  }) })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"DealsBoard.js","sourceRoot":"","sources":["../../src/react/DealsBoard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,IAAI,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAa,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAgB,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAe,CAAC;AACzE,OA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G,SAAS,EAAC,+DAA+D,aAC1E,yBAAO,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,GAAQ,EAC3E,WAAW,CAAC,IAAI,CAAC,KAAK,MAAM,IAAI,CAC/B,KAAC,YAAY,IACX,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,EAC1B,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,GACzE,CACH,IACC,EACJ,aAAG,SAAS,EAAC,4BAA4B,aACvC,eAAM,SAAS,EAAC,0BAA0B,YAAE,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,GAAQ,EACtF,eAAM,SAAS,EAAC,uBAAuB,YACpC,UAAU,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,oBAAoB,CAAC,GACxD,IACL,EACH,MAAM,IAAI,CACT,KAAC,WAAW,IACV,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAC/B,IAAI,EAAE,IAAI,EACV,SAAS,EAAC,QAAQ,GAClB,CACH,IACW,IACT,IApDA,IAAI,CAAC,GAAG,CAqDZ,CACN,CAAC,GACC,CACN,KA3EI,KAAK,CAAC,GAAG,CA4EN,CACX,CAAC;gBACJ,CAAC,CAAC,GACE,IACE,CACX,CAAC;AACJ,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import { type ReactNode } from 'react';
2
- import type { Deal, DealOutcome, Lead, Pipeline, PipelineStage } from '../types.ts';
2
+ import type { DealInput, LeadInput } from '../backend.ts';
3
+ import type { NewLeadOptions } from '../crm-client.ts';
4
+ import type { ContactDetails, Deal, DealOutcome, Lead, Pipeline, PipelineStage } from '../types.ts';
5
+ import { type CrmChoice } from './Forms.tsx';
3
6
  import { type CrmNames } from './format.ts';
4
7
  import { type CrmText } from './text.ts';
5
8
  /** Label and value pairs as a description list. */
@@ -13,18 +16,34 @@ export declare function DetailList({ items }: {
13
16
  export interface ConvertChoice {
14
17
  companyName?: string;
15
18
  }
19
+ /** Reads and sets people's email and telephone, such as `CrmStore.contactDetails` and `setContactDetails`. */
20
+ export interface ContactDetailsAccess {
21
+ load: (identity: string) => Promise<ContactDetails>;
22
+ save: (identity: string, details: Partial<ContactDetails>) => Promise<ContactDetails>;
23
+ }
16
24
  /**
17
- * A lead's details. While it's open: "Convert to deal", where the new client company's name can be corrected, and
18
- * "Mark unqualified" with why. Once unqualified it can be reopened.
25
+ * A lead's details. While it's open, its fields can be changed (with `onChange`), it can be converted ("Convert to
26
+ * deal", where the new client company's name can be corrected) and marked unqualified with why. Once unqualified it
27
+ * can be reopened.
19
28
  */
20
- export declare function LeadDetail({ lead, names, onConvert, onSetOutcome, converting, sample, text, }: {
29
+ export declare function LeadDetail({ lead, names, companies, people, team, onChange, onConvert, onSetOutcome, converting, contactDetails, sample, text, }: {
21
30
  lead: Lead;
22
31
  names?: CrmNames | undefined;
32
+ /** Companies the lead can be linked to: the host's customers. */
33
+ companies?: readonly CrmChoice[] | undefined;
34
+ /** People to choose as the contact: the host's customers' people. */
35
+ people?: readonly CrmChoice[] | undefined;
36
+ /** People to assign the lead to: the host's team. */
37
+ team?: readonly CrmChoice[] | undefined;
38
+ /** Saves a change to the open lead, making a new company or contact first when `options` asks. */
39
+ onChange?: ((changes: Partial<LeadInput>, options?: NewLeadOptions) => Promise<unknown>) | undefined;
23
40
  /** Shown while the lead is open. */
24
41
  onConvert?: ((lead: Lead, choice: ConvertChoice) => void) | undefined;
25
42
  /** Unqualifies (with why) or reopens the lead. */
26
43
  onSetOutcome?: ((lead: Lead, outcome: 'IN_PROGRESS' | 'CLOSED', closedReason?: string) => void) | undefined;
27
44
  converting?: boolean | undefined;
45
+ /** Reads and sets the contact's email and telephone, shown under the contact when given. */
46
+ contactDetails?: ContactDetailsAccess | undefined;
28
47
  sample?: boolean | undefined;
29
48
  text?: Partial<CrmText> | undefined;
30
49
  }): import("react").JSX.Element;
@@ -38,14 +57,28 @@ export declare function OutcomeControl({ deal, onSetOutcome, disabled, text, }:
38
57
  disabled?: boolean | undefined;
39
58
  text?: Partial<CrmText> | undefined;
40
59
  }): import("react").JSX.Element;
41
- /** A deal's details, with its stage picker and its outcome (open, won or lost). */
42
- export declare function DealDetail({ deal, pipeline, names, onMove, onSetOutcome, saving, sample, text, }: {
60
+ /**
61
+ * A deal's details: with `onChange`, its fields can be edited, saved as they change; its outcome is set with
62
+ * `onSetOutcome`. Without them, read only.
63
+ */
64
+ export declare function DealDetail({ deal, pipelines, names, companies, people, team, onChange, onMove, onSetOutcome, saving, contactDetails, sample, text, }: {
43
65
  deal: Deal;
44
- pipeline: Pipeline;
66
+ /** The workflows a deal can be in: its own is found from its stage. */
67
+ pipelines: readonly Pipeline[];
45
68
  names?: CrmNames | undefined;
69
+ /** Companies the deal can be with: the host's customers. */
70
+ companies?: readonly CrmChoice[] | undefined;
71
+ /** People to choose as the contact: the host's customers' people. */
72
+ people?: readonly CrmChoice[] | undefined;
73
+ /** People to assign the deal to: the host's team. */
74
+ team?: readonly CrmChoice[] | undefined;
75
+ /** Saves a change to the deal's fields. */
76
+ onChange?: ((changes: Partial<DealInput>) => Promise<unknown>) | undefined;
46
77
  onMove?: ((deal: Deal, stage: PipelineStage) => void) | undefined;
47
78
  onSetOutcome?: ((deal: Deal, outcome: DealOutcome, closedReason?: string) => void) | undefined;
48
79
  saving?: boolean | undefined;
80
+ /** Reads and sets the contact's email and telephone, shown under the contact when given. */
81
+ contactDetails?: ContactDetailsAccess | undefined;
49
82
  sample?: boolean | undefined;
50
83
  text?: Partial<CrmText> | undefined;
51
84
  }): import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Details.d.ts","sourceRoot":"","sources":["../../src/react/Details.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1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId, useState } from 'react';
3
- import { SOURCE_LABELS, leadOutcome } from "../leads.js";
4
- import { dealOutcome, dealProbability, orderedStages, stageOf } from "../pipeline.js";
2
+ import { useEffect, useId, useState } from 'react';
3
+ import { LEAD_SOURCES, LEAD_STATUS_LABELS, SOURCE_LABELS, leadOutcome } from "../leads.js";
4
+ import { minorOf, toDecimal } from "../money.js";
5
+ import { dealOutcome, dealProbability, orderedStages, pipelineOf, stageOf } from "../pipeline.js";
6
+ import { ChoiceSelect, Field, moneyOf, MoneyInput, NewCompanyStep, NewContactStep, PipelineStageFields, } from "./Forms.js";
7
+ import { ChoiceCombobox } from "./ChoiceCombobox.js";
5
8
  import { StageSelect } from "./DealsBoard.js";
6
9
  import { companyNameOf, formatDate, formatMaybeMoney, personNameOf } from "./format.js";
7
10
  import { leadCompany } from "./LeadsTable.js";
@@ -15,11 +18,119 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
15
18
  export function DetailList({ items }) {
16
19
  return (_jsx("dl", { className: "grid grid-cols-[minmax(7rem,auto)_minmax(0,1fr)] gap-x-4 gap-y-2 text-sm", children: items.map(({ label, value }) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-muted-foreground", children: label }), _jsx("dd", { children: value })] }, label))) }));
17
20
  }
21
+ /** A text field that saves when it loses focus or Enter is pressed, and only when it changed. */
22
+ function CommitInput({ id, value, onCommit, ...props }) {
23
+ const [draft, setDraft] = useState(value);
24
+ useEffect(() => setDraft(value), [value]);
25
+ const commit = () => {
26
+ if (draft.trim() !== value)
27
+ onCommit(draft.trim());
28
+ };
29
+ return (_jsx(Input, { id: id, value: draft, onChange: (event) => setDraft(event.target.value), onBlur: commit, onKeyDown: (event) => {
30
+ if (event.key === 'Enter')
31
+ commit();
32
+ }, ...props }));
33
+ }
34
+ /**
35
+ * A record's money, saved as it changes: when the amount loses focus or Enter is pressed, or the currency is chosen.
36
+ * `onInvalid` is told when the amount isn't a number of at least zero.
37
+ */
38
+ function CommitMoney({ id, value, onCommit, onInvalid, text, }) {
39
+ const savedCurrency = value?.currencyCode ?? 'GBP';
40
+ const savedAmount = value ? toDecimal(minorOf(value), savedCurrency) : '';
41
+ const [amount, setAmount] = useState(savedAmount);
42
+ const [currency, setCurrency] = useState(savedCurrency);
43
+ useEffect(() => {
44
+ setAmount(savedAmount);
45
+ setCurrency(savedCurrency);
46
+ }, [savedAmount, savedCurrency]);
47
+ const commit = (nextAmount, nextCurrency) => {
48
+ if (nextAmount.trim() === savedAmount && nextCurrency === savedCurrency)
49
+ return;
50
+ const money = moneyOf(nextAmount, nextCurrency);
51
+ if (money === undefined)
52
+ return onInvalid();
53
+ // No amount yet: the currency is kept here until there's an amount to save in it.
54
+ if (money === null && !value)
55
+ return;
56
+ onCommit(money);
57
+ };
58
+ return (_jsx(MoneyInput, { id: id, amount: amount, currencyCode: currency, onAmount: setAmount, onCurrency: (next) => {
59
+ setCurrency(next);
60
+ commit(amount, next);
61
+ }, onCommit: () => commit(amount, currency), text: text }));
62
+ }
63
+ /**
64
+ * The chosen contact's email and telephone, read from their record and saved there as they change: on the person, not
65
+ * the lead or deal, so every record with them as contact sees the change.
66
+ */
67
+ function ContactDetailsFields({ id, contact, name, access, text, }) {
68
+ const words = withText(text);
69
+ const [details, setDetails] = useState();
70
+ const [error, setError] = useState();
71
+ useEffect(() => {
72
+ let current = true;
73
+ setDetails(undefined);
74
+ setError(undefined);
75
+ access
76
+ .load(contact)
77
+ .then((loaded) => current && setDetails(loaded))
78
+ .catch(() => current && setError(words.contactDetailsUnavailable));
79
+ return () => {
80
+ current = false;
81
+ };
82
+ }, [access, contact, words.contactDetailsUnavailable]);
83
+ const save = async (changes) => {
84
+ setError(undefined);
85
+ try {
86
+ setDetails(await access.save(contact, changes));
87
+ }
88
+ catch (failure) {
89
+ setError(`${words.saveFailed} ${failure instanceof Error ? failure.message : ''}`.trim());
90
+ }
91
+ };
92
+ return (_jsxs("fieldset", { className: "grid gap-3 border-s-2 ps-3", "aria-describedby": error ? `${id}-error` : undefined, children: [_jsx("legend", { className: name ? 'text-sm font-medium' : 'sr-only', children: name ?? words.contactDetails }), _jsx(Field, { id: `${id}-email`, label: name ? `${name}: ${words.email}` : words.contactEmail, children: _jsx(CommitInput, { id: `${id}-email`, type: "email", autoComplete: "off", value: details?.email ?? '', disabled: !details, onCommit: (email) => void save({ email }) }) }), _jsx(Field, { id: `${id}-telephone`, label: name ? `${name}: ${words.telephone}` : words.contactTelephone, children: _jsx(CommitInput, { id: `${id}-telephone`, type: "tel", autoComplete: "off", value: details?.telephone ?? '', disabled: !details, onCommit: (telephone) => void save({ telephone }) }) }), error && (_jsx("p", { id: `${id}-error`, role: "alert", className: "text-destructive text-sm", children: error }))] }));
93
+ }
94
+ /** Statuses a lead can be set to: qualified comes from converting it. */
95
+ const SETTABLE_STATUSES = ['NEW', 'CONTACTED'];
96
+ /**
97
+ * An open lead's fields, each saved as it changes: title, status, company, contact, source, value and assignee. The
98
+ * company and contact can be added: "Add a new ..." opens a step for its details, and saving it saves the lead.
99
+ */
100
+ function LeadFields({ lead, names, companies, people, team, onChange, saving, contactDetails, text, }) {
101
+ const words = withText(text);
102
+ const id = useId();
103
+ const [step, setStep] = useState('fields');
104
+ const [error, setError] = useState();
105
+ const save = async (changes) => {
106
+ setError(undefined);
107
+ try {
108
+ await onChange(changes);
109
+ }
110
+ catch (failure) {
111
+ setError(`${words.saveFailed} ${failure instanceof Error ? failure.message : ''}`.trim());
112
+ }
113
+ };
114
+ if (step === 'company')
115
+ return (_jsx(NewCompanyStep, { framed: false, text: text, onBack: () => setStep('fields'), onUse: async (name) => {
116
+ // A new company replaces the lead's, so the link is cleared for it to be made.
117
+ await onChange({ contactCompany: null }, { companyName: name });
118
+ setStep('fields');
119
+ } }));
120
+ if (step === 'contact')
121
+ return (_jsx(NewContactStep, { framed: false, text: text, onBack: () => setStep('fields'), onUse: async (contact) => {
122
+ await onChange({}, { contact });
123
+ setStep('fields');
124
+ } }));
125
+ const link = (urn) => (urn ? { urn } : null);
126
+ return (_jsxs("div", { className: "grid gap-3", children: [_jsx(Field, { id: `${id}-title`, label: words.title, children: _jsx(CommitInput, { id: `${id}-title`, value: lead.title, onCommit: (title) => title && void save({ title }) }) }), _jsx(Field, { id: `${id}-status`, label: words.status, children: _jsxs(Select, { value: lead.status, onValueChange: (status) => void save({ status: status }), children: [_jsx(SelectTrigger, { id: `${id}-status`, className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: [...new Set([...SETTABLE_STATUSES, lead.status])].map((status) => (_jsx(SelectItem, { value: status, disabled: !SETTABLE_STATUSES.includes(status), children: LEAD_STATUS_LABELS[status] }, status))) })] }) }), _jsx(Field, { id: `${id}-company`, label: words.company, children: _jsx(ChoiceSelect, { id: `${id}-company`, value: lead.contactCompany?.urn ?? '', onChange: (urn) => void save({ contactCompany: link(urn) }), choices: companies, none: words.noCompany, add: { label: words.addCompany, onAdd: () => setStep('company') }, named: (urn) => companyNameOf(names, urn), text: text }) }), _jsx(Field, { id: `${id}-contact`, label: words.contact, children: _jsx(ChoiceSelect, { id: `${id}-contact`, value: lead.contactIdentity?.urn ?? '', onChange: (urn) => void save({ contactIdentity: link(urn) }), choices: people, none: words.noContact, add: { label: words.addContact, onAdd: () => setStep('contact') }, named: (urn) => personNameOf(names, urn), text: text }) }), lead.contactIdentity && contactDetails && (_jsx(ContactDetailsFields, { id: `${id}-contact-details`, contact: lead.contactIdentity.urn, access: contactDetails, text: text })), _jsx(Field, { id: `${id}-source`, label: words.source, children: _jsxs(Select, { value: lead.source, onValueChange: (source) => void save({ source: source }), children: [_jsx(SelectTrigger, { id: `${id}-source`, className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: LEAD_SOURCES.map((source) => (_jsx(SelectItem, { value: source, children: SOURCE_LABELS[source] }, source))) })] }) }), _jsx(Field, { id: `${id}-value`, label: words.value, children: _jsx(CommitMoney, { id: `${id}-value`, value: lead.targetValue, onCommit: (targetValue) => void save({ targetValue }), onInvalid: () => setError(words.invalidAmount), text: text }) }), _jsx(Field, { id: `${id}-assignee`, label: words.assignee, children: _jsx(ChoiceSelect, { id: `${id}-assignee`, value: lead.assignee?.urn ?? '', onChange: (urn) => void save({ assignee: link(urn) }), choices: team, none: words.unassigned, named: (urn) => personNameOf(names, urn), text: text }) }), _jsx("p", { "aria-live": "polite", className: "text-muted-foreground text-xs", children: saving ? words.saving : '' }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error }))] }));
127
+ }
18
128
  /**
19
- * A lead's details. While it's open: "Convert to deal", where the new client company's name can be corrected, and
20
- * "Mark unqualified" with why. Once unqualified it can be reopened.
129
+ * A lead's details. While it's open, its fields can be changed (with `onChange`), it can be converted ("Convert to
130
+ * deal", where the new client company's name can be corrected) and marked unqualified with why. Once unqualified it
131
+ * can be reopened.
21
132
  */
22
- export function LeadDetail({ lead, names, onConvert, onSetOutcome, converting, sample, text, }) {
133
+ export function LeadDetail({ lead, names, companies = [], people = [], team = [], onChange, onConvert, onSetOutcome, converting, contactDetails, sample, text, }) {
23
134
  const words = withText(text);
24
135
  const id = useId();
25
136
  const [companyName, setCompanyName] = useState('');
@@ -27,20 +138,25 @@ export function LeadDetail({ lead, names, onConvert, onSetOutcome, converting, s
27
138
  const [reason, setReason] = useState('');
28
139
  const outcome = leadOutcome(lead);
29
140
  const open = outcome === 'IN_PROGRESS';
141
+ const editable = open && onChange !== undefined;
30
142
  const submit = (event) => {
31
143
  event.preventDefault();
32
144
  onConvert?.(lead, lead.contactCompany ? {} : { companyName: companyName.trim() });
33
145
  };
34
- return (_jsx(CrmCard, { title: lead.title, sample: sample, text: text, children: _jsxs("div", { className: "grid gap-5", children: [_jsx(DetailList, { items: [
35
- { label: words.status, value: _jsx(LeadStatusBadge, { lead: lead }) },
146
+ return (_jsx(CrmCard, { title: lead.title, sample: sample, text: text, children: _jsxs("div", { className: "grid gap-5", children: [editable && (_jsx(LeadFields, { lead: lead, names: names, companies: companies, people: people, team: team, onChange: onChange, saving: converting, contactDetails: contactDetails, text: text })), _jsx(DetailList, { items: [
147
+ ...(editable ? [] : [{ label: words.status, value: _jsx(LeadStatusBadge, { lead: lead }) }]),
36
148
  // A lead has no close time of its own: it was last changed when it closed.
37
149
  ...(!open ? [{ label: words.closed, value: formatDate(lead.updatedTimestamp) }] : []),
38
150
  ...(lead.closedReason ? [{ label: words.unqualifiedReason, value: lead.closedReason }] : []),
39
- { label: words.contact, value: personNameOf(names, lead.contactIdentity?.urn) ?? '-' },
40
- { label: words.company, value: leadCompany(lead, names) || '-' },
41
- { label: words.source, value: SOURCE_LABELS[lead.source] },
42
- { label: words.value, value: formatMaybeMoney(lead.targetValue) },
43
- { label: words.assignee, value: personNameOf(names, lead.assignee?.urn) ?? '-' },
151
+ ...(editable
152
+ ? []
153
+ : [
154
+ { label: words.contact, value: personNameOf(names, lead.contactIdentity?.urn) ?? '-' },
155
+ { label: words.company, value: leadCompany(lead, names) || '-' },
156
+ { label: words.source, value: SOURCE_LABELS[lead.source] },
157
+ { label: words.value, value: formatMaybeMoney(lead.targetValue) },
158
+ { label: words.assignee, value: personNameOf(names, lead.assignee?.urn) ?? '-' },
159
+ ]),
44
160
  { label: words.created, value: formatDate(lead.createdTimestamp) },
45
161
  ] }), open && onConvert && (_jsxs("form", { onSubmit: submit, className: "grid gap-3", "aria-labelledby": `${id}-title`, children: [_jsxs("div", { className: "grid gap-1", children: [_jsx("h3", { id: `${id}-title`, className: "text-sm font-semibold", children: words.convert }), _jsx("p", { className: "text-muted-foreground text-sm", children: words.convertSummary })] }), !lead.contactCompany && (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `${id}-company`, children: words.companyName }), _jsx(Input, { id: `${id}-company`, value: companyName, onChange: (event) => setCompanyName(event.target.value), "aria-describedby": `${id}-company-hint` }), _jsx("p", { id: `${id}-company-hint`, className: "text-muted-foreground text-xs", children: words.companyNameHint })] })), _jsx("div", { children: _jsx(Button, { type: "submit", size: "sm", disabled: converting ?? false, children: converting ? words.converting : words.convert }) })] })), open && onSetOutcome && !unqualifying && (_jsx("div", { children: _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => setUnqualifying(true), children: words.markUnqualified }) })), open && onSetOutcome && unqualifying && (_jsxs("form", { className: "grid gap-2", onSubmit: (event) => {
46
162
  event.preventDefault();
@@ -74,28 +190,69 @@ export function OutcomeControl({ deal, onSetOutcome, disabled, text, }) {
74
190
  onSetOutcome(deal, 'LOST', reason);
75
191
  }, children: [_jsx(Label, { htmlFor: `${id}-reason`, children: words.lostReason }), _jsx(Input, { id: `${id}-reason`, value: reason, onChange: (event) => setReason(event.target.value) }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "submit", size: "sm", children: words.markLost }), _jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => setLosing(false), children: words.cancel })] })] }))] }));
76
192
  }
77
- /** A deal's details, with its stage picker and its outcome (open, won or lost). */
78
- export function DealDetail({ deal, pipeline, names, onMove, onSetOutcome, saving, sample, text, }) {
193
+ /**
194
+ * A deal's fields, each saved as it changes: title, workflow and stage, companies and contacts (found by searching, each
195
+ * contact with their email and telephone), value, probability, expected close and assignee.
196
+ */
197
+ function DealFields({ deal, pipelines, names, companies, people, team, onChange, onMove, saving, contactDetails, text, }) {
198
+ const words = withText(text);
199
+ const id = useId();
200
+ const [error, setError] = useState();
201
+ const save = async (changes) => {
202
+ setError(undefined);
203
+ try {
204
+ await onChange(changes);
205
+ }
206
+ catch (failure) {
207
+ setError(`${words.saveFailed} ${failure instanceof Error ? failure.message : ''}`.trim());
208
+ }
209
+ };
210
+ return (_jsxs("div", { className: "grid gap-3", children: [_jsx(Field, { id: `${id}-title`, label: words.title, children: _jsx(CommitInput, { id: `${id}-title`, value: deal.title, onCommit: (title) => title && void save({ title }) }) }), _jsx(PipelineStageFields, { id: id, pipelines: pipelines, stage: deal.workflowStage?.urn ?? '', onStage: (stage) => (onMove ? onMove(deal, stage) : void save({ workflowStage: { urn: stage.urn } })), disabled: saving, text: text }), _jsx(Field, { id: `${id}-companies`, label: words.companies, children: _jsx(ChoiceCombobox, { id: `${id}-companies`, value: deal.contactCompanies.map((company) => company.urn), onChange: (urns) => void save({ contactCompanies: urns.map((urn) => ({ urn })) }), choices: companies, named: (urn) => companyNameOf(names, urn), placeholder: words.searchCompanies, text: text }) }), _jsx(Field, { id: `${id}-contacts`, label: words.contacts, children: _jsx(ChoiceCombobox, { id: `${id}-contacts`, value: deal.contactIdentities.map((contact) => contact.urn), onChange: (urns) => void save({ contactIdentities: urns.map((urn) => ({ urn })) }), choices: people, named: (urn) => personNameOf(names, urn), placeholder: words.searchContacts, text: text }) }), contactDetails &&
211
+ deal.contactIdentities.map((contact, index) => (_jsx(ContactDetailsFields, { id: `${id}-contact-${index}`, contact: contact.urn,
212
+ // Each contact's fields are named for them when there are several.
213
+ name: deal.contactIdentities.length > 1 ? (personNameOf(names, contact.urn) ?? words.unnamed) : undefined, access: contactDetails, text: text }, contact.urn))), _jsx(Field, { id: `${id}-value`, label: words.value, children: _jsx(CommitMoney, { id: `${id}-value`, value: deal.targetValue, onCommit: (targetValue) => void save({ targetValue }), onInvalid: () => setError(words.invalidAmount), text: text }) }), _jsx(Field, { id: `${id}-probability`, label: `${words.probability} (%)`, children: _jsx(CommitInput, { id: `${id}-probability`, inputMode: "decimal", value: deal.probability === null || deal.probability === undefined ? '' : String(deal.probability), onCommit: (typed) => {
214
+ const chance = typed ? Number(typed) : null;
215
+ if (chance !== null && !(chance >= 0 && chance <= 100))
216
+ return setError(words.invalidProbability);
217
+ void save({ probability: chance });
218
+ } }) }), _jsx(Field, { id: `${id}-close`, label: words.expectedClose, children: _jsx(Input, { id: `${id}-close`, type: "date", value: deal.targetCloseTimestamp?.slice(0, 10) ?? '', onChange: (event) => void save({ targetCloseTimestamp: event.target.value ? `${event.target.value}T00:00:00` : null }) }) }), _jsx(Field, { id: `${id}-assignee`, label: words.assignee, children: _jsx(ChoiceSelect, { id: `${id}-assignee`, value: deal.assignee?.urn ?? '', onChange: (urn) => void save({ assignee: urn ? { urn } : null }), choices: team, none: words.unassigned, named: (urn) => personNameOf(names, urn), text: text }) }), _jsx("p", { "aria-live": "polite", className: "text-muted-foreground text-xs", children: saving ? words.saving : '' }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error }))] }));
219
+ }
220
+ /**
221
+ * A deal's details: with `onChange`, its fields can be edited, saved as they change; its outcome is set with
222
+ * `onSetOutcome`. Without them, read only.
223
+ */
224
+ export function DealDetail({ deal, pipelines, names, companies = [], people = [], team = [], onChange, onMove, onSetOutcome, saving, contactDetails, sample, text, }) {
79
225
  const words = withText(text);
80
- const stage = stageOf(deal, pipeline) ?? orderedStages(pipeline)[0];
226
+ const pipeline = pipelineOf(deal, pipelines) ?? pipelines[0];
227
+ const stage = pipeline && (stageOf(deal, pipeline) ?? orderedStages(pipeline)[0]);
81
228
  const outcome = dealOutcome(deal);
82
229
  const probability = dealProbability(deal);
230
+ const outcomeItem = {
231
+ label: words.outcome,
232
+ value: onSetOutcome ? (_jsx(OutcomeControl, { deal: deal, onSetOutcome: onSetOutcome, disabled: saving, text: text }, deal.urn)) : (_jsx(OutcomeBadge, { outcome: outcome, label: words[OUTCOME_LABELS[outcome]] })),
233
+ };
234
+ if (onChange)
235
+ return (_jsx(CrmCard, { title: deal.title, sample: sample, text: text, children: _jsxs("div", { className: "grid gap-5", children: [_jsx(DealFields, { deal: deal, pipelines: pipelines, names: names, companies: companies, people: people, team: team, onChange: onChange, onMove: onMove, saving: saving, contactDetails: contactDetails, text: text }), _jsx(DetailList, { items: [
236
+ outcomeItem,
237
+ ...(deal.closeTimestamp ? [{ label: words.closed, value: formatDate(deal.closeTimestamp) }] : []),
238
+ ...(deal.lostReason ? [{ label: words.lostReason, value: deal.lostReason }] : []),
239
+ { label: words.created, value: formatDate(deal.createdTimestamp) },
240
+ ] })] }) }));
83
241
  return (_jsx(CrmCard, { title: deal.title, sample: sample, text: text, children: _jsx(DetailList, { items: [
84
242
  {
85
243
  label: words.stage,
86
- value: onMove ? (_jsx(StageSelect, { deal: deal, pipeline: pipeline, onMove: onMove, disabled: saving, text: text })) : ((stage?.name ?? '-')),
87
- },
88
- {
89
- label: words.outcome,
90
- value: onSetOutcome ? (_jsx(OutcomeControl, { deal: deal, onSetOutcome: onSetOutcome, disabled: saving, text: text }, deal.urn)) : (_jsx(OutcomeBadge, { outcome: outcome, label: words[OUTCOME_LABELS[outcome]] })),
244
+ value: onMove && pipeline ? (_jsx(StageSelect, { deal: deal, pipeline: pipeline, onMove: onMove, disabled: saving, text: text })) : ((stage?.name ?? '-')),
91
245
  },
246
+ outcomeItem,
92
247
  {
93
248
  label: words.company,
94
- value: deal.contactCompanies.map((company) => companyNameOf(names, company.urn) ?? words.unnamed).join(', ') || '-',
249
+ value: deal.contactCompanies.map((company) => companyNameOf(names, company.urn) ?? words.unnamed).join(', ') ||
250
+ '-',
95
251
  },
96
252
  {
97
253
  label: words.contact,
98
- value: deal.contactIdentities.map((contact) => personNameOf(names, contact.urn) ?? words.unnamed).join(', ') || '-',
254
+ value: deal.contactIdentities.map((contact) => personNameOf(names, contact.urn) ?? words.unnamed).join(', ') ||
255
+ '-',
99
256
  },
100
257
  { label: words.value, value: formatMaybeMoney(deal.targetValue) },
101
258
  { label: words.probability, value: probability === undefined ? '-' : `${probability}%` },