@baack-software/baack-ts-crm 0.0.0-stage → 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 (234) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +74 -2
  3. package/dist/account.d.ts +36 -0
  4. package/dist/account.d.ts.map +1 -0
  5. package/dist/account.js +48 -0
  6. package/dist/account.js.map +1 -0
  7. package/dist/backend.d.ts +104 -0
  8. package/dist/backend.d.ts.map +1 -0
  9. package/dist/backend.js +328 -0
  10. package/dist/backend.js.map +1 -0
  11. package/dist/crm-client.d.ts +164 -0
  12. package/dist/crm-client.d.ts.map +1 -0
  13. package/dist/crm-client.js +252 -0
  14. package/dist/crm-client.js.map +1 -0
  15. package/dist/deal-order.d.ts +42 -0
  16. package/dist/deal-order.d.ts.map +1 -0
  17. package/dist/deal-order.js +80 -0
  18. package/dist/deal-order.js.map +1 -0
  19. package/dist/errors.d.ts +21 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +33 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +14 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +14 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/invoices.d.ts +53 -0
  28. package/dist/invoices.d.ts.map +1 -0
  29. package/dist/invoices.js +155 -0
  30. package/dist/invoices.js.map +1 -0
  31. package/dist/leads.d.ts +29 -0
  32. package/dist/leads.d.ts.map +1 -0
  33. package/dist/leads.js +56 -0
  34. package/dist/leads.js.map +1 -0
  35. package/dist/mock/index.d.ts +43 -0
  36. package/dist/mock/index.d.ts.map +1 -0
  37. package/dist/mock/index.js +303 -0
  38. package/dist/mock/index.js.map +1 -0
  39. package/dist/money.d.ts +29 -0
  40. package/dist/money.d.ts.map +1 -0
  41. package/dist/money.js +82 -0
  42. package/dist/money.js.map +1 -0
  43. package/dist/period.d.ts +30 -0
  44. package/dist/period.d.ts.map +1 -0
  45. package/dist/period.js +49 -0
  46. package/dist/period.js.map +1 -0
  47. package/dist/pipeline.d.ts +36 -0
  48. package/dist/pipeline.d.ts.map +1 -0
  49. package/dist/pipeline.js +58 -0
  50. package/dist/pipeline.js.map +1 -0
  51. package/dist/react/Charts.d.ts +19 -0
  52. package/dist/react/Charts.d.ts.map +1 -0
  53. package/dist/react/Charts.js +38 -0
  54. package/dist/react/Charts.js.map +1 -0
  55. package/dist/react/ChoiceCombobox.d.ts +36 -0
  56. package/dist/react/ChoiceCombobox.d.ts.map +1 -0
  57. package/dist/react/ChoiceCombobox.js +105 -0
  58. package/dist/react/ChoiceCombobox.js.map +1 -0
  59. package/dist/react/CompanyAccountView.d.ts +21 -0
  60. package/dist/react/CompanyAccountView.d.ts.map +1 -0
  61. package/dist/react/CompanyAccountView.js +27 -0
  62. package/dist/react/CompanyAccountView.js.map +1 -0
  63. package/dist/react/DashboardCards.d.ts +32 -0
  64. package/dist/react/DashboardCards.d.ts.map +1 -0
  65. package/dist/react/DashboardCards.js +38 -0
  66. package/dist/react/DashboardCards.js.map +1 -0
  67. package/dist/react/DealsBoard.d.ts +49 -0
  68. package/dist/react/DealsBoard.d.ts.map +1 -0
  69. package/dist/react/DealsBoard.js +82 -0
  70. package/dist/react/DealsBoard.js.map +1 -0
  71. package/dist/react/Details.d.ts +85 -0
  72. package/dist/react/Details.d.ts.map +1 -0
  73. package/dist/react/Details.js +268 -0
  74. package/dist/react/Details.js.map +1 -0
  75. package/dist/react/Forms.d.ts +190 -0
  76. package/dist/react/Forms.d.ts.map +1 -0
  77. package/dist/react/Forms.js +494 -0
  78. package/dist/react/Forms.js.map +1 -0
  79. package/dist/react/LeadsTable.d.ts +22 -0
  80. package/dist/react/LeadsTable.d.ts.map +1 -0
  81. package/dist/react/LeadsTable.js +79 -0
  82. package/dist/react/LeadsTable.js.map +1 -0
  83. package/dist/react/Sales.d.ts +68 -0
  84. package/dist/react/Sales.d.ts.map +1 -0
  85. package/dist/react/Sales.js +270 -0
  86. package/dist/react/Sales.js.map +1 -0
  87. package/dist/react/SidePanel.d.ts +31 -0
  88. package/dist/react/SidePanel.d.ts.map +1 -0
  89. package/dist/react/SidePanel.js +49 -0
  90. package/dist/react/SidePanel.js.map +1 -0
  91. package/dist/react/format.d.ts +28 -0
  92. package/dist/react/format.d.ts.map +1 -0
  93. package/dist/react/format.js +30 -0
  94. package/dist/react/format.js.map +1 -0
  95. package/dist/react/index.d.ts +15 -0
  96. package/dist/react/index.d.ts.map +1 -0
  97. package/dist/react/index.js +15 -0
  98. package/dist/react/index.js.map +1 -0
  99. package/dist/react/parts.d.ts +55 -0
  100. package/dist/react/parts.d.ts.map +1 -0
  101. package/dist/react/parts.js +82 -0
  102. package/dist/react/parts.js.map +1 -0
  103. package/dist/react/pipeline-choice.d.ts +19 -0
  104. package/dist/react/pipeline-choice.d.ts.map +1 -0
  105. package/dist/react/pipeline-choice.js +39 -0
  106. package/dist/react/pipeline-choice.js.map +1 -0
  107. package/dist/react/text.d.ts +232 -0
  108. package/dist/react/text.d.ts.map +1 -0
  109. package/dist/react/text.js +229 -0
  110. package/dist/react/text.js.map +1 -0
  111. package/dist/react/ui/alert.d.ts +11 -0
  112. package/dist/react/ui/alert.d.ts.map +1 -0
  113. package/dist/react/ui/alert.js +29 -0
  114. package/dist/react/ui/alert.js.map +1 -0
  115. package/dist/react/ui/badge.d.ts +10 -0
  116. package/dist/react/ui/badge.d.ts.map +1 -0
  117. package/dist/react/ui/badge.js +26 -0
  118. package/dist/react/ui/badge.js.map +1 -0
  119. package/dist/react/ui/button.d.ts +11 -0
  120. package/dist/react/ui/button.d.ts.map +1 -0
  121. package/dist/react/ui/button.js +37 -0
  122. package/dist/react/ui/button.js.map +1 -0
  123. package/dist/react/ui/card.d.ts +12 -0
  124. package/dist/react/ui/card.d.ts.map +1 -0
  125. package/dist/react/ui/card.js +26 -0
  126. package/dist/react/ui/card.js.map +1 -0
  127. package/dist/react/ui/chart.d.ts +45 -0
  128. package/dist/react/ui/chart.d.ts.map +1 -0
  129. package/dist/react/ui/chart.js +116 -0
  130. package/dist/react/ui/chart.js.map +1 -0
  131. package/dist/react/ui/input.d.ts +4 -0
  132. package/dist/react/ui/input.d.ts.map +1 -0
  133. package/dist/react/ui/input.js +8 -0
  134. package/dist/react/ui/input.js.map +1 -0
  135. package/dist/react/ui/label.d.ts +5 -0
  136. package/dist/react/ui/label.d.ts.map +1 -0
  137. package/dist/react/ui/label.js +10 -0
  138. package/dist/react/ui/label.js.map +1 -0
  139. package/dist/react/ui/progress.d.ts +5 -0
  140. package/dist/react/ui/progress.d.ts.map +1 -0
  141. package/dist/react/ui/progress.js +10 -0
  142. package/dist/react/ui/progress.js.map +1 -0
  143. package/dist/react/ui/select.d.ts +16 -0
  144. package/dist/react/ui/select.d.ts.map +1 -0
  145. package/dist/react/ui/select.js +37 -0
  146. package/dist/react/ui/select.js.map +1 -0
  147. package/dist/react/ui/separator.d.ts +5 -0
  148. package/dist/react/ui/separator.d.ts.map +1 -0
  149. package/dist/react/ui/separator.js +10 -0
  150. package/dist/react/ui/separator.js.map +1 -0
  151. package/dist/react/ui/sheet.d.ts +15 -0
  152. package/dist/react/ui/sheet.d.ts.map +1 -0
  153. package/dist/react/ui/sheet.js +38 -0
  154. package/dist/react/ui/sheet.js.map +1 -0
  155. package/dist/react/ui/skeleton.d.ts +3 -0
  156. package/dist/react/ui/skeleton.d.ts.map +1 -0
  157. package/dist/react/ui/skeleton.js +7 -0
  158. package/dist/react/ui/skeleton.js.map +1 -0
  159. package/dist/react/ui/table.d.ts +11 -0
  160. package/dist/react/ui/table.d.ts.map +1 -0
  161. package/dist/react/ui/table.js +29 -0
  162. package/dist/react/ui/table.js.map +1 -0
  163. package/dist/react/ui/tabs.d.ts +12 -0
  164. package/dist/react/ui/tabs.d.ts.map +1 -0
  165. package/dist/react/ui/tabs.js +31 -0
  166. package/dist/react/ui/tabs.js.map +1 -0
  167. package/dist/react/views.d.ts +82 -0
  168. package/dist/react/views.d.ts.map +1 -0
  169. package/dist/react/views.js +241 -0
  170. package/dist/react/views.js.map +1 -0
  171. package/dist/sales.d.ts +82 -0
  172. package/dist/sales.d.ts.map +1 -0
  173. package/dist/sales.js +87 -0
  174. package/dist/sales.js.map +1 -0
  175. package/dist/store.d.ts +159 -0
  176. package/dist/store.d.ts.map +1 -0
  177. package/dist/store.js +305 -0
  178. package/dist/store.js.map +1 -0
  179. package/dist/target.d.ts +22 -0
  180. package/dist/target.d.ts.map +1 -0
  181. package/dist/target.js +40 -0
  182. package/dist/target.js.map +1 -0
  183. package/dist/types.d.ts +204 -0
  184. package/dist/types.d.ts.map +1 -0
  185. package/dist/types.js +2 -0
  186. package/dist/types.js.map +1 -0
  187. package/package.json +100 -4
  188. package/src/account.ts +79 -0
  189. package/src/backend.ts +501 -0
  190. package/src/crm-client.ts +393 -0
  191. package/src/deal-order.ts +116 -0
  192. package/src/errors.ts +34 -0
  193. package/src/index.ts +13 -0
  194. package/src/invoices.ts +177 -0
  195. package/src/leads.ts +78 -0
  196. package/src/mock/index.ts +398 -0
  197. package/src/money.ts +104 -0
  198. package/src/period.ts +71 -0
  199. package/src/pipeline.ts +82 -0
  200. package/src/react/Charts.tsx +143 -0
  201. package/src/react/ChoiceCombobox.tsx +227 -0
  202. package/src/react/CompanyAccountView.tsx +198 -0
  203. package/src/react/DashboardCards.tsx +171 -0
  204. package/src/react/DealsBoard.tsx +344 -0
  205. package/src/react/Details.tsx +870 -0
  206. package/src/react/Forms.tsx +1486 -0
  207. package/src/react/LeadsTable.tsx +234 -0
  208. package/src/react/Sales.tsx +827 -0
  209. package/src/react/SidePanel.tsx +104 -0
  210. package/src/react/format.ts +53 -0
  211. package/src/react/index.ts +14 -0
  212. package/src/react/parts.tsx +183 -0
  213. package/src/react/pipeline-choice.ts +54 -0
  214. package/src/react/text.ts +232 -0
  215. package/src/react/ui/README.md +6 -0
  216. package/src/react/ui/alert.tsx +75 -0
  217. package/src/react/ui/badge.tsx +48 -0
  218. package/src/react/ui/button.tsx +66 -0
  219. package/src/react/ui/card.tsx +102 -0
  220. package/src/react/ui/chart.tsx +304 -0
  221. package/src/react/ui/input.tsx +18 -0
  222. package/src/react/ui/label.tsx +23 -0
  223. package/src/react/ui/progress.tsx +30 -0
  224. package/src/react/ui/select.tsx +189 -0
  225. package/src/react/ui/separator.tsx +27 -0
  226. package/src/react/ui/sheet.tsx +145 -0
  227. package/src/react/ui/skeleton.tsx +13 -0
  228. package/src/react/ui/table.tsx +113 -0
  229. package/src/react/ui/tabs.tsx +89 -0
  230. package/src/react/views.tsx +633 -0
  231. package/src/sales.ts +167 -0
  232. package/src/store.ts +528 -0
  233. package/src/target.ts +54 -0
  234. package/src/types.ts +230 -0
@@ -0,0 +1,344 @@
1
+ import { cn } from 'cn';
2
+ import { Search, X } from 'lucide-react';
3
+ import { useId } from 'react';
4
+ import { DEAL_ORDERS, sortDeals, type DealFilter, type DealOrder } from '../deal-order.ts';
5
+ import { addMoney, type MoneyTotals } from '../money.ts';
6
+ import { dealCompany, dealOutcome, orderedStages } from '../pipeline.ts';
7
+ import type { Deal, DealOutcome, Pipeline, PipelineStage } from '../types.ts';
8
+ import type { CrmChoice } from './Forms.tsx';
9
+ import { companyNameOf, formatDate, formatMaybeMoney, formatTotals, type CrmNames } from './format.ts';
10
+ import { OutcomeBadge, SampleDataBadge } from './parts.tsx';
11
+ import { recordItemId } from './SidePanel.tsx';
12
+ import { withText, type CrmText } from './text.ts';
13
+ import { Button } from './ui/button.tsx';
14
+ import { Card, CardContent, CardHeader, CardTitle } from './ui/card.tsx';
15
+ import { Input } from './ui/input.tsx';
16
+ import { Label } from './ui/label.tsx';
17
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select.tsx';
18
+
19
+ /** Picks the stage a deal is at; moving it is one choice, so it works from the keyboard as well as by pointer. */
20
+ export function StageSelect({
21
+ deal,
22
+ pipeline,
23
+ onMove,
24
+ disabled,
25
+ text,
26
+ className,
27
+ }: {
28
+ deal: Deal;
29
+ pipeline: Pipeline;
30
+ onMove: (deal: Deal, stage: PipelineStage) => void;
31
+ disabled?: boolean | undefined;
32
+ text?: Partial<CrmText> | undefined;
33
+ className?: string | undefined;
34
+ }) {
35
+ const words = withText(text);
36
+ const stages = orderedStages(pipeline);
37
+ return (
38
+ <Select
39
+ value={deal.workflowStage?.urn ?? ''}
40
+ disabled={disabled ?? false}
41
+ onValueChange={(urn) => {
42
+ const stage = stages.find((candidate) => candidate.urn === urn);
43
+ if (stage) onMove(deal, stage);
44
+ }}
45
+ >
46
+ <SelectTrigger size="sm" aria-label={`${words.moveTo}: ${deal.title}`} className={className}>
47
+ <SelectValue />
48
+ </SelectTrigger>
49
+ <SelectContent>
50
+ {stages.map((stage) => (
51
+ <SelectItem key={stage.urn} value={stage.urn}>
52
+ {stage.name}
53
+ </SelectItem>
54
+ ))}
55
+ </SelectContent>
56
+ </Select>
57
+ );
58
+ }
59
+
60
+ const ANY = '__any__';
61
+ const NONE = '__none__';
62
+
63
+ const ORDER_WORDS: Record<DealOrder, keyof CrmText> = {
64
+ weighted: 'orderWeighted',
65
+ size: 'orderSize',
66
+ urgency: 'orderUrgency',
67
+ };
68
+
69
+ const OUTCOMES: readonly { outcome: DealOutcome; label: keyof CrmText }[] = [
70
+ { outcome: 'OPEN', label: 'outcomeOpen' },
71
+ { outcome: 'WON', label: 'outcomeWon' },
72
+ { outcome: 'LOST', label: 'outcomeLost' },
73
+ ];
74
+
75
+ /** A labelled select of a filter or order, with "any" as `ANY` and "none" as `NONE`. */
76
+ function ToolbarSelect({
77
+ label,
78
+ value,
79
+ onChange,
80
+ options,
81
+ className,
82
+ }: {
83
+ label: string;
84
+ value: string;
85
+ onChange: (value: string) => void;
86
+ options: readonly { value: string; label: string }[];
87
+ className?: string;
88
+ }) {
89
+ const id = useId();
90
+ return (
91
+ <div className="grid gap-1.5">
92
+ <Label htmlFor={id}>{label}</Label>
93
+ <Select value={value} onValueChange={onChange}>
94
+ <SelectTrigger id={id} className={className}>
95
+ <SelectValue />
96
+ </SelectTrigger>
97
+ <SelectContent>
98
+ {options.map((option) => (
99
+ <SelectItem key={option.value} value={option.value}>
100
+ {option.label}
101
+ </SelectItem>
102
+ ))}
103
+ </SelectContent>
104
+ </Select>
105
+ </div>
106
+ );
107
+ }
108
+
109
+ /**
110
+ * Filters for the deals board, as the tasks view has (words, outcome, assignee and company), and the order of each
111
+ * column's deals: weighted, by size or by urgency (see `sortDeals`). Controlled; apply them with `filterDeals`.
112
+ */
113
+ export function DealFilters({
114
+ value,
115
+ onChange,
116
+ order,
117
+ onOrder,
118
+ team = [],
119
+ companies = [],
120
+ shown,
121
+ text,
122
+ }: {
123
+ value: DealFilter;
124
+ onChange: (filter: DealFilter) => void;
125
+ order: DealOrder;
126
+ onOrder: (order: DealOrder) => void;
127
+ team?: readonly CrmChoice[] | undefined;
128
+ companies?: readonly CrmChoice[] | undefined;
129
+ /** How many deals the filters leave, announced as they change. */
130
+ shown?: number | undefined;
131
+ text?: Partial<CrmText> | undefined;
132
+ }) {
133
+ const words = withText(text);
134
+ const set = <K extends keyof DealFilter>(key: K, next: DealFilter[K]) => {
135
+ const { [key]: _removed, ...rest } = value;
136
+ onChange(next === undefined ? rest : { ...rest, [key]: next });
137
+ };
138
+ const pick = (selected: string) => (selected === ANY ? undefined : selected === NONE ? null : selected);
139
+ const current = (selected: string | null | undefined) =>
140
+ selected === undefined ? ANY : selected === null ? NONE : selected;
141
+ const active = Object.values(value).some((field) => field !== undefined && field !== '');
142
+ return (
143
+ <div role="search" aria-label={words.filterDeals} className="flex flex-wrap items-end gap-3">
144
+ <div className="relative min-w-48 flex-1">
145
+ <Search
146
+ aria-hidden="true"
147
+ className="text-muted-foreground absolute top-1/2 left-2.5 size-4 -translate-y-1/2"
148
+ />
149
+ <Input
150
+ type="search"
151
+ aria-label={words.filterDeals}
152
+ placeholder={words.filterDeals}
153
+ value={value.text ?? ''}
154
+ onChange={(event) => set('text', event.target.value || undefined)}
155
+ className="pl-8"
156
+ />
157
+ </div>
158
+ <ToolbarSelect
159
+ label={words.outcome}
160
+ value={value.outcome ?? ANY}
161
+ onChange={(selected) => set('outcome', selected === ANY ? undefined : (selected as DealOutcome))}
162
+ options={[
163
+ { value: ANY, label: words.allOutcomes },
164
+ ...OUTCOMES.map(({ outcome, label }) => ({ value: outcome, label: words[label] })),
165
+ ]}
166
+ className="w-36"
167
+ />
168
+ <ToolbarSelect
169
+ label={words.assignee}
170
+ value={current(value.assignee)}
171
+ onChange={(selected) => set('assignee', pick(selected))}
172
+ options={[
173
+ { value: ANY, label: words.anyone },
174
+ { value: NONE, label: words.unassigned },
175
+ ...team.map((person) => ({ value: person.urn, label: person.name })),
176
+ ]}
177
+ className="w-44"
178
+ />
179
+ {companies.length > 0 && (
180
+ <ToolbarSelect
181
+ label={words.company}
182
+ value={current(value.company)}
183
+ onChange={(selected) => set('company', pick(selected))}
184
+ options={[
185
+ { value: ANY, label: words.allCompanies },
186
+ { value: NONE, label: words.noCompany },
187
+ ...companies.map((company) => ({ value: company.urn, label: company.name })),
188
+ ]}
189
+ className="w-44"
190
+ />
191
+ )}
192
+ <ToolbarSelect
193
+ label={words.sortBy}
194
+ value={order}
195
+ onChange={(selected) => onOrder(selected as DealOrder)}
196
+ options={DEAL_ORDERS.map((option) => ({ value: option, label: words[ORDER_WORDS[option]] }))}
197
+ className="w-36"
198
+ />
199
+ {active && (
200
+ <Button variant="ghost" size="sm" onClick={() => onChange({})}>
201
+ <X aria-hidden="true" />
202
+ {words.clearFilters}
203
+ </Button>
204
+ )}
205
+ {shown !== undefined && (
206
+ <p aria-live="polite" className="sr-only">
207
+ {shown} {words.dealsShown}
208
+ </p>
209
+ )}
210
+ </div>
211
+ );
212
+ }
213
+
214
+ /**
215
+ * Deals as a board, one column per pipeline stage with its count and value, each column in `order` (weighted to start
216
+ * with). Each deal can be opened, and moved with its stage picker.
217
+ */
218
+ export function DealsBoard({
219
+ deals,
220
+ pipeline,
221
+ names,
222
+ onOpen,
223
+ onMove,
224
+ selected,
225
+ saving,
226
+ sample,
227
+ order = 'weighted',
228
+ text,
229
+ }: {
230
+ deals: readonly Deal[];
231
+ pipeline: Pipeline;
232
+ /** How each column's deals are ordered. */
233
+ order?: DealOrder | undefined;
234
+ names?: CrmNames | undefined;
235
+ onOpen?: ((deal: Deal) => void) | undefined;
236
+ onMove?: ((deal: Deal, stage: PipelineStage) => void) | undefined;
237
+ /** The open deal, highlighted. */
238
+ selected?: string | undefined;
239
+ /** URNs of deals being saved. */
240
+ saving?: ReadonlySet<string> | undefined;
241
+ sample?: boolean | undefined;
242
+ text?: Partial<CrmText> | undefined;
243
+ }) {
244
+ const words = withText(text);
245
+ return (
246
+ <section aria-label={`${pipeline.name}: ${words.deals}`} className="grid gap-3">
247
+ {sample && (
248
+ <div>
249
+ <SampleDataBadge text={text} />
250
+ </div>
251
+ )}
252
+ {/* Focusable, so the columns past the edge can be scrolled to from the keyboard. */}
253
+ <div tabIndex={0} aria-label={pipeline.name} className="flex gap-3 overflow-x-auto rounded-xl pb-2">
254
+ {orderedStages(pipeline).map((stage) => {
255
+ const here = sortDeals(
256
+ deals.filter((deal) => deal.workflowStage?.urn === stage.urn),
257
+ order,
258
+ );
259
+ const value = here.reduce<MoneyTotals>((totals, deal) => addMoney(totals, deal.targetValue), {});
260
+ return (
261
+ <section
262
+ key={stage.urn}
263
+ aria-labelledby={`stage-${stage.urn}`}
264
+ className="bg-muted/50 flex w-64 shrink-0 flex-col gap-2 rounded-xl p-2"
265
+ >
266
+ <header className="px-1 pt-1">
267
+ <h3
268
+ id={`stage-${stage.urn}`}
269
+ className="flex items-baseline justify-between gap-2 text-sm font-semibold"
270
+ >
271
+ {stage.name}
272
+ <span className="text-muted-foreground font-normal tabular-nums">{here.length}</span>
273
+ </h3>
274
+ <p className="text-muted-foreground text-xs tabular-nums">{formatTotals(value)}</p>
275
+ </header>
276
+ {here.length === 0 ? (
277
+ <p className="text-muted-foreground px-1 py-4 text-center text-xs">{words.noDeals}</p>
278
+ ) : (
279
+ <ul className="grid gap-2">
280
+ {here.map((deal) => (
281
+ <li key={deal.urn}>
282
+ <Card
283
+ size="sm"
284
+ className={cn(
285
+ saving?.has(deal.urn) && 'opacity-60',
286
+ selected === deal.urn && 'ring-primary ring-2',
287
+ )}
288
+ >
289
+ <CardHeader>
290
+ <CardTitle className="text-sm">
291
+ {onOpen ? (
292
+ <button
293
+ type="button"
294
+ id={recordItemId(deal.urn)}
295
+ aria-current={selected === deal.urn ? 'true' : undefined}
296
+ className="text-left hover:underline"
297
+ onClick={() => onOpen(deal)}
298
+ >
299
+ {deal.title}
300
+ </button>
301
+ ) : (
302
+ deal.title
303
+ )}
304
+ </CardTitle>
305
+ </CardHeader>
306
+ <CardContent className="grid gap-2 text-xs">
307
+ <p className="text-muted-foreground flex items-center justify-between gap-2">
308
+ <span>{companyNameOf(names, dealCompany(deal)?.urn) ?? words.unnamed}</span>
309
+ {dealOutcome(deal) !== 'OPEN' && (
310
+ <OutcomeBadge
311
+ outcome={dealOutcome(deal)}
312
+ label={dealOutcome(deal) === 'WON' ? words.outcomeWon : words.outcomeLost}
313
+ />
314
+ )}
315
+ </p>
316
+ <p className="flex justify-between gap-2">
317
+ <span className="font-medium tabular-nums">{formatMaybeMoney(deal.targetValue)}</span>
318
+ <span className="text-muted-foreground">
319
+ {formatDate(deal.closeTimestamp ?? deal.targetCloseTimestamp)}
320
+ </span>
321
+ </p>
322
+ {onMove && (
323
+ <StageSelect
324
+ deal={deal}
325
+ pipeline={pipeline}
326
+ onMove={onMove}
327
+ disabled={saving?.has(deal.urn)}
328
+ text={text}
329
+ className="w-full"
330
+ />
331
+ )}
332
+ </CardContent>
333
+ </Card>
334
+ </li>
335
+ ))}
336
+ </ul>
337
+ )}
338
+ </section>
339
+ );
340
+ })}
341
+ </div>
342
+ </section>
343
+ );
344
+ }