@baack-software/baack-ts-crm 0.0.0-stage → 0.0.2
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/LICENSE +201 -0
- package/README.md +74 -2
- package/dist/account.d.ts +36 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/account.js +48 -0
- package/dist/account.js.map +1 -0
- package/dist/backend.d.ts +76 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +233 -0
- package/dist/backend.js.map +1 -0
- package/dist/crm-client.d.ts +122 -0
- package/dist/crm-client.d.ts.map +1 -0
- package/dist/crm-client.js +168 -0
- package/dist/crm-client.js.map +1 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +33 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.d.ts +46 -0
- package/dist/invoices.d.ts.map +1 -0
- package/dist/invoices.js +137 -0
- package/dist/invoices.js.map +1 -0
- package/dist/leads.d.ts +29 -0
- package/dist/leads.d.ts.map +1 -0
- package/dist/leads.js +56 -0
- package/dist/leads.js.map +1 -0
- package/dist/mock/index.d.ts +43 -0
- package/dist/mock/index.d.ts.map +1 -0
- package/dist/mock/index.js +303 -0
- package/dist/mock/index.js.map +1 -0
- package/dist/money.d.ts +29 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +82 -0
- package/dist/money.js.map +1 -0
- package/dist/period.d.ts +17 -0
- package/dist/period.d.ts.map +1 -0
- package/dist/period.js +23 -0
- package/dist/period.js.map +1 -0
- package/dist/pipeline.d.ts +30 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +40 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/react/Charts.d.ts +19 -0
- package/dist/react/Charts.d.ts.map +1 -0
- package/dist/react/Charts.js +38 -0
- package/dist/react/Charts.js.map +1 -0
- package/dist/react/CompanyAccountView.d.ts +21 -0
- package/dist/react/CompanyAccountView.d.ts.map +1 -0
- package/dist/react/CompanyAccountView.js +27 -0
- package/dist/react/CompanyAccountView.js.map +1 -0
- package/dist/react/DashboardCards.d.ts +32 -0
- package/dist/react/DashboardCards.d.ts.map +1 -0
- package/dist/react/DashboardCards.js +38 -0
- package/dist/react/DashboardCards.js.map +1 -0
- package/dist/react/DealsBoard.d.ts +30 -0
- package/dist/react/DealsBoard.d.ts.map +1 -0
- package/dist/react/DealsBoard.js +33 -0
- package/dist/react/DealsBoard.js.map +1 -0
- package/dist/react/Details.d.ts +52 -0
- package/dist/react/Details.d.ts.map +1 -0
- package/dist/react/Details.js +111 -0
- package/dist/react/Details.js.map +1 -0
- package/dist/react/Forms.d.ts +59 -0
- package/dist/react/Forms.d.ts.map +1 -0
- package/dist/react/Forms.js +204 -0
- package/dist/react/Forms.js.map +1 -0
- package/dist/react/LeadsTable.d.ts +22 -0
- package/dist/react/LeadsTable.d.ts.map +1 -0
- package/dist/react/LeadsTable.js +79 -0
- package/dist/react/LeadsTable.js.map +1 -0
- package/dist/react/Sales.d.ts +49 -0
- package/dist/react/Sales.d.ts.map +1 -0
- package/dist/react/Sales.js +186 -0
- package/dist/react/Sales.js.map +1 -0
- package/dist/react/SidePanel.d.ts +21 -0
- package/dist/react/SidePanel.d.ts.map +1 -0
- package/dist/react/SidePanel.js +37 -0
- package/dist/react/SidePanel.js.map +1 -0
- package/dist/react/format.d.ts +28 -0
- package/dist/react/format.d.ts.map +1 -0
- package/dist/react/format.js +30 -0
- package/dist/react/format.js.map +1 -0
- package/dist/react/index.d.ts +14 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +14 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/parts.d.ts +45 -0
- package/dist/react/parts.d.ts.map +1 -0
- package/dist/react/parts.js +59 -0
- package/dist/react/parts.js.map +1 -0
- package/dist/react/text.d.ts +145 -0
- package/dist/react/text.d.ts.map +1 -0
- package/dist/react/text.js +142 -0
- package/dist/react/text.js.map +1 -0
- package/dist/react/ui/alert.d.ts +11 -0
- package/dist/react/ui/alert.d.ts.map +1 -0
- package/dist/react/ui/alert.js +29 -0
- package/dist/react/ui/alert.js.map +1 -0
- package/dist/react/ui/badge.d.ts +10 -0
- package/dist/react/ui/badge.d.ts.map +1 -0
- package/dist/react/ui/badge.js +26 -0
- package/dist/react/ui/badge.js.map +1 -0
- package/dist/react/ui/button.d.ts +11 -0
- package/dist/react/ui/button.d.ts.map +1 -0
- package/dist/react/ui/button.js +37 -0
- package/dist/react/ui/button.js.map +1 -0
- package/dist/react/ui/card.d.ts +12 -0
- package/dist/react/ui/card.d.ts.map +1 -0
- package/dist/react/ui/card.js +26 -0
- package/dist/react/ui/card.js.map +1 -0
- package/dist/react/ui/chart.d.ts +45 -0
- package/dist/react/ui/chart.d.ts.map +1 -0
- package/dist/react/ui/chart.js +116 -0
- package/dist/react/ui/chart.js.map +1 -0
- package/dist/react/ui/input.d.ts +4 -0
- package/dist/react/ui/input.d.ts.map +1 -0
- package/dist/react/ui/input.js +8 -0
- package/dist/react/ui/input.js.map +1 -0
- package/dist/react/ui/label.d.ts +5 -0
- package/dist/react/ui/label.d.ts.map +1 -0
- package/dist/react/ui/label.js +10 -0
- package/dist/react/ui/label.js.map +1 -0
- package/dist/react/ui/progress.d.ts +5 -0
- package/dist/react/ui/progress.d.ts.map +1 -0
- package/dist/react/ui/progress.js +10 -0
- package/dist/react/ui/progress.js.map +1 -0
- package/dist/react/ui/select.d.ts +16 -0
- package/dist/react/ui/select.d.ts.map +1 -0
- package/dist/react/ui/select.js +37 -0
- package/dist/react/ui/select.js.map +1 -0
- package/dist/react/ui/separator.d.ts +5 -0
- package/dist/react/ui/separator.d.ts.map +1 -0
- package/dist/react/ui/separator.js +10 -0
- package/dist/react/ui/separator.js.map +1 -0
- package/dist/react/ui/sheet.d.ts +15 -0
- package/dist/react/ui/sheet.d.ts.map +1 -0
- package/dist/react/ui/sheet.js +38 -0
- package/dist/react/ui/sheet.js.map +1 -0
- package/dist/react/ui/skeleton.d.ts +3 -0
- package/dist/react/ui/skeleton.d.ts.map +1 -0
- package/dist/react/ui/skeleton.js +7 -0
- package/dist/react/ui/skeleton.js.map +1 -0
- package/dist/react/ui/table.d.ts +11 -0
- package/dist/react/ui/table.d.ts.map +1 -0
- package/dist/react/ui/table.js +29 -0
- package/dist/react/ui/table.js.map +1 -0
- package/dist/react/ui/tabs.d.ts +12 -0
- package/dist/react/ui/tabs.d.ts.map +1 -0
- package/dist/react/ui/tabs.js +31 -0
- package/dist/react/ui/tabs.js.map +1 -0
- package/dist/react/views.d.ts +60 -0
- package/dist/react/views.d.ts.map +1 -0
- package/dist/react/views.js +172 -0
- package/dist/react/views.js.map +1 -0
- package/dist/sales.d.ts +57 -0
- package/dist/sales.d.ts.map +1 -0
- package/dist/sales.js +64 -0
- package/dist/sales.js.map +1 -0
- package/dist/store.d.ts +140 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +244 -0
- package/dist/store.js.map +1 -0
- package/dist/target.d.ts +21 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +36 -0
- package/dist/target.js.map +1 -0
- package/dist/types.d.ts +180 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +100 -4
- package/src/account.ts +79 -0
- package/src/backend.ts +371 -0
- package/src/crm-client.ts +250 -0
- package/src/errors.ts +34 -0
- package/src/index.ts +12 -0
- package/src/invoices.ts +157 -0
- package/src/leads.ts +78 -0
- package/src/mock/index.ts +398 -0
- package/src/money.ts +104 -0
- package/src/period.ts +32 -0
- package/src/pipeline.ts +61 -0
- package/src/react/Charts.tsx +143 -0
- package/src/react/CompanyAccountView.tsx +198 -0
- package/src/react/DashboardCards.tsx +171 -0
- package/src/react/DealsBoard.tsx +177 -0
- package/src/react/Details.tsx +293 -0
- package/src/react/Forms.tsx +619 -0
- package/src/react/LeadsTable.tsx +234 -0
- package/src/react/Sales.tsx +539 -0
- package/src/react/SidePanel.tsx +95 -0
- package/src/react/format.ts +53 -0
- package/src/react/index.ts +13 -0
- package/src/react/parts.tsx +131 -0
- package/src/react/text.ts +144 -0
- package/src/react/ui/README.md +6 -0
- package/src/react/ui/alert.tsx +75 -0
- package/src/react/ui/badge.tsx +48 -0
- package/src/react/ui/button.tsx +66 -0
- package/src/react/ui/card.tsx +102 -0
- package/src/react/ui/chart.tsx +304 -0
- package/src/react/ui/input.tsx +18 -0
- package/src/react/ui/label.tsx +23 -0
- package/src/react/ui/progress.tsx +30 -0
- package/src/react/ui/select.tsx +189 -0
- package/src/react/ui/separator.tsx +27 -0
- package/src/react/ui/sheet.tsx +145 -0
- package/src/react/ui/skeleton.tsx +13 -0
- package/src/react/ui/table.tsx +113 -0
- package/src/react/ui/tabs.tsx +89 -0
- package/src/react/views.tsx +443 -0
- package/src/sales.ts +120 -0
- package/src/store.ts +419 -0
- package/src/target.ts +51 -0
- package/src/types.ts +202 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { useId } from 'react';
|
|
2
|
+
import { Area, AreaChart, Bar, BarChart, CartesianGrid, XAxis, YAxis } from 'recharts';
|
|
3
|
+
import { SOURCE_LABELS, type SourceCount } from '../leads.ts';
|
|
4
|
+
import { formatMoney, fractionDigits, fromMinor, type MoneyTotals } from '../money.ts';
|
|
5
|
+
import { CrmCard } from './parts.tsx';
|
|
6
|
+
import { withText, type CrmText } from './text.ts';
|
|
7
|
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from './ui/chart.tsx';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Charts as the Baack console draws them: shadcn's chart wrapper on Recharts, coloured by the theme's chart tokens.
|
|
11
|
+
* Each chart is hidden from screen readers, which get the same figures as a table.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const formatDay = (day: string) =>
|
|
15
|
+
new Date(`${day}T00:00:00Z`).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' });
|
|
16
|
+
|
|
17
|
+
/** Payments received each day, as an area like the console's usage chart. */
|
|
18
|
+
export function RevenueChart({
|
|
19
|
+
days,
|
|
20
|
+
currencyCode,
|
|
21
|
+
text,
|
|
22
|
+
}: {
|
|
23
|
+
days: { day: string; totals: MoneyTotals }[];
|
|
24
|
+
/** The currency charted; others aren't added in. */
|
|
25
|
+
currencyCode: string | undefined;
|
|
26
|
+
text?: Partial<CrmText> | undefined;
|
|
27
|
+
}) {
|
|
28
|
+
const words = withText(text);
|
|
29
|
+
const id = useId().replace(/:/g, '');
|
|
30
|
+
const currency = currencyCode ?? 'GBP';
|
|
31
|
+
const scale = 10 ** fractionDigits(currency);
|
|
32
|
+
const points = days.map(({ day, totals }) => ({ day, revenue: (totals[currency] ?? 0) / scale }));
|
|
33
|
+
const config = { revenue: { label: words.revenue, color: 'var(--chart-1)' } } satisfies ChartConfig;
|
|
34
|
+
const money = (value: number) => formatMoney(fromMinor(Math.round(value * scale), currency), 'en-GB');
|
|
35
|
+
const short = (value: number) =>
|
|
36
|
+
new Intl.NumberFormat('en-GB', { style: 'currency', currency, notation: 'compact' }).format(value);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<CrmCard title={words.revenueOverTime} description={words.revenueHint} text={text}>
|
|
40
|
+
<ChartContainer config={config} className="aspect-auto h-60 w-full" aria-hidden="true">
|
|
41
|
+
<AreaChart data={points} accessibilityLayer={false} margin={{ left: 0, right: 8 }}>
|
|
42
|
+
<defs>
|
|
43
|
+
<linearGradient id={`${id}-revenue`} x1="0" y1="0" x2="0" y2="1">
|
|
44
|
+
<stop offset="5%" stopColor="var(--color-revenue)" stopOpacity={0.8} />
|
|
45
|
+
<stop offset="95%" stopColor="var(--color-revenue)" stopOpacity={0.1} />
|
|
46
|
+
</linearGradient>
|
|
47
|
+
</defs>
|
|
48
|
+
<CartesianGrid vertical={false} />
|
|
49
|
+
<XAxis
|
|
50
|
+
dataKey="day"
|
|
51
|
+
tickLine={false}
|
|
52
|
+
axisLine={false}
|
|
53
|
+
tickMargin={8}
|
|
54
|
+
minTickGap={32}
|
|
55
|
+
tickFormatter={formatDay}
|
|
56
|
+
/>
|
|
57
|
+
<YAxis tickLine={false} axisLine={false} width={56} tickFormatter={short} />
|
|
58
|
+
<ChartTooltip
|
|
59
|
+
cursor={false}
|
|
60
|
+
content={
|
|
61
|
+
<ChartTooltipContent
|
|
62
|
+
labelFormatter={(value) => formatDay(String(value))}
|
|
63
|
+
formatter={(value) => money(Number(value))}
|
|
64
|
+
indicator="dot"
|
|
65
|
+
/>
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
<Area
|
|
69
|
+
dataKey="revenue"
|
|
70
|
+
type="monotone"
|
|
71
|
+
fill={`url(#${id}-revenue)`}
|
|
72
|
+
stroke="var(--color-revenue)"
|
|
73
|
+
isAnimationActive={false}
|
|
74
|
+
/>
|
|
75
|
+
</AreaChart>
|
|
76
|
+
</ChartContainer>
|
|
77
|
+
{/* Tables ignore sr-only's 1px height, so the wrapper hides it. */}
|
|
78
|
+
<div className="sr-only">
|
|
79
|
+
<table>
|
|
80
|
+
<caption>{words.revenueOverTime}</caption>
|
|
81
|
+
<thead>
|
|
82
|
+
<tr>
|
|
83
|
+
<th scope="col">{words.date}</th>
|
|
84
|
+
<th scope="col">{words.revenue}</th>
|
|
85
|
+
</tr>
|
|
86
|
+
</thead>
|
|
87
|
+
<tbody>
|
|
88
|
+
{points
|
|
89
|
+
.filter((point) => point.revenue !== 0)
|
|
90
|
+
.map((point) => (
|
|
91
|
+
<tr key={point.day}>
|
|
92
|
+
<th scope="row">{formatDay(point.day)}</th>
|
|
93
|
+
<td>{money(point.revenue)}</td>
|
|
94
|
+
</tr>
|
|
95
|
+
))}
|
|
96
|
+
</tbody>
|
|
97
|
+
</table>
|
|
98
|
+
</div>
|
|
99
|
+
</CrmCard>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** How many leads came from each source, as a shadcn bar chart. */
|
|
104
|
+
export function LeadsBySourceCard({ counts, text }: { counts: SourceCount[]; text?: Partial<CrmText> | undefined }) {
|
|
105
|
+
const words = withText(text);
|
|
106
|
+
const total = counts.reduce((sum, row) => sum + row.count, 0);
|
|
107
|
+
const points = counts
|
|
108
|
+
.filter((row) => row.count > 0)
|
|
109
|
+
.map((row) => ({ source: SOURCE_LABELS[row.source], leads: row.count }));
|
|
110
|
+
const config = { leads: { label: words.leads, color: 'var(--chart-2)' } } satisfies ChartConfig;
|
|
111
|
+
return (
|
|
112
|
+
<CrmCard title={words.leadsBySource} description={`${total} ${words.leads.toLowerCase()}`} text={text}>
|
|
113
|
+
<ChartContainer config={config} className="aspect-auto h-60 w-full" aria-hidden="true">
|
|
114
|
+
<BarChart data={points} layout="vertical" accessibilityLayer={false} margin={{ left: 0, right: 8 }}>
|
|
115
|
+
<CartesianGrid horizontal={false} />
|
|
116
|
+
<YAxis dataKey="source" type="category" tickLine={false} axisLine={false} width={72} />
|
|
117
|
+
<XAxis type="number" dataKey="leads" allowDecimals={false} tickLine={false} axisLine={false} />
|
|
118
|
+
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="dot" />} />
|
|
119
|
+
<Bar dataKey="leads" fill="var(--color-leads)" radius={4} isAnimationActive={false} />
|
|
120
|
+
</BarChart>
|
|
121
|
+
</ChartContainer>
|
|
122
|
+
<div className="sr-only">
|
|
123
|
+
<table>
|
|
124
|
+
<caption>{words.leadsBySource}</caption>
|
|
125
|
+
<thead>
|
|
126
|
+
<tr>
|
|
127
|
+
<th scope="col">{words.source}</th>
|
|
128
|
+
<th scope="col">{words.leads}</th>
|
|
129
|
+
</tr>
|
|
130
|
+
</thead>
|
|
131
|
+
<tbody>
|
|
132
|
+
{points.map((point) => (
|
|
133
|
+
<tr key={point.source}>
|
|
134
|
+
<th scope="row">{point.source}</th>
|
|
135
|
+
<td>{point.leads}</td>
|
|
136
|
+
</tr>
|
|
137
|
+
))}
|
|
138
|
+
</tbody>
|
|
139
|
+
</table>
|
|
140
|
+
</div>
|
|
141
|
+
</CrmCard>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CompanyAccount } from '../account.ts';
|
|
3
|
+
import { isOverdueInvoice, outstanding } from '../invoices.ts';
|
|
4
|
+
import { dealOutcome, stageOf } from '../pipeline.ts';
|
|
5
|
+
import type { Deal, Invoice, Lead, Pipeline } from '../types.ts';
|
|
6
|
+
import { enumLabel, formatDate, formatMaybeMoney, formatTotals } from './format.ts';
|
|
7
|
+
import { CrmCard, InvoiceStatusBadge, LeadStatusBadge, OutcomeBadge } from './parts.tsx';
|
|
8
|
+
import { withText, type CrmText } from './text.ts';
|
|
9
|
+
import { Card, CardDescription, CardHeader, CardTitle } from './ui/card.tsx';
|
|
10
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './ui/table.tsx';
|
|
11
|
+
|
|
12
|
+
function Figure({ label, value, emphasis }: { label: string; value: string; emphasis?: boolean }) {
|
|
13
|
+
return (
|
|
14
|
+
<Card size="sm">
|
|
15
|
+
<CardHeader>
|
|
16
|
+
<CardDescription>
|
|
17
|
+
<h3>{label}</h3>
|
|
18
|
+
</CardDescription>
|
|
19
|
+
<CardTitle>
|
|
20
|
+
<span className={emphasis ? 'text-destructive text-xl tabular-nums' : 'text-xl tabular-nums'}>{value}</span>
|
|
21
|
+
</CardTitle>
|
|
22
|
+
</CardHeader>
|
|
23
|
+
</Card>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* One customer company's account: its figures (open and won deals, outstanding, overdue, received), deals, open
|
|
29
|
+
* leads, invoices and payments. `people` and `tasks` are the host's own panels (from the identity search and
|
|
30
|
+
* baack-ts-tasks), placed beside the CRM's.
|
|
31
|
+
*/
|
|
32
|
+
export function CompanyAccountView({
|
|
33
|
+
account,
|
|
34
|
+
pipelines,
|
|
35
|
+
onOpenDeal,
|
|
36
|
+
onOpenLead,
|
|
37
|
+
people,
|
|
38
|
+
tasks,
|
|
39
|
+
sample,
|
|
40
|
+
now = new Date(),
|
|
41
|
+
text,
|
|
42
|
+
}: {
|
|
43
|
+
account: CompanyAccount;
|
|
44
|
+
pipelines: readonly Pipeline[];
|
|
45
|
+
onOpenDeal?: ((deal: Deal) => void) | undefined;
|
|
46
|
+
onOpenLead?: ((lead: Lead) => void) | undefined;
|
|
47
|
+
people?: ReactNode;
|
|
48
|
+
tasks?: ReactNode;
|
|
49
|
+
sample?: boolean | undefined;
|
|
50
|
+
now?: Date;
|
|
51
|
+
text?: Partial<CrmText> | undefined;
|
|
52
|
+
}) {
|
|
53
|
+
const words = withText(text);
|
|
54
|
+
const overdue = Object.values(account.overdue).some((minor) => minor > 0);
|
|
55
|
+
const opener = <T extends { title: string }>(record: T, open?: (record: T) => void) =>
|
|
56
|
+
open ? (
|
|
57
|
+
<button type="button" className="text-left font-medium hover:underline" onClick={() => open(record)}>
|
|
58
|
+
{record.title}
|
|
59
|
+
</button>
|
|
60
|
+
) : (
|
|
61
|
+
<span className="font-medium">{record.title}</span>
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className="grid gap-6">
|
|
66
|
+
<section aria-label={words.account} className="grid gap-4 sm:grid-cols-2 xl:grid-cols-5">
|
|
67
|
+
<Figure label={words.openValue} value={formatTotals(account.openValue)} />
|
|
68
|
+
<Figure label={words.wonValue} value={formatTotals(account.wonValue)} />
|
|
69
|
+
<Figure label={words.outstanding} value={formatTotals(account.outstanding)} />
|
|
70
|
+
<Figure label={words.overdue} value={formatTotals(account.overdue)} emphasis={overdue} />
|
|
71
|
+
<Figure label={words.received} value={formatTotals(account.received)} />
|
|
72
|
+
</section>
|
|
73
|
+
|
|
74
|
+
<div className="grid items-start gap-6 lg:grid-cols-2">
|
|
75
|
+
<CrmCard title={words.deals} sample={sample} text={text}>
|
|
76
|
+
{account.deals.length === 0 ? (
|
|
77
|
+
<p className="text-muted-foreground text-sm">{words.noDeals}</p>
|
|
78
|
+
) : (
|
|
79
|
+
<Table>
|
|
80
|
+
<caption className="sr-only">{words.deals}</caption>
|
|
81
|
+
<TableHeader>
|
|
82
|
+
<TableRow>
|
|
83
|
+
<TableHead>{words.deals}</TableHead>
|
|
84
|
+
<TableHead>{words.stage}</TableHead>
|
|
85
|
+
<TableHead className="text-right">{words.value}</TableHead>
|
|
86
|
+
</TableRow>
|
|
87
|
+
</TableHeader>
|
|
88
|
+
<TableBody>
|
|
89
|
+
{account.deals.map((deal) => {
|
|
90
|
+
const pipeline = pipelines.find((candidate) => stageOf(deal, candidate));
|
|
91
|
+
const stage = pipeline && stageOf(deal, pipeline);
|
|
92
|
+
return (
|
|
93
|
+
<TableRow key={deal.urn}>
|
|
94
|
+
<TableCell className="whitespace-normal">{opener(deal, onOpenDeal)}</TableCell>
|
|
95
|
+
<TableCell>
|
|
96
|
+
<OutcomeBadge outcome={dealOutcome(deal)} label={stage?.name ?? '-'} />
|
|
97
|
+
</TableCell>
|
|
98
|
+
<TableCell className="text-right tabular-nums">{formatMaybeMoney(deal.targetValue)}</TableCell>
|
|
99
|
+
</TableRow>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</TableBody>
|
|
103
|
+
</Table>
|
|
104
|
+
)}
|
|
105
|
+
</CrmCard>
|
|
106
|
+
|
|
107
|
+
<CrmCard title={words.openLeads} sample={sample} text={text}>
|
|
108
|
+
{account.openLeads.length === 0 ? (
|
|
109
|
+
<p className="text-muted-foreground text-sm">{words.none}</p>
|
|
110
|
+
) : (
|
|
111
|
+
<ul className="grid gap-2 text-sm">
|
|
112
|
+
{account.openLeads.map((lead) => (
|
|
113
|
+
<li key={lead.urn} className="flex items-center justify-between gap-2">
|
|
114
|
+
{opener(lead, onOpenLead)}
|
|
115
|
+
<LeadStatusBadge lead={lead} />
|
|
116
|
+
</li>
|
|
117
|
+
))}
|
|
118
|
+
</ul>
|
|
119
|
+
)}
|
|
120
|
+
</CrmCard>
|
|
121
|
+
|
|
122
|
+
{people && <div>{people}</div>}
|
|
123
|
+
{tasks && <div>{tasks}</div>}
|
|
124
|
+
|
|
125
|
+
<CrmCard title={words.invoices} sample={sample} text={text} className="lg:col-span-2">
|
|
126
|
+
{account.invoices.length === 0 ? (
|
|
127
|
+
<p className="text-muted-foreground text-sm">{words.noInvoices}</p>
|
|
128
|
+
) : (
|
|
129
|
+
<Table>
|
|
130
|
+
<caption className="sr-only">{words.invoices}</caption>
|
|
131
|
+
<TableHeader>
|
|
132
|
+
<TableRow>
|
|
133
|
+
<TableHead>{words.invoice}</TableHead>
|
|
134
|
+
<TableHead>{words.status}</TableHead>
|
|
135
|
+
<TableHead className="text-right">{words.total}</TableHead>
|
|
136
|
+
<TableHead className="text-right">{words.outstanding}</TableHead>
|
|
137
|
+
<TableHead>{words.due}</TableHead>
|
|
138
|
+
</TableRow>
|
|
139
|
+
</TableHeader>
|
|
140
|
+
<TableBody>
|
|
141
|
+
{account.invoices.map((invoice: Invoice) => (
|
|
142
|
+
<TableRow key={invoice.urn}>
|
|
143
|
+
<TableCell className="whitespace-normal">
|
|
144
|
+
{invoice.lines?.[0]?.description ?? invoice.urn.slice(-6)}
|
|
145
|
+
</TableCell>
|
|
146
|
+
<TableCell>
|
|
147
|
+
<InvoiceStatusBadge status={invoice.status} overdue={isOverdueInvoice(invoice, now)} />
|
|
148
|
+
</TableCell>
|
|
149
|
+
<TableCell className="text-right tabular-nums">
|
|
150
|
+
{formatMaybeMoney(invoice.total)}
|
|
151
|
+
</TableCell>
|
|
152
|
+
<TableCell className="text-right tabular-nums">{formatMaybeMoney(outstanding(invoice))}</TableCell>
|
|
153
|
+
<TableCell>{formatDate(invoice.dueTimestamp)}</TableCell>
|
|
154
|
+
</TableRow>
|
|
155
|
+
))}
|
|
156
|
+
</TableBody>
|
|
157
|
+
</Table>
|
|
158
|
+
)}
|
|
159
|
+
</CrmCard>
|
|
160
|
+
|
|
161
|
+
<CrmCard title={words.payments} sample={sample} text={text} className="lg:col-span-2">
|
|
162
|
+
{account.payments.length === 0 ? (
|
|
163
|
+
<p className="text-muted-foreground text-sm">{words.noPayments}</p>
|
|
164
|
+
) : (
|
|
165
|
+
<Table>
|
|
166
|
+
<caption className="sr-only">{words.payments}</caption>
|
|
167
|
+
<TableHeader>
|
|
168
|
+
<TableRow>
|
|
169
|
+
<TableHead>{words.date}</TableHead>
|
|
170
|
+
<TableHead>{words.method}</TableHead>
|
|
171
|
+
<TableHead>{words.reference}</TableHead>
|
|
172
|
+
<TableHead>{words.status}</TableHead>
|
|
173
|
+
<TableHead className="text-right">{words.amount}</TableHead>
|
|
174
|
+
</TableRow>
|
|
175
|
+
</TableHeader>
|
|
176
|
+
<TableBody>
|
|
177
|
+
{account.payments.map((payment) => (
|
|
178
|
+
<TableRow key={payment.urn}>
|
|
179
|
+
<TableCell>{formatDate(payment.receivedTimestamp)}</TableCell>
|
|
180
|
+
<TableCell>{enumLabel(payment.remittanceMethod)}</TableCell>
|
|
181
|
+
<TableCell>{payment.reference ?? '-'}</TableCell>
|
|
182
|
+
<TableCell>
|
|
183
|
+
{enumLabel(payment.remittanceDirection)}, {enumLabel(payment.remittanceStatus).toLowerCase()}
|
|
184
|
+
</TableCell>
|
|
185
|
+
<TableCell className="text-right tabular-nums">
|
|
186
|
+
{payment.remittanceDirection === 'REFUND' ? '-' : ''}
|
|
187
|
+
{formatMaybeMoney(payment.value)}
|
|
188
|
+
</TableCell>
|
|
189
|
+
</TableRow>
|
|
190
|
+
))}
|
|
191
|
+
</TableBody>
|
|
192
|
+
</Table>
|
|
193
|
+
)}
|
|
194
|
+
</CrmCard>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { useId } from 'react';
|
|
2
|
+
import { fromMinor, formatMoney } from '../money.ts';
|
|
3
|
+
import type { StageSummary } from '../pipeline.ts';
|
|
4
|
+
import type { Dashboard } from '../store.ts';
|
|
5
|
+
import type { SalesTarget } from '../target.ts';
|
|
6
|
+
import { formatPercent, formatTotals } from './format.ts';
|
|
7
|
+
import { ChangeIndicator, CrmCard, SampleDataBadge } from './parts.tsx';
|
|
8
|
+
import { withText, type CrmText } from './text.ts';
|
|
9
|
+
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card.tsx';
|
|
10
|
+
import { Progress } from './ui/progress.tsx';
|
|
11
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './ui/table.tsx';
|
|
12
|
+
|
|
13
|
+
/** One figure with its change against the previous period. */
|
|
14
|
+
export function MetricCard({
|
|
15
|
+
label,
|
|
16
|
+
value,
|
|
17
|
+
change,
|
|
18
|
+
hint,
|
|
19
|
+
sample,
|
|
20
|
+
text,
|
|
21
|
+
}: {
|
|
22
|
+
label: string;
|
|
23
|
+
value: string;
|
|
24
|
+
change: number | undefined;
|
|
25
|
+
hint?: string;
|
|
26
|
+
sample?: boolean | undefined;
|
|
27
|
+
text?: Partial<CrmText> | undefined;
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<Card size="sm">
|
|
31
|
+
<CardHeader>
|
|
32
|
+
<CardDescription>
|
|
33
|
+
<h2>{label}</h2>
|
|
34
|
+
</CardDescription>
|
|
35
|
+
<CardTitle>
|
|
36
|
+
<span className="text-2xl font-semibold tabular-nums">{value}</span>
|
|
37
|
+
</CardTitle>
|
|
38
|
+
{sample && (
|
|
39
|
+
<CardAction>
|
|
40
|
+
<SampleDataBadge text={text} />
|
|
41
|
+
</CardAction>
|
|
42
|
+
)}
|
|
43
|
+
</CardHeader>
|
|
44
|
+
<CardContent className="grid gap-1">
|
|
45
|
+
<ChangeIndicator change={change} text={text} />
|
|
46
|
+
{hint && <p className="text-muted-foreground text-xs">{hint}</p>}
|
|
47
|
+
</CardContent>
|
|
48
|
+
</Card>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The dashboard's four figures: customers, open deals, revenue and new leads, each against the period before. */
|
|
53
|
+
export function MetricCards({
|
|
54
|
+
dashboard,
|
|
55
|
+
sample,
|
|
56
|
+
text,
|
|
57
|
+
}: {
|
|
58
|
+
dashboard: Dashboard;
|
|
59
|
+
sample?: boolean | undefined;
|
|
60
|
+
text?: Partial<CrmText> | undefined;
|
|
61
|
+
}) {
|
|
62
|
+
const words = withText(text);
|
|
63
|
+
const { customers, openDeals, revenue, newLeads } = dashboard;
|
|
64
|
+
const shared = { sample, text };
|
|
65
|
+
return (
|
|
66
|
+
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
|
|
67
|
+
<MetricCard
|
|
68
|
+
label={words.customers}
|
|
69
|
+
value={String(customers.total)}
|
|
70
|
+
change={customers.added.change}
|
|
71
|
+
hint={words.customersHint}
|
|
72
|
+
{...shared}
|
|
73
|
+
/>
|
|
74
|
+
<MetricCard
|
|
75
|
+
label={words.openDeals}
|
|
76
|
+
value={String(openDeals.count)}
|
|
77
|
+
change={openDeals.created.change}
|
|
78
|
+
hint={formatTotals(openDeals.value)}
|
|
79
|
+
{...shared}
|
|
80
|
+
/>
|
|
81
|
+
<MetricCard
|
|
82
|
+
label={words.revenue}
|
|
83
|
+
value={formatTotals(revenue.current, revenue.currencyCode)}
|
|
84
|
+
change={revenue.change}
|
|
85
|
+
hint={words.revenueHint}
|
|
86
|
+
{...shared}
|
|
87
|
+
/>
|
|
88
|
+
<MetricCard label={words.newLeads} value={String(newLeads.current)} change={newLeads.change} {...shared} />
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Progress towards the sales target, one bar per currency. */
|
|
94
|
+
export function TargetCard({
|
|
95
|
+
target,
|
|
96
|
+
sample,
|
|
97
|
+
text,
|
|
98
|
+
}: {
|
|
99
|
+
target: SalesTarget;
|
|
100
|
+
sample?: boolean | undefined;
|
|
101
|
+
text?: Partial<CrmText> | undefined;
|
|
102
|
+
}) {
|
|
103
|
+
const words = withText(text);
|
|
104
|
+
const id = useId();
|
|
105
|
+
const currencies = Object.keys(target.progress);
|
|
106
|
+
return (
|
|
107
|
+
<CrmCard title={words.target} description={words.targetSummary} sample={sample} text={text}>
|
|
108
|
+
{currencies.length === 0 ? (
|
|
109
|
+
<p className="text-muted-foreground text-sm">{words.none}</p>
|
|
110
|
+
) : (
|
|
111
|
+
<ul className="grid gap-4">
|
|
112
|
+
{currencies.map((currency) => {
|
|
113
|
+
const progress = target.progress[currency] ?? 0;
|
|
114
|
+
const received = formatMoney(fromMinor(target.received[currency] ?? 0, currency));
|
|
115
|
+
const goal = formatMoney(fromMinor(target.target[currency] ?? 0, currency));
|
|
116
|
+
return (
|
|
117
|
+
<li key={currency} className="grid gap-2">
|
|
118
|
+
<p className="flex items-baseline justify-between gap-2">
|
|
119
|
+
<span className="text-2xl font-semibold tabular-nums">{formatPercent(progress)}</span>
|
|
120
|
+
<span id={`${id}-${currency}`} className="text-muted-foreground text-sm">
|
|
121
|
+
{received} {words.targetReceived} {goal}
|
|
122
|
+
</span>
|
|
123
|
+
</p>
|
|
124
|
+
<Progress value={Math.min(100, progress * 100)} aria-labelledby={`${id}-${currency}`} />
|
|
125
|
+
</li>
|
|
126
|
+
);
|
|
127
|
+
})}
|
|
128
|
+
</ul>
|
|
129
|
+
)}
|
|
130
|
+
</CrmCard>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The pipeline by stage: deals, value, weighted value and share. */
|
|
135
|
+
export function PipelineCard({
|
|
136
|
+
stages,
|
|
137
|
+
sample,
|
|
138
|
+
text,
|
|
139
|
+
}: {
|
|
140
|
+
stages: StageSummary[];
|
|
141
|
+
sample?: boolean | undefined;
|
|
142
|
+
text?: Partial<CrmText> | undefined;
|
|
143
|
+
}) {
|
|
144
|
+
const words = withText(text);
|
|
145
|
+
return (
|
|
146
|
+
<CrmCard title={words.pipeline} sample={sample} text={text}>
|
|
147
|
+
<Table>
|
|
148
|
+
<TableHeader>
|
|
149
|
+
<TableRow>
|
|
150
|
+
<TableHead>{words.stage}</TableHead>
|
|
151
|
+
<TableHead className="text-right">{words.deals}</TableHead>
|
|
152
|
+
<TableHead className="text-right">{words.value}</TableHead>
|
|
153
|
+
<TableHead className="text-right">{words.weighted}</TableHead>
|
|
154
|
+
<TableHead className="text-right">{words.share}</TableHead>
|
|
155
|
+
</TableRow>
|
|
156
|
+
</TableHeader>
|
|
157
|
+
<TableBody>
|
|
158
|
+
{stages.map((row) => (
|
|
159
|
+
<TableRow key={row.stage.urn}>
|
|
160
|
+
<TableCell className="font-medium">{row.stage.name}</TableCell>
|
|
161
|
+
<TableCell className="text-right tabular-nums">{row.deals.length}</TableCell>
|
|
162
|
+
<TableCell className="text-right tabular-nums">{formatTotals(row.value)}</TableCell>
|
|
163
|
+
<TableCell className="text-right tabular-nums">{formatTotals(row.weighted)}</TableCell>
|
|
164
|
+
<TableCell className="text-right tabular-nums">{formatPercent(row.share)}</TableCell>
|
|
165
|
+
</TableRow>
|
|
166
|
+
))}
|
|
167
|
+
</TableBody>
|
|
168
|
+
</Table>
|
|
169
|
+
</CrmCard>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { cn } from 'cn';
|
|
2
|
+
import { addMoney, type MoneyTotals } from '../money.ts';
|
|
3
|
+
import { dealCompany, dealOutcome, orderedStages } from '../pipeline.ts';
|
|
4
|
+
import type { Deal, Pipeline, PipelineStage } from '../types.ts';
|
|
5
|
+
import { companyNameOf, formatDate, formatMaybeMoney, formatTotals, type CrmNames } from './format.ts';
|
|
6
|
+
import { OutcomeBadge, SampleDataBadge } from './parts.tsx';
|
|
7
|
+
import { recordItemId } from './SidePanel.tsx';
|
|
8
|
+
import { withText, type CrmText } from './text.ts';
|
|
9
|
+
import { Card, CardContent, CardHeader, CardTitle } from './ui/card.tsx';
|
|
10
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select.tsx';
|
|
11
|
+
|
|
12
|
+
/** Picks the stage a deal is at; moving it is one choice, so it works from the keyboard as well as by pointer. */
|
|
13
|
+
export function StageSelect({
|
|
14
|
+
deal,
|
|
15
|
+
pipeline,
|
|
16
|
+
onMove,
|
|
17
|
+
disabled,
|
|
18
|
+
text,
|
|
19
|
+
className,
|
|
20
|
+
}: {
|
|
21
|
+
deal: Deal;
|
|
22
|
+
pipeline: Pipeline;
|
|
23
|
+
onMove: (deal: Deal, stage: PipelineStage) => void;
|
|
24
|
+
disabled?: boolean | undefined;
|
|
25
|
+
text?: Partial<CrmText> | undefined;
|
|
26
|
+
className?: string | undefined;
|
|
27
|
+
}) {
|
|
28
|
+
const words = withText(text);
|
|
29
|
+
const stages = orderedStages(pipeline);
|
|
30
|
+
return (
|
|
31
|
+
<Select
|
|
32
|
+
value={deal.workflowStage?.urn ?? ''}
|
|
33
|
+
disabled={disabled ?? false}
|
|
34
|
+
onValueChange={(urn) => {
|
|
35
|
+
const stage = stages.find((candidate) => candidate.urn === urn);
|
|
36
|
+
if (stage) onMove(deal, stage);
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<SelectTrigger size="sm" aria-label={`${words.moveTo}: ${deal.title}`} className={className}>
|
|
40
|
+
<SelectValue />
|
|
41
|
+
</SelectTrigger>
|
|
42
|
+
<SelectContent>
|
|
43
|
+
{stages.map((stage) => (
|
|
44
|
+
<SelectItem key={stage.urn} value={stage.urn}>
|
|
45
|
+
{stage.name}
|
|
46
|
+
</SelectItem>
|
|
47
|
+
))}
|
|
48
|
+
</SelectContent>
|
|
49
|
+
</Select>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Deals as a board, one column per pipeline stage with its count and value. Each deal can be opened, and moved with
|
|
55
|
+
* its stage picker.
|
|
56
|
+
*/
|
|
57
|
+
export function DealsBoard({
|
|
58
|
+
deals,
|
|
59
|
+
pipeline,
|
|
60
|
+
names,
|
|
61
|
+
onOpen,
|
|
62
|
+
onMove,
|
|
63
|
+
selected,
|
|
64
|
+
saving,
|
|
65
|
+
sample,
|
|
66
|
+
text,
|
|
67
|
+
}: {
|
|
68
|
+
deals: readonly Deal[];
|
|
69
|
+
pipeline: Pipeline;
|
|
70
|
+
names?: CrmNames | undefined;
|
|
71
|
+
onOpen?: ((deal: Deal) => void) | undefined;
|
|
72
|
+
onMove?: ((deal: Deal, stage: PipelineStage) => void) | undefined;
|
|
73
|
+
/** The open deal, highlighted. */
|
|
74
|
+
selected?: string | undefined;
|
|
75
|
+
/** URNs of deals being saved. */
|
|
76
|
+
saving?: ReadonlySet<string> | undefined;
|
|
77
|
+
sample?: boolean | undefined;
|
|
78
|
+
text?: Partial<CrmText> | undefined;
|
|
79
|
+
}) {
|
|
80
|
+
const words = withText(text);
|
|
81
|
+
return (
|
|
82
|
+
<section aria-label={`${pipeline.name}: ${words.deals}`} className="grid gap-3">
|
|
83
|
+
{sample && (
|
|
84
|
+
<div>
|
|
85
|
+
<SampleDataBadge text={text} />
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
{/* Focusable, so the columns past the edge can be scrolled to from the keyboard. */}
|
|
89
|
+
<div tabIndex={0} aria-label={pipeline.name} className="flex gap-3 overflow-x-auto rounded-xl pb-2">
|
|
90
|
+
{orderedStages(pipeline).map((stage) => {
|
|
91
|
+
const here = deals.filter((deal) => deal.workflowStage?.urn === stage.urn);
|
|
92
|
+
const value = here.reduce<MoneyTotals>((totals, deal) => addMoney(totals, deal.targetValue), {});
|
|
93
|
+
return (
|
|
94
|
+
<section
|
|
95
|
+
key={stage.urn}
|
|
96
|
+
aria-labelledby={`stage-${stage.urn}`}
|
|
97
|
+
className="bg-muted/50 flex w-64 shrink-0 flex-col gap-2 rounded-xl p-2"
|
|
98
|
+
>
|
|
99
|
+
<header className="px-1 pt-1">
|
|
100
|
+
<h3
|
|
101
|
+
id={`stage-${stage.urn}`}
|
|
102
|
+
className="flex items-baseline justify-between gap-2 text-sm font-semibold"
|
|
103
|
+
>
|
|
104
|
+
{stage.name}
|
|
105
|
+
<span className="text-muted-foreground font-normal tabular-nums">{here.length}</span>
|
|
106
|
+
</h3>
|
|
107
|
+
<p className="text-muted-foreground text-xs tabular-nums">{formatTotals(value)}</p>
|
|
108
|
+
</header>
|
|
109
|
+
{here.length === 0 ? (
|
|
110
|
+
<p className="text-muted-foreground px-1 py-4 text-center text-xs">{words.noDeals}</p>
|
|
111
|
+
) : (
|
|
112
|
+
<ul className="grid gap-2">
|
|
113
|
+
{here.map((deal) => (
|
|
114
|
+
<li key={deal.urn}>
|
|
115
|
+
<Card
|
|
116
|
+
size="sm"
|
|
117
|
+
className={cn(
|
|
118
|
+
saving?.has(deal.urn) && 'opacity-60',
|
|
119
|
+
selected === deal.urn && 'ring-primary ring-2',
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
<CardHeader>
|
|
123
|
+
<CardTitle className="text-sm">
|
|
124
|
+
{onOpen ? (
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
id={recordItemId(deal.urn)}
|
|
128
|
+
aria-current={selected === deal.urn ? 'true' : undefined}
|
|
129
|
+
className="text-left hover:underline"
|
|
130
|
+
onClick={() => onOpen(deal)}
|
|
131
|
+
>
|
|
132
|
+
{deal.title}
|
|
133
|
+
</button>
|
|
134
|
+
) : (
|
|
135
|
+
deal.title
|
|
136
|
+
)}
|
|
137
|
+
</CardTitle>
|
|
138
|
+
</CardHeader>
|
|
139
|
+
<CardContent className="grid gap-2 text-xs">
|
|
140
|
+
<p className="text-muted-foreground flex items-center justify-between gap-2">
|
|
141
|
+
<span>{companyNameOf(names, dealCompany(deal)?.urn) ?? words.unnamed}</span>
|
|
142
|
+
{dealOutcome(deal) !== 'OPEN' && (
|
|
143
|
+
<OutcomeBadge
|
|
144
|
+
outcome={dealOutcome(deal)}
|
|
145
|
+
label={dealOutcome(deal) === 'WON' ? words.outcomeWon : words.outcomeLost}
|
|
146
|
+
/>
|
|
147
|
+
)}
|
|
148
|
+
</p>
|
|
149
|
+
<p className="flex justify-between gap-2">
|
|
150
|
+
<span className="font-medium tabular-nums">{formatMaybeMoney(deal.targetValue)}</span>
|
|
151
|
+
<span className="text-muted-foreground">
|
|
152
|
+
{formatDate(deal.closeTimestamp ?? deal.targetCloseTimestamp)}
|
|
153
|
+
</span>
|
|
154
|
+
</p>
|
|
155
|
+
{onMove && (
|
|
156
|
+
<StageSelect
|
|
157
|
+
deal={deal}
|
|
158
|
+
pipeline={pipeline}
|
|
159
|
+
onMove={onMove}
|
|
160
|
+
disabled={saving?.has(deal.urn)}
|
|
161
|
+
text={text}
|
|
162
|
+
className="w-full"
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
</CardContent>
|
|
166
|
+
</Card>
|
|
167
|
+
</li>
|
|
168
|
+
))}
|
|
169
|
+
</ul>
|
|
170
|
+
)}
|
|
171
|
+
</section>
|
|
172
|
+
);
|
|
173
|
+
})}
|
|
174
|
+
</div>
|
|
175
|
+
</section>
|
|
176
|
+
);
|
|
177
|
+
}
|