@contractspec/example.crm-pipeline 1.57.0 → 1.58.0

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 (259) hide show
  1. package/.turbo/turbo-build.log +148 -164
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +20 -0
  4. package/dist/browser/crm-pipeline.feature.js +75 -0
  5. package/dist/browser/deal/deal.enum.js +18 -0
  6. package/dist/browser/deal/deal.operation.js +396 -0
  7. package/dist/browser/deal/deal.schema.js +141 -0
  8. package/dist/browser/deal/deal.test-spec.js +58 -0
  9. package/dist/browser/deal/index.js +408 -0
  10. package/dist/browser/docs/crm-pipeline.docblock.js +113 -0
  11. package/dist/browser/docs/index.js +113 -0
  12. package/dist/browser/entities/company.entity.js +52 -0
  13. package/dist/browser/entities/contact.entity.js +66 -0
  14. package/dist/browser/entities/deal.entity.js +107 -0
  15. package/dist/browser/entities/index.js +343 -0
  16. package/dist/browser/entities/task.entity.js +99 -0
  17. package/dist/browser/events/contact.event.js +31 -0
  18. package/dist/browser/events/deal.event.js +101 -0
  19. package/dist/browser/events/index.js +158 -0
  20. package/dist/browser/events/task.event.js +28 -0
  21. package/dist/browser/example.js +39 -0
  22. package/dist/browser/handlers/crm.handlers.js +160 -0
  23. package/dist/browser/handlers/deal.handlers.js +293 -0
  24. package/dist/browser/handlers/index.js +456 -0
  25. package/dist/browser/handlers/mock-data.js +165 -0
  26. package/dist/browser/index.js +3279 -0
  27. package/dist/browser/operations/index.js +407 -0
  28. package/dist/browser/presentations/dashboard.presentation.js +52 -0
  29. package/dist/browser/presentations/index.js +284 -0
  30. package/dist/browser/presentations/pipeline.presentation.js +233 -0
  31. package/dist/browser/seeders/index.js +22 -0
  32. package/dist/browser/shared/overlay-types.js +0 -0
  33. package/dist/browser/ui/CrmDashboard.js +1325 -0
  34. package/dist/browser/ui/CrmDealCard.js +50 -0
  35. package/dist/browser/ui/CrmPipelineBoard.js +160 -0
  36. package/dist/browser/ui/hooks/index.js +186 -0
  37. package/dist/browser/ui/hooks/useDealList.js +84 -0
  38. package/dist/browser/ui/hooks/useDealMutations.js +100 -0
  39. package/dist/browser/ui/index.js +1972 -0
  40. package/dist/browser/ui/modals/CreateDealModal.js +211 -0
  41. package/dist/browser/ui/modals/DealActionsModal.js +428 -0
  42. package/dist/browser/ui/modals/index.js +638 -0
  43. package/dist/browser/ui/overlays/demo-overlays.js +55 -0
  44. package/dist/browser/ui/overlays/index.js +55 -0
  45. package/dist/browser/ui/renderers/index.js +827 -0
  46. package/dist/browser/ui/renderers/pipeline.markdown.js +564 -0
  47. package/dist/browser/ui/renderers/pipeline.renderer.js +264 -0
  48. package/dist/crm-pipeline.feature.d.ts +1 -6
  49. package/dist/crm-pipeline.feature.d.ts.map +1 -1
  50. package/dist/crm-pipeline.feature.js +74 -164
  51. package/dist/deal/deal.enum.d.ts +2 -7
  52. package/dist/deal/deal.enum.d.ts.map +1 -1
  53. package/dist/deal/deal.enum.js +16 -22
  54. package/dist/deal/deal.operation.d.ts +444 -450
  55. package/dist/deal/deal.operation.d.ts.map +1 -1
  56. package/dist/deal/deal.operation.js +390 -263
  57. package/dist/deal/deal.schema.d.ts +251 -256
  58. package/dist/deal/deal.schema.d.ts.map +1 -1
  59. package/dist/deal/deal.schema.js +131 -275
  60. package/dist/deal/deal.test-spec.d.ts +2 -7
  61. package/dist/deal/deal.test-spec.d.ts.map +1 -1
  62. package/dist/deal/deal.test-spec.js +56 -62
  63. package/dist/deal/index.d.ts +7 -4
  64. package/dist/deal/index.d.ts.map +1 -0
  65. package/dist/deal/index.js +408 -4
  66. package/dist/docs/crm-pipeline.docblock.d.ts +2 -1
  67. package/dist/docs/crm-pipeline.docblock.d.ts.map +1 -0
  68. package/dist/docs/crm-pipeline.docblock.js +45 -51
  69. package/dist/docs/index.d.ts +2 -1
  70. package/dist/docs/index.d.ts.map +1 -0
  71. package/dist/docs/index.js +114 -1
  72. package/dist/entities/company.entity.d.ts +27 -32
  73. package/dist/entities/company.entity.d.ts.map +1 -1
  74. package/dist/entities/company.entity.js +51 -61
  75. package/dist/entities/contact.entity.d.ts +31 -36
  76. package/dist/entities/contact.entity.d.ts.map +1 -1
  77. package/dist/entities/contact.entity.js +65 -76
  78. package/dist/entities/deal.entity.d.ts +52 -57
  79. package/dist/entities/deal.entity.d.ts.map +1 -1
  80. package/dist/entities/deal.entity.js +104 -116
  81. package/dist/entities/index.d.ts +6 -10
  82. package/dist/entities/index.d.ts.map +1 -1
  83. package/dist/entities/index.js +342 -31
  84. package/dist/entities/task.entity.d.ts +42 -47
  85. package/dist/entities/task.entity.d.ts.map +1 -1
  86. package/dist/entities/task.entity.js +95 -124
  87. package/dist/events/contact.event.d.ts +21 -27
  88. package/dist/events/contact.event.d.ts.map +1 -1
  89. package/dist/events/contact.event.js +29 -42
  90. package/dist/events/deal.event.d.ts +100 -106
  91. package/dist/events/deal.event.d.ts.map +1 -1
  92. package/dist/events/deal.event.js +93 -163
  93. package/dist/events/index.d.ts +4 -4
  94. package/dist/events/index.d.ts.map +1 -0
  95. package/dist/events/index.js +158 -4
  96. package/dist/events/task.event.d.ts +21 -27
  97. package/dist/events/task.event.d.ts.map +1 -1
  98. package/dist/events/task.event.js +26 -42
  99. package/dist/example.d.ts +2 -6
  100. package/dist/example.d.ts.map +1 -1
  101. package/dist/example.js +38 -50
  102. package/dist/handlers/crm.handlers.d.ts +80 -78
  103. package/dist/handlers/crm.handlers.d.ts.map +1 -1
  104. package/dist/handlers/crm.handlers.js +155 -166
  105. package/dist/handlers/deal.handlers.d.ts +58 -63
  106. package/dist/handlers/deal.handlers.d.ts.map +1 -1
  107. package/dist/handlers/deal.handlers.js +279 -105
  108. package/dist/handlers/index.d.ts +10 -4
  109. package/dist/handlers/index.d.ts.map +1 -0
  110. package/dist/handlers/index.js +456 -4
  111. package/dist/handlers/mock-data.d.ts +38 -41
  112. package/dist/handlers/mock-data.d.ts.map +1 -1
  113. package/dist/handlers/mock-data.js +162 -184
  114. package/dist/index.d.ts +13 -42
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +3277 -53
  117. package/dist/node/crm-pipeline.feature.js +75 -0
  118. package/dist/node/deal/deal.enum.js +18 -0
  119. package/dist/node/deal/deal.operation.js +396 -0
  120. package/dist/node/deal/deal.schema.js +141 -0
  121. package/dist/node/deal/deal.test-spec.js +58 -0
  122. package/dist/node/deal/index.js +408 -0
  123. package/dist/node/docs/crm-pipeline.docblock.js +113 -0
  124. package/dist/node/docs/index.js +113 -0
  125. package/dist/node/entities/company.entity.js +52 -0
  126. package/dist/node/entities/contact.entity.js +66 -0
  127. package/dist/node/entities/deal.entity.js +107 -0
  128. package/dist/node/entities/index.js +343 -0
  129. package/dist/node/entities/task.entity.js +99 -0
  130. package/dist/node/events/contact.event.js +31 -0
  131. package/dist/node/events/deal.event.js +101 -0
  132. package/dist/node/events/index.js +158 -0
  133. package/dist/node/events/task.event.js +28 -0
  134. package/dist/node/example.js +39 -0
  135. package/dist/node/handlers/crm.handlers.js +160 -0
  136. package/dist/node/handlers/deal.handlers.js +293 -0
  137. package/dist/node/handlers/index.js +456 -0
  138. package/dist/node/handlers/mock-data.js +165 -0
  139. package/dist/node/index.js +3279 -0
  140. package/dist/node/operations/index.js +407 -0
  141. package/dist/node/presentations/dashboard.presentation.js +52 -0
  142. package/dist/node/presentations/index.js +284 -0
  143. package/dist/node/presentations/pipeline.presentation.js +233 -0
  144. package/dist/node/seeders/index.js +22 -0
  145. package/dist/node/shared/overlay-types.js +0 -0
  146. package/dist/node/ui/CrmDashboard.js +1325 -0
  147. package/dist/node/ui/CrmDealCard.js +50 -0
  148. package/dist/node/ui/CrmPipelineBoard.js +160 -0
  149. package/dist/node/ui/hooks/index.js +186 -0
  150. package/dist/node/ui/hooks/useDealList.js +84 -0
  151. package/dist/node/ui/hooks/useDealMutations.js +100 -0
  152. package/dist/node/ui/index.js +1972 -0
  153. package/dist/node/ui/modals/CreateDealModal.js +211 -0
  154. package/dist/node/ui/modals/DealActionsModal.js +428 -0
  155. package/dist/node/ui/modals/index.js +638 -0
  156. package/dist/node/ui/overlays/demo-overlays.js +55 -0
  157. package/dist/node/ui/overlays/index.js +55 -0
  158. package/dist/node/ui/renderers/index.js +827 -0
  159. package/dist/node/ui/renderers/pipeline.markdown.js +564 -0
  160. package/dist/node/ui/renderers/pipeline.renderer.js +264 -0
  161. package/dist/operations/index.d.ts +2 -5
  162. package/dist/operations/index.d.ts.map +1 -0
  163. package/dist/operations/index.js +407 -5
  164. package/dist/presentations/dashboard.presentation.d.ts +2 -7
  165. package/dist/presentations/dashboard.presentation.d.ts.map +1 -1
  166. package/dist/presentations/dashboard.presentation.js +51 -60
  167. package/dist/presentations/index.d.ts +3 -3
  168. package/dist/presentations/index.d.ts.map +1 -0
  169. package/dist/presentations/index.js +284 -3
  170. package/dist/presentations/pipeline.presentation.d.ts +4 -9
  171. package/dist/presentations/pipeline.presentation.d.ts.map +1 -1
  172. package/dist/presentations/pipeline.presentation.js +228 -116
  173. package/dist/seeders/index.d.ts +4 -8
  174. package/dist/seeders/index.d.ts.map +1 -1
  175. package/dist/seeders/index.js +21 -45
  176. package/dist/shared/overlay-types.d.ts +25 -28
  177. package/dist/shared/overlay-types.d.ts.map +1 -1
  178. package/dist/shared/overlay-types.js +1 -0
  179. package/dist/ui/CrmDashboard.d.ts +1 -6
  180. package/dist/ui/CrmDashboard.d.ts.map +1 -1
  181. package/dist/ui/CrmDashboard.js +1318 -296
  182. package/dist/ui/CrmDealCard.d.ts +8 -12
  183. package/dist/ui/CrmDealCard.d.ts.map +1 -1
  184. package/dist/ui/CrmDealCard.js +47 -45
  185. package/dist/ui/CrmPipelineBoard.d.ts +11 -20
  186. package/dist/ui/CrmPipelineBoard.d.ts.map +1 -1
  187. package/dist/ui/CrmPipelineBoard.js +157 -94
  188. package/dist/ui/hooks/index.d.ts +3 -3
  189. package/dist/ui/hooks/index.d.ts.map +1 -0
  190. package/dist/ui/hooks/index.js +185 -4
  191. package/dist/ui/hooks/useDealList.d.ts +28 -32
  192. package/dist/ui/hooks/useDealList.d.ts.map +1 -1
  193. package/dist/ui/hooks/useDealList.js +81 -90
  194. package/dist/ui/hooks/useDealMutations.d.ts +18 -22
  195. package/dist/ui/hooks/useDealMutations.d.ts.map +1 -1
  196. package/dist/ui/hooks/useDealMutations.js +97 -155
  197. package/dist/ui/index.d.ts +8 -14
  198. package/dist/ui/index.d.ts.map +1 -0
  199. package/dist/ui/index.js +1973 -15
  200. package/dist/ui/modals/CreateDealModal.d.ts +19 -29
  201. package/dist/ui/modals/CreateDealModal.d.ts.map +1 -1
  202. package/dist/ui/modals/CreateDealModal.js +209 -180
  203. package/dist/ui/modals/DealActionsModal.d.ts +31 -44
  204. package/dist/ui/modals/DealActionsModal.d.ts.map +1 -1
  205. package/dist/ui/modals/DealActionsModal.js +424 -367
  206. package/dist/ui/modals/index.d.ts +3 -3
  207. package/dist/ui/modals/index.d.ts.map +1 -0
  208. package/dist/ui/modals/index.js +638 -3
  209. package/dist/ui/overlays/demo-overlays.d.ts +10 -8
  210. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
  211. package/dist/ui/overlays/demo-overlays.js +54 -66
  212. package/dist/ui/overlays/index.d.ts +2 -2
  213. package/dist/ui/overlays/index.d.ts.map +1 -0
  214. package/dist/ui/overlays/index.js +56 -3
  215. package/dist/ui/renderers/index.d.ts +3 -3
  216. package/dist/ui/renderers/index.d.ts.map +1 -0
  217. package/dist/ui/renderers/index.js +827 -3
  218. package/dist/ui/renderers/pipeline.markdown.d.ts +12 -11
  219. package/dist/ui/renderers/pipeline.markdown.d.ts.map +1 -1
  220. package/dist/ui/renderers/pipeline.markdown.js +560 -114
  221. package/dist/ui/renderers/pipeline.renderer.d.ts +9 -7
  222. package/dist/ui/renderers/pipeline.renderer.d.ts.map +1 -1
  223. package/dist/ui/renderers/pipeline.renderer.js +261 -24
  224. package/package.json +476 -90
  225. package/tsdown.config.js +1 -2
  226. package/.turbo/turbo-build$colon$bundle.log +0 -164
  227. package/dist/crm-pipeline.feature.js.map +0 -1
  228. package/dist/deal/deal.enum.js.map +0 -1
  229. package/dist/deal/deal.operation.js.map +0 -1
  230. package/dist/deal/deal.schema.js.map +0 -1
  231. package/dist/deal/deal.test-spec.js.map +0 -1
  232. package/dist/docs/crm-pipeline.docblock.js.map +0 -1
  233. package/dist/entities/company.entity.js.map +0 -1
  234. package/dist/entities/contact.entity.js.map +0 -1
  235. package/dist/entities/deal.entity.js.map +0 -1
  236. package/dist/entities/index.js.map +0 -1
  237. package/dist/entities/task.entity.js.map +0 -1
  238. package/dist/events/contact.event.js.map +0 -1
  239. package/dist/events/deal.event.js.map +0 -1
  240. package/dist/events/task.event.js.map +0 -1
  241. package/dist/example.js.map +0 -1
  242. package/dist/handlers/crm.handlers.js.map +0 -1
  243. package/dist/handlers/deal.handlers.js.map +0 -1
  244. package/dist/handlers/mock-data.js.map +0 -1
  245. package/dist/index.js.map +0 -1
  246. package/dist/presentations/dashboard.presentation.js.map +0 -1
  247. package/dist/presentations/pipeline.presentation.js.map +0 -1
  248. package/dist/seeders/index.js.map +0 -1
  249. package/dist/ui/CrmDashboard.js.map +0 -1
  250. package/dist/ui/CrmDealCard.js.map +0 -1
  251. package/dist/ui/CrmPipelineBoard.js.map +0 -1
  252. package/dist/ui/hooks/useDealList.js.map +0 -1
  253. package/dist/ui/hooks/useDealMutations.js.map +0 -1
  254. package/dist/ui/modals/CreateDealModal.js.map +0 -1
  255. package/dist/ui/modals/DealActionsModal.js.map +0 -1
  256. package/dist/ui/overlays/demo-overlays.js.map +0 -1
  257. package/dist/ui/renderers/pipeline.markdown.js.map +0 -1
  258. package/dist/ui/renderers/pipeline.renderer.js.map +0 -1
  259. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,1325 @@
1
+ // src/ui/hooks/useDealList.ts
2
+ import { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
+ "use client";
5
+ function useDealList(options = {}) {
6
+ const { handlers, projectId } = useTemplateRuntime();
7
+ const { crm } = handlers;
8
+ const [data, setData] = useState(null);
9
+ const [dealsByStage, setDealsByStage] = useState({});
10
+ const [stages, setStages] = useState([]);
11
+ const [loading, setLoading] = useState(true);
12
+ const [error, setError] = useState(null);
13
+ const [page, setPage] = useState(1);
14
+ const pipelineId = options.pipelineId ?? "pipeline-1";
15
+ const fetchData = useCallback(async () => {
16
+ setLoading(true);
17
+ setError(null);
18
+ try {
19
+ const [dealsResult, stageDealsResult, stagesResult] = await Promise.all([
20
+ crm.listDeals({
21
+ projectId,
22
+ pipelineId,
23
+ stageId: options.stageId,
24
+ status: options.status === "all" ? undefined : options.status,
25
+ search: options.search,
26
+ limit: options.limit ?? 50,
27
+ offset: (page - 1) * (options.limit ?? 50)
28
+ }),
29
+ crm.getDealsByStage({ projectId, pipelineId }),
30
+ crm.getPipelineStages({ pipelineId })
31
+ ]);
32
+ setData(dealsResult);
33
+ setDealsByStage(stageDealsResult);
34
+ setStages(stagesResult);
35
+ } catch (err) {
36
+ setError(err instanceof Error ? err : new Error("Unknown error"));
37
+ } finally {
38
+ setLoading(false);
39
+ }
40
+ }, [
41
+ crm,
42
+ projectId,
43
+ pipelineId,
44
+ options.stageId,
45
+ options.status,
46
+ options.search,
47
+ options.limit,
48
+ page
49
+ ]);
50
+ useEffect(() => {
51
+ fetchData();
52
+ }, [fetchData]);
53
+ const stats = useMemo(() => {
54
+ if (!data)
55
+ return null;
56
+ const open = data.deals.filter((d) => d.status === "OPEN");
57
+ const won = data.deals.filter((d) => d.status === "WON");
58
+ const lost = data.deals.filter((d) => d.status === "LOST");
59
+ return {
60
+ total: data.total,
61
+ totalValue: data.totalValue,
62
+ openCount: open.length,
63
+ openValue: open.reduce((sum, d) => sum + d.value, 0),
64
+ wonCount: won.length,
65
+ wonValue: won.reduce((sum, d) => sum + d.value, 0),
66
+ lostCount: lost.length
67
+ };
68
+ }, [data]);
69
+ return {
70
+ data,
71
+ dealsByStage,
72
+ stages,
73
+ loading,
74
+ error,
75
+ stats,
76
+ page,
77
+ refetch: fetchData,
78
+ nextPage: () => setPage((p) => p + 1),
79
+ prevPage: () => page > 1 && setPage((p) => p - 1)
80
+ };
81
+ }
82
+
83
+ // src/ui/hooks/useDealMutations.ts
84
+ import { useCallback as useCallback2, useState as useState2 } from "react";
85
+ import { useTemplateRuntime as useTemplateRuntime2 } from "@contractspec/lib.example-shared-ui";
86
+ function useDealMutations(options = {}) {
87
+ const { handlers, projectId } = useTemplateRuntime2();
88
+ const { crm } = handlers;
89
+ const [createState, setCreateState] = useState2({
90
+ loading: false,
91
+ error: null,
92
+ data: null
93
+ });
94
+ const [moveState, setMoveState] = useState2({
95
+ loading: false,
96
+ error: null,
97
+ data: null
98
+ });
99
+ const [winState, setWinState] = useState2({
100
+ loading: false,
101
+ error: null,
102
+ data: null
103
+ });
104
+ const [loseState, setLoseState] = useState2({
105
+ loading: false,
106
+ error: null,
107
+ data: null
108
+ });
109
+ const createDeal = useCallback2(async (input) => {
110
+ setCreateState({ loading: true, error: null, data: null });
111
+ try {
112
+ const result = await crm.createDeal(input, {
113
+ projectId,
114
+ ownerId: "user-1"
115
+ });
116
+ setCreateState({ loading: false, error: null, data: result });
117
+ options.onSuccess?.();
118
+ return result;
119
+ } catch (err) {
120
+ const error = err instanceof Error ? err : new Error("Failed to create deal");
121
+ setCreateState({ loading: false, error, data: null });
122
+ options.onError?.(error);
123
+ return null;
124
+ }
125
+ }, [crm, projectId, options]);
126
+ const moveDeal = useCallback2(async (input) => {
127
+ setMoveState({ loading: true, error: null, data: null });
128
+ try {
129
+ const result = await crm.moveDeal(input);
130
+ setMoveState({ loading: false, error: null, data: result });
131
+ options.onSuccess?.();
132
+ return result;
133
+ } catch (err) {
134
+ const error = err instanceof Error ? err : new Error("Failed to move deal");
135
+ setMoveState({ loading: false, error, data: null });
136
+ options.onError?.(error);
137
+ return null;
138
+ }
139
+ }, [crm, options]);
140
+ const winDeal = useCallback2(async (input) => {
141
+ setWinState({ loading: true, error: null, data: null });
142
+ try {
143
+ const result = await crm.winDeal(input);
144
+ setWinState({ loading: false, error: null, data: result });
145
+ options.onSuccess?.();
146
+ return result;
147
+ } catch (err) {
148
+ const error = err instanceof Error ? err : new Error("Failed to mark deal as won");
149
+ setWinState({ loading: false, error, data: null });
150
+ options.onError?.(error);
151
+ return null;
152
+ }
153
+ }, [crm, options]);
154
+ const loseDeal = useCallback2(async (input) => {
155
+ setLoseState({ loading: true, error: null, data: null });
156
+ try {
157
+ const result = await crm.loseDeal(input);
158
+ setLoseState({ loading: false, error: null, data: result });
159
+ options.onSuccess?.();
160
+ return result;
161
+ } catch (err) {
162
+ const error = err instanceof Error ? err : new Error("Failed to mark deal as lost");
163
+ setLoseState({ loading: false, error, data: null });
164
+ options.onError?.(error);
165
+ return null;
166
+ }
167
+ }, [crm, options]);
168
+ return {
169
+ createDeal,
170
+ moveDeal,
171
+ winDeal,
172
+ loseDeal,
173
+ createState,
174
+ moveState,
175
+ winState,
176
+ loseState,
177
+ isLoading: createState.loading || moveState.loading || winState.loading || loseState.loading
178
+ };
179
+ }
180
+
181
+ // src/ui/CrmDealCard.tsx
182
+ import { jsxDEV } from "react/jsx-dev-runtime";
183
+ "use client";
184
+ function formatCurrency(value, currency) {
185
+ return new Intl.NumberFormat("en-US", {
186
+ style: "currency",
187
+ currency,
188
+ minimumFractionDigits: 0,
189
+ maximumFractionDigits: 0
190
+ }).format(value);
191
+ }
192
+ function CrmDealCard({ deal, onClick }) {
193
+ const daysUntilClose = deal.expectedCloseDate ? Math.ceil((deal.expectedCloseDate.getTime() - Date.now()) / (1000 * 60 * 60 * 24)) : null;
194
+ return /* @__PURE__ */ jsxDEV("div", {
195
+ onClick,
196
+ className: "border-border bg-card cursor-pointer rounded-lg border p-3 shadow-sm transition-shadow hover:shadow-md",
197
+ role: "button",
198
+ tabIndex: 0,
199
+ onKeyDown: (e) => {
200
+ if (e.key === "Enter" || e.key === " ")
201
+ onClick?.();
202
+ },
203
+ children: [
204
+ /* @__PURE__ */ jsxDEV("h4", {
205
+ className: "leading-snug font-medium",
206
+ children: deal.name
207
+ }, undefined, false, undefined, this),
208
+ /* @__PURE__ */ jsxDEV("div", {
209
+ className: "text-primary mt-2 text-lg font-semibold",
210
+ children: formatCurrency(deal.value, deal.currency)
211
+ }, undefined, false, undefined, this),
212
+ /* @__PURE__ */ jsxDEV("div", {
213
+ className: "text-muted-foreground mt-3 flex items-center justify-between text-xs",
214
+ children: [
215
+ daysUntilClose !== null && /* @__PURE__ */ jsxDEV("span", {
216
+ className: daysUntilClose < 0 ? "text-red-500" : daysUntilClose <= 7 ? "text-yellow-600 dark:text-yellow-500" : "",
217
+ children: daysUntilClose < 0 ? `${Math.abs(daysUntilClose)}d overdue` : daysUntilClose === 0 ? "Due today" : `${daysUntilClose}d left`
218
+ }, undefined, false, undefined, this),
219
+ /* @__PURE__ */ jsxDEV("span", {
220
+ className: `rounded px-1.5 py-0.5 text-xs font-medium ${deal.status === "WON" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : deal.status === "LOST" ? "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400" : "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"}`,
221
+ children: deal.status
222
+ }, undefined, false, undefined, this)
223
+ ]
224
+ }, undefined, true, undefined, this)
225
+ ]
226
+ }, undefined, true, undefined, this);
227
+ }
228
+
229
+ // src/ui/CrmPipelineBoard.tsx
230
+ import { useState as useState3 } from "react";
231
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
232
+ "use client";
233
+ function formatCurrency2(value) {
234
+ if (value >= 1e6)
235
+ return `$${(value / 1e6).toFixed(1)}M`;
236
+ if (value >= 1000)
237
+ return `$${(value / 1000).toFixed(0)}K`;
238
+ return `$${value}`;
239
+ }
240
+ function CrmPipelineBoard({
241
+ dealsByStage,
242
+ stages,
243
+ onDealClick,
244
+ onDealMove
245
+ }) {
246
+ const [quickMoveOpen, setQuickMoveOpen] = useState3(null);
247
+ const sortedStages = [...stages].sort((a, b) => a.position - b.position);
248
+ const handleQuickMove = (dealId, toStageId) => {
249
+ onDealMove?.(dealId, toStageId);
250
+ setQuickMoveOpen(null);
251
+ };
252
+ return /* @__PURE__ */ jsxDEV2("div", {
253
+ className: "flex gap-4 overflow-x-auto pb-4",
254
+ children: sortedStages.map((stage) => {
255
+ const deals = dealsByStage[stage.id] ?? [];
256
+ const stageValue = deals.reduce((sum, d) => sum + d.value, 0);
257
+ return /* @__PURE__ */ jsxDEV2("div", {
258
+ className: "bg-muted/30 flex w-72 flex-shrink-0 flex-col rounded-lg",
259
+ children: [
260
+ /* @__PURE__ */ jsxDEV2("div", {
261
+ className: "border-border flex items-center justify-between border-b px-3 py-2",
262
+ children: [
263
+ /* @__PURE__ */ jsxDEV2("div", {
264
+ children: [
265
+ /* @__PURE__ */ jsxDEV2("h3", {
266
+ className: "font-medium",
267
+ children: stage.name
268
+ }, undefined, false, undefined, this),
269
+ /* @__PURE__ */ jsxDEV2("p", {
270
+ className: "text-muted-foreground text-xs",
271
+ children: [
272
+ deals.length,
273
+ " deals · ",
274
+ formatCurrency2(stageValue)
275
+ ]
276
+ }, undefined, true, undefined, this)
277
+ ]
278
+ }, undefined, true, undefined, this),
279
+ /* @__PURE__ */ jsxDEV2("span", {
280
+ className: "bg-muted flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium",
281
+ children: deals.length
282
+ }, undefined, false, undefined, this)
283
+ ]
284
+ }, undefined, true, undefined, this),
285
+ /* @__PURE__ */ jsxDEV2("div", {
286
+ className: "flex flex-1 flex-col gap-2 p-2",
287
+ children: deals.length === 0 ? /* @__PURE__ */ jsxDEV2("div", {
288
+ className: "border-muted-foreground/20 text-muted-foreground flex h-24 items-center justify-center rounded-md border-2 border-dashed text-xs",
289
+ children: "No deals"
290
+ }, undefined, false, undefined, this) : deals.map((deal) => /* @__PURE__ */ jsxDEV2("div", {
291
+ className: "group relative",
292
+ children: [
293
+ /* @__PURE__ */ jsxDEV2(CrmDealCard, {
294
+ deal,
295
+ onClick: () => onDealClick?.(deal.id)
296
+ }, undefined, false, undefined, this),
297
+ deal.status === "OPEN" && onDealMove && /* @__PURE__ */ jsxDEV2("div", {
298
+ className: "absolute top-1 right-1 opacity-0 transition-opacity group-hover:opacity-100",
299
+ children: [
300
+ /* @__PURE__ */ jsxDEV2("button", {
301
+ type: "button",
302
+ onClick: (e) => {
303
+ e.stopPropagation();
304
+ setQuickMoveOpen(quickMoveOpen === deal.id ? null : deal.id);
305
+ },
306
+ className: "bg-background border-border hover:bg-muted flex h-6 w-6 items-center justify-center rounded border text-xs shadow-sm",
307
+ title: "Quick move",
308
+ children: "➡️"
309
+ }, undefined, false, undefined, this),
310
+ quickMoveOpen === deal.id && /* @__PURE__ */ jsxDEV2("div", {
311
+ className: "bg-card border-border absolute top-7 right-0 z-20 min-w-[140px] rounded-lg border py-1 shadow-lg",
312
+ children: [
313
+ /* @__PURE__ */ jsxDEV2("p", {
314
+ className: "text-muted-foreground px-3 py-1 text-xs font-medium",
315
+ children: "Move to:"
316
+ }, undefined, false, undefined, this),
317
+ sortedStages.filter((s) => s.id !== deal.stageId).map((s) => /* @__PURE__ */ jsxDEV2("button", {
318
+ type: "button",
319
+ onClick: (e) => {
320
+ e.stopPropagation();
321
+ handleQuickMove(deal.id, s.id);
322
+ },
323
+ className: "hover:bg-muted w-full px-3 py-1.5 text-left text-sm",
324
+ children: s.name
325
+ }, s.id, false, undefined, this))
326
+ ]
327
+ }, undefined, true, undefined, this)
328
+ ]
329
+ }, undefined, true, undefined, this)
330
+ ]
331
+ }, deal.id, true, undefined, this))
332
+ }, undefined, false, undefined, this)
333
+ ]
334
+ }, stage.id, true, undefined, this);
335
+ })
336
+ }, undefined, false, undefined, this);
337
+ }
338
+
339
+ // src/ui/modals/CreateDealModal.tsx
340
+ import { useState as useState4 } from "react";
341
+ import { Button, Input } from "@contractspec/lib.design-system";
342
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
343
+ "use client";
344
+ var CURRENCIES = ["USD", "EUR", "GBP", "CAD"];
345
+ var DEFAULT_PIPELINE_ID = "pipeline-1";
346
+ function CreateDealModal({
347
+ isOpen,
348
+ onClose,
349
+ onSubmit,
350
+ stages,
351
+ isLoading = false
352
+ }) {
353
+ const [name, setName] = useState4("");
354
+ const [value, setValue] = useState4("");
355
+ const [currency, setCurrency] = useState4("USD");
356
+ const [stageId, setStageId] = useState4(stages[0]?.id ?? "");
357
+ const [expectedCloseDate, setExpectedCloseDate] = useState4("");
358
+ const [error, setError] = useState4(null);
359
+ const handleSubmit = async (e) => {
360
+ e.preventDefault();
361
+ setError(null);
362
+ if (!name.trim()) {
363
+ setError("Deal name is required");
364
+ return;
365
+ }
366
+ const numericValue = parseFloat(value);
367
+ if (isNaN(numericValue) || numericValue <= 0) {
368
+ setError("Value must be a positive number");
369
+ return;
370
+ }
371
+ if (!stageId) {
372
+ setError("Please select a pipeline stage");
373
+ return;
374
+ }
375
+ try {
376
+ await onSubmit({
377
+ name: name.trim(),
378
+ value: numericValue,
379
+ currency,
380
+ pipelineId: DEFAULT_PIPELINE_ID,
381
+ stageId,
382
+ expectedCloseDate: expectedCloseDate ? new Date(expectedCloseDate) : undefined
383
+ });
384
+ setName("");
385
+ setValue("");
386
+ setCurrency("USD");
387
+ setStageId(stages[0]?.id ?? "");
388
+ setExpectedCloseDate("");
389
+ onClose();
390
+ } catch (err) {
391
+ setError(err instanceof Error ? err.message : "Failed to create deal");
392
+ }
393
+ };
394
+ if (!isOpen)
395
+ return null;
396
+ return /* @__PURE__ */ jsxDEV3("div", {
397
+ className: "fixed inset-0 z-50 flex items-center justify-center",
398
+ children: [
399
+ /* @__PURE__ */ jsxDEV3("div", {
400
+ className: "bg-background/80 absolute inset-0 backdrop-blur-sm",
401
+ onClick: onClose,
402
+ role: "button",
403
+ tabIndex: 0,
404
+ onKeyDown: (e) => {
405
+ if (e.key === "Enter" || e.key === " ")
406
+ onClose();
407
+ },
408
+ "aria-label": "Close modal"
409
+ }, undefined, false, undefined, this),
410
+ /* @__PURE__ */ jsxDEV3("div", {
411
+ className: "bg-card border-border relative z-10 w-full max-w-md rounded-xl border p-6 shadow-xl",
412
+ children: [
413
+ /* @__PURE__ */ jsxDEV3("h2", {
414
+ className: "mb-4 text-xl font-semibold",
415
+ children: "Create New Deal"
416
+ }, undefined, false, undefined, this),
417
+ /* @__PURE__ */ jsxDEV3("form", {
418
+ onSubmit: handleSubmit,
419
+ className: "space-y-4",
420
+ children: [
421
+ /* @__PURE__ */ jsxDEV3("div", {
422
+ children: [
423
+ /* @__PURE__ */ jsxDEV3("label", {
424
+ htmlFor: "deal-name",
425
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
426
+ children: "Deal Name *"
427
+ }, undefined, false, undefined, this),
428
+ /* @__PURE__ */ jsxDEV3(Input, {
429
+ id: "deal-name",
430
+ value: name,
431
+ onChange: (e) => setName(e.target.value),
432
+ placeholder: "e.g., Enterprise License - Acme Corp",
433
+ disabled: isLoading
434
+ }, undefined, false, undefined, this)
435
+ ]
436
+ }, undefined, true, undefined, this),
437
+ /* @__PURE__ */ jsxDEV3("div", {
438
+ className: "flex gap-3",
439
+ children: [
440
+ /* @__PURE__ */ jsxDEV3("div", {
441
+ className: "flex-1",
442
+ children: [
443
+ /* @__PURE__ */ jsxDEV3("label", {
444
+ htmlFor: "deal-value",
445
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
446
+ children: "Value *"
447
+ }, undefined, false, undefined, this),
448
+ /* @__PURE__ */ jsxDEV3(Input, {
449
+ id: "deal-value",
450
+ type: "number",
451
+ min: "0",
452
+ step: "0.01",
453
+ value,
454
+ onChange: (e) => setValue(e.target.value),
455
+ placeholder: "50000",
456
+ disabled: isLoading
457
+ }, undefined, false, undefined, this)
458
+ ]
459
+ }, undefined, true, undefined, this),
460
+ /* @__PURE__ */ jsxDEV3("div", {
461
+ className: "w-24",
462
+ children: [
463
+ /* @__PURE__ */ jsxDEV3("label", {
464
+ htmlFor: "deal-currency",
465
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
466
+ children: "Currency"
467
+ }, undefined, false, undefined, this),
468
+ /* @__PURE__ */ jsxDEV3("select", {
469
+ id: "deal-currency",
470
+ value: currency,
471
+ onChange: (e) => setCurrency(e.target.value),
472
+ disabled: isLoading,
473
+ className: "border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none disabled:opacity-50",
474
+ children: CURRENCIES.map((c) => /* @__PURE__ */ jsxDEV3("option", {
475
+ value: c,
476
+ children: c
477
+ }, c, false, undefined, this))
478
+ }, undefined, false, undefined, this)
479
+ ]
480
+ }, undefined, true, undefined, this)
481
+ ]
482
+ }, undefined, true, undefined, this),
483
+ /* @__PURE__ */ jsxDEV3("div", {
484
+ children: [
485
+ /* @__PURE__ */ jsxDEV3("label", {
486
+ htmlFor: "deal-stage",
487
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
488
+ children: "Pipeline Stage *"
489
+ }, undefined, false, undefined, this),
490
+ /* @__PURE__ */ jsxDEV3("select", {
491
+ id: "deal-stage",
492
+ value: stageId,
493
+ onChange: (e) => setStageId(e.target.value),
494
+ disabled: isLoading,
495
+ className: "border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none disabled:opacity-50",
496
+ children: stages.map((stage) => /* @__PURE__ */ jsxDEV3("option", {
497
+ value: stage.id,
498
+ children: stage.name
499
+ }, stage.id, false, undefined, this))
500
+ }, undefined, false, undefined, this)
501
+ ]
502
+ }, undefined, true, undefined, this),
503
+ /* @__PURE__ */ jsxDEV3("div", {
504
+ children: [
505
+ /* @__PURE__ */ jsxDEV3("label", {
506
+ htmlFor: "deal-close-date",
507
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
508
+ children: "Expected Close Date"
509
+ }, undefined, false, undefined, this),
510
+ /* @__PURE__ */ jsxDEV3(Input, {
511
+ id: "deal-close-date",
512
+ type: "date",
513
+ value: expectedCloseDate,
514
+ onChange: (e) => setExpectedCloseDate(e.target.value),
515
+ disabled: isLoading
516
+ }, undefined, false, undefined, this)
517
+ ]
518
+ }, undefined, true, undefined, this),
519
+ error && /* @__PURE__ */ jsxDEV3("div", {
520
+ className: "bg-destructive/10 text-destructive rounded-md p-3 text-sm",
521
+ children: error
522
+ }, undefined, false, undefined, this),
523
+ /* @__PURE__ */ jsxDEV3("div", {
524
+ className: "flex justify-end gap-3 pt-2",
525
+ children: [
526
+ /* @__PURE__ */ jsxDEV3(Button, {
527
+ type: "button",
528
+ variant: "ghost",
529
+ onPress: onClose,
530
+ disabled: isLoading,
531
+ children: "Cancel"
532
+ }, undefined, false, undefined, this),
533
+ /* @__PURE__ */ jsxDEV3(Button, {
534
+ type: "submit",
535
+ disabled: isLoading,
536
+ children: isLoading ? "Creating..." : "Create Deal"
537
+ }, undefined, false, undefined, this)
538
+ ]
539
+ }, undefined, true, undefined, this)
540
+ ]
541
+ }, undefined, true, undefined, this)
542
+ ]
543
+ }, undefined, true, undefined, this)
544
+ ]
545
+ }, undefined, true, undefined, this);
546
+ }
547
+
548
+ // src/ui/modals/DealActionsModal.tsx
549
+ import { useState as useState5 } from "react";
550
+ import { Button as Button2 } from "@contractspec/lib.design-system";
551
+ import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
552
+ "use client";
553
+ function formatCurrency3(value, currency) {
554
+ return new Intl.NumberFormat("en-US", {
555
+ style: "currency",
556
+ currency,
557
+ minimumFractionDigits: 0,
558
+ maximumFractionDigits: 0
559
+ }).format(value);
560
+ }
561
+ function DealActionsModal({
562
+ isOpen,
563
+ deal,
564
+ stages,
565
+ onClose,
566
+ onWin,
567
+ onLose,
568
+ onMove,
569
+ isLoading = false
570
+ }) {
571
+ const [mode, setMode] = useState5("menu");
572
+ const [wonSource, setWonSource] = useState5("");
573
+ const [lostReason, setLostReason] = useState5("");
574
+ const [notes, setNotes] = useState5("");
575
+ const [selectedStageId, setSelectedStageId] = useState5("");
576
+ const [error, setError] = useState5(null);
577
+ const resetForm = () => {
578
+ setMode("menu");
579
+ setWonSource("");
580
+ setLostReason("");
581
+ setNotes("");
582
+ setSelectedStageId("");
583
+ setError(null);
584
+ };
585
+ const handleClose = () => {
586
+ resetForm();
587
+ onClose();
588
+ };
589
+ const handleWin = async () => {
590
+ if (!deal)
591
+ return;
592
+ setError(null);
593
+ try {
594
+ await onWin({
595
+ dealId: deal.id,
596
+ wonSource: wonSource.trim() || undefined,
597
+ notes: notes.trim() || undefined
598
+ });
599
+ handleClose();
600
+ } catch (err) {
601
+ setError(err instanceof Error ? err.message : "Failed to mark deal as won");
602
+ }
603
+ };
604
+ const handleLose = async () => {
605
+ if (!deal)
606
+ return;
607
+ setError(null);
608
+ if (!lostReason.trim()) {
609
+ setError("Please provide a reason for losing the deal");
610
+ return;
611
+ }
612
+ try {
613
+ await onLose({
614
+ dealId: deal.id,
615
+ lostReason: lostReason.trim(),
616
+ notes: notes.trim() || undefined
617
+ });
618
+ handleClose();
619
+ } catch (err) {
620
+ setError(err instanceof Error ? err.message : "Failed to mark deal as lost");
621
+ }
622
+ };
623
+ const handleMove = async () => {
624
+ if (!deal)
625
+ return;
626
+ setError(null);
627
+ if (!selectedStageId) {
628
+ setError("Please select a stage");
629
+ return;
630
+ }
631
+ if (selectedStageId === deal.stageId) {
632
+ setError("Deal is already in this stage");
633
+ return;
634
+ }
635
+ try {
636
+ await onMove({
637
+ dealId: deal.id,
638
+ stageId: selectedStageId
639
+ });
640
+ handleClose();
641
+ } catch (err) {
642
+ setError(err instanceof Error ? err.message : "Failed to move deal");
643
+ }
644
+ };
645
+ if (!isOpen || !deal)
646
+ return null;
647
+ return /* @__PURE__ */ jsxDEV4("div", {
648
+ className: "fixed inset-0 z-50 flex items-center justify-center",
649
+ children: [
650
+ /* @__PURE__ */ jsxDEV4("div", {
651
+ className: "bg-background/80 absolute inset-0 backdrop-blur-sm",
652
+ onClick: handleClose,
653
+ role: "button",
654
+ tabIndex: 0,
655
+ onKeyDown: (e) => {
656
+ if (e.key === "Enter" || e.key === " ")
657
+ handleClose();
658
+ },
659
+ "aria-label": "Close modal"
660
+ }, undefined, false, undefined, this),
661
+ /* @__PURE__ */ jsxDEV4("div", {
662
+ className: "bg-card border-border relative z-10 w-full max-w-md rounded-xl border p-6 shadow-xl",
663
+ children: [
664
+ /* @__PURE__ */ jsxDEV4("div", {
665
+ className: "border-border mb-4 border-b pb-4",
666
+ children: [
667
+ /* @__PURE__ */ jsxDEV4("h2", {
668
+ className: "text-xl font-semibold",
669
+ children: deal.name
670
+ }, undefined, false, undefined, this),
671
+ /* @__PURE__ */ jsxDEV4("p", {
672
+ className: "text-primary text-lg font-medium",
673
+ children: formatCurrency3(deal.value, deal.currency)
674
+ }, undefined, false, undefined, this),
675
+ /* @__PURE__ */ jsxDEV4("span", {
676
+ className: `mt-2 inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${deal.status === "WON" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : deal.status === "LOST" ? "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400" : "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"}`,
677
+ children: deal.status
678
+ }, undefined, false, undefined, this)
679
+ ]
680
+ }, undefined, true, undefined, this),
681
+ mode === "menu" && /* @__PURE__ */ jsxDEV4("div", {
682
+ className: "space-y-3",
683
+ children: [
684
+ deal.status === "OPEN" && /* @__PURE__ */ jsxDEV4(Fragment, {
685
+ children: [
686
+ /* @__PURE__ */ jsxDEV4(Button2, {
687
+ className: "w-full justify-start",
688
+ variant: "ghost",
689
+ onPress: () => setMode("win"),
690
+ children: [
691
+ /* @__PURE__ */ jsxDEV4("span", {
692
+ className: "mr-2",
693
+ children: "\uD83C\uDFC6"
694
+ }, undefined, false, undefined, this),
695
+ " Mark as Won"
696
+ ]
697
+ }, undefined, true, undefined, this),
698
+ /* @__PURE__ */ jsxDEV4(Button2, {
699
+ className: "w-full justify-start",
700
+ variant: "ghost",
701
+ onPress: () => setMode("lose"),
702
+ children: [
703
+ /* @__PURE__ */ jsxDEV4("span", {
704
+ className: "mr-2",
705
+ children: "❌"
706
+ }, undefined, false, undefined, this),
707
+ " Mark as Lost"
708
+ ]
709
+ }, undefined, true, undefined, this),
710
+ /* @__PURE__ */ jsxDEV4(Button2, {
711
+ className: "w-full justify-start",
712
+ variant: "ghost",
713
+ onPress: () => {
714
+ setSelectedStageId(deal.stageId);
715
+ setMode("move");
716
+ },
717
+ children: [
718
+ /* @__PURE__ */ jsxDEV4("span", {
719
+ className: "mr-2",
720
+ children: "➡️"
721
+ }, undefined, false, undefined, this),
722
+ " Move to Stage"
723
+ ]
724
+ }, undefined, true, undefined, this)
725
+ ]
726
+ }, undefined, true, undefined, this),
727
+ deal.status !== "OPEN" && /* @__PURE__ */ jsxDEV4("p", {
728
+ className: "text-muted-foreground py-4 text-center",
729
+ children: [
730
+ "This deal is already ",
731
+ deal.status.toLowerCase(),
732
+ ". No actions available."
733
+ ]
734
+ }, undefined, true, undefined, this),
735
+ /* @__PURE__ */ jsxDEV4("div", {
736
+ className: "border-border border-t pt-3",
737
+ children: /* @__PURE__ */ jsxDEV4(Button2, {
738
+ className: "w-full",
739
+ variant: "outline",
740
+ onPress: handleClose,
741
+ children: "Close"
742
+ }, undefined, false, undefined, this)
743
+ }, undefined, false, undefined, this)
744
+ ]
745
+ }, undefined, true, undefined, this),
746
+ mode === "win" && /* @__PURE__ */ jsxDEV4("div", {
747
+ className: "space-y-4",
748
+ children: [
749
+ /* @__PURE__ */ jsxDEV4("div", {
750
+ children: [
751
+ /* @__PURE__ */ jsxDEV4("label", {
752
+ htmlFor: "won-source",
753
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
754
+ children: "How did you win this deal?"
755
+ }, undefined, false, undefined, this),
756
+ /* @__PURE__ */ jsxDEV4("select", {
757
+ id: "won-source",
758
+ value: wonSource,
759
+ onChange: (e) => setWonSource(e.target.value),
760
+ className: "border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none",
761
+ children: [
762
+ /* @__PURE__ */ jsxDEV4("option", {
763
+ value: "",
764
+ children: "Select a source..."
765
+ }, undefined, false, undefined, this),
766
+ /* @__PURE__ */ jsxDEV4("option", {
767
+ value: "referral",
768
+ children: "Referral"
769
+ }, undefined, false, undefined, this),
770
+ /* @__PURE__ */ jsxDEV4("option", {
771
+ value: "cold_outreach",
772
+ children: "Cold Outreach"
773
+ }, undefined, false, undefined, this),
774
+ /* @__PURE__ */ jsxDEV4("option", {
775
+ value: "inbound",
776
+ children: "Inbound Lead"
777
+ }, undefined, false, undefined, this),
778
+ /* @__PURE__ */ jsxDEV4("option", {
779
+ value: "upsell",
780
+ children: "Upsell"
781
+ }, undefined, false, undefined, this),
782
+ /* @__PURE__ */ jsxDEV4("option", {
783
+ value: "other",
784
+ children: "Other"
785
+ }, undefined, false, undefined, this)
786
+ ]
787
+ }, undefined, true, undefined, this)
788
+ ]
789
+ }, undefined, true, undefined, this),
790
+ /* @__PURE__ */ jsxDEV4("div", {
791
+ children: [
792
+ /* @__PURE__ */ jsxDEV4("label", {
793
+ htmlFor: "win-notes",
794
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
795
+ children: "Notes (optional)"
796
+ }, undefined, false, undefined, this),
797
+ /* @__PURE__ */ jsxDEV4("textarea", {
798
+ id: "win-notes",
799
+ value: notes,
800
+ onChange: (e) => setNotes(e.target.value),
801
+ placeholder: "Any additional notes about the win...",
802
+ rows: 3,
803
+ className: "border-input bg-background focus:ring-ring w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none"
804
+ }, undefined, false, undefined, this)
805
+ ]
806
+ }, undefined, true, undefined, this),
807
+ error && /* @__PURE__ */ jsxDEV4("div", {
808
+ className: "bg-destructive/10 text-destructive rounded-md p-3 text-sm",
809
+ children: error
810
+ }, undefined, false, undefined, this),
811
+ /* @__PURE__ */ jsxDEV4("div", {
812
+ className: "flex justify-end gap-3 pt-2",
813
+ children: [
814
+ /* @__PURE__ */ jsxDEV4(Button2, {
815
+ variant: "ghost",
816
+ onPress: () => setMode("menu"),
817
+ disabled: isLoading,
818
+ children: "Back"
819
+ }, undefined, false, undefined, this),
820
+ /* @__PURE__ */ jsxDEV4(Button2, {
821
+ onPress: handleWin,
822
+ disabled: isLoading,
823
+ children: isLoading ? "Processing..." : "\uD83C\uDFC6 Confirm Win"
824
+ }, undefined, false, undefined, this)
825
+ ]
826
+ }, undefined, true, undefined, this)
827
+ ]
828
+ }, undefined, true, undefined, this),
829
+ mode === "lose" && /* @__PURE__ */ jsxDEV4("div", {
830
+ className: "space-y-4",
831
+ children: [
832
+ /* @__PURE__ */ jsxDEV4("div", {
833
+ children: [
834
+ /* @__PURE__ */ jsxDEV4("label", {
835
+ htmlFor: "lost-reason",
836
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
837
+ children: "Why was this deal lost? *"
838
+ }, undefined, false, undefined, this),
839
+ /* @__PURE__ */ jsxDEV4("select", {
840
+ id: "lost-reason",
841
+ value: lostReason,
842
+ onChange: (e) => setLostReason(e.target.value),
843
+ className: "border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none",
844
+ children: [
845
+ /* @__PURE__ */ jsxDEV4("option", {
846
+ value: "",
847
+ children: "Select a reason..."
848
+ }, undefined, false, undefined, this),
849
+ /* @__PURE__ */ jsxDEV4("option", {
850
+ value: "price",
851
+ children: "Price too high"
852
+ }, undefined, false, undefined, this),
853
+ /* @__PURE__ */ jsxDEV4("option", {
854
+ value: "competitor",
855
+ children: "Lost to competitor"
856
+ }, undefined, false, undefined, this),
857
+ /* @__PURE__ */ jsxDEV4("option", {
858
+ value: "no_budget",
859
+ children: "No budget"
860
+ }, undefined, false, undefined, this),
861
+ /* @__PURE__ */ jsxDEV4("option", {
862
+ value: "no_decision",
863
+ children: "No decision made"
864
+ }, undefined, false, undefined, this),
865
+ /* @__PURE__ */ jsxDEV4("option", {
866
+ value: "timing",
867
+ children: "Bad timing"
868
+ }, undefined, false, undefined, this),
869
+ /* @__PURE__ */ jsxDEV4("option", {
870
+ value: "product_fit",
871
+ children: "Product not a fit"
872
+ }, undefined, false, undefined, this),
873
+ /* @__PURE__ */ jsxDEV4("option", {
874
+ value: "other",
875
+ children: "Other"
876
+ }, undefined, false, undefined, this)
877
+ ]
878
+ }, undefined, true, undefined, this)
879
+ ]
880
+ }, undefined, true, undefined, this),
881
+ /* @__PURE__ */ jsxDEV4("div", {
882
+ children: [
883
+ /* @__PURE__ */ jsxDEV4("label", {
884
+ htmlFor: "lose-notes",
885
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
886
+ children: "Notes (optional)"
887
+ }, undefined, false, undefined, this),
888
+ /* @__PURE__ */ jsxDEV4("textarea", {
889
+ id: "lose-notes",
890
+ value: notes,
891
+ onChange: (e) => setNotes(e.target.value),
892
+ placeholder: "Any additional details...",
893
+ rows: 3,
894
+ className: "border-input bg-background focus:ring-ring w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none"
895
+ }, undefined, false, undefined, this)
896
+ ]
897
+ }, undefined, true, undefined, this),
898
+ error && /* @__PURE__ */ jsxDEV4("div", {
899
+ className: "bg-destructive/10 text-destructive rounded-md p-3 text-sm",
900
+ children: error
901
+ }, undefined, false, undefined, this),
902
+ /* @__PURE__ */ jsxDEV4("div", {
903
+ className: "flex justify-end gap-3 pt-2",
904
+ children: [
905
+ /* @__PURE__ */ jsxDEV4(Button2, {
906
+ variant: "ghost",
907
+ onPress: () => setMode("menu"),
908
+ disabled: isLoading,
909
+ children: "Back"
910
+ }, undefined, false, undefined, this),
911
+ /* @__PURE__ */ jsxDEV4(Button2, {
912
+ variant: "destructive",
913
+ onPress: handleLose,
914
+ disabled: isLoading,
915
+ children: isLoading ? "Processing..." : "❌ Confirm Loss"
916
+ }, undefined, false, undefined, this)
917
+ ]
918
+ }, undefined, true, undefined, this)
919
+ ]
920
+ }, undefined, true, undefined, this),
921
+ mode === "move" && /* @__PURE__ */ jsxDEV4("div", {
922
+ className: "space-y-4",
923
+ children: [
924
+ /* @__PURE__ */ jsxDEV4("div", {
925
+ children: [
926
+ /* @__PURE__ */ jsxDEV4("label", {
927
+ htmlFor: "move-stage",
928
+ className: "text-muted-foreground mb-1 block text-sm font-medium",
929
+ children: "Move to Stage"
930
+ }, undefined, false, undefined, this),
931
+ /* @__PURE__ */ jsxDEV4("select", {
932
+ id: "move-stage",
933
+ value: selectedStageId,
934
+ onChange: (e) => setSelectedStageId(e.target.value),
935
+ className: "border-input bg-background focus:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus:ring-2 focus:outline-none",
936
+ children: stages.map((stage) => /* @__PURE__ */ jsxDEV4("option", {
937
+ value: stage.id,
938
+ children: [
939
+ stage.name,
940
+ stage.id === deal.stageId ? " (current)" : ""
941
+ ]
942
+ }, stage.id, true, undefined, this))
943
+ }, undefined, false, undefined, this)
944
+ ]
945
+ }, undefined, true, undefined, this),
946
+ error && /* @__PURE__ */ jsxDEV4("div", {
947
+ className: "bg-destructive/10 text-destructive rounded-md p-3 text-sm",
948
+ children: error
949
+ }, undefined, false, undefined, this),
950
+ /* @__PURE__ */ jsxDEV4("div", {
951
+ className: "flex justify-end gap-3 pt-2",
952
+ children: [
953
+ /* @__PURE__ */ jsxDEV4(Button2, {
954
+ variant: "ghost",
955
+ onPress: () => setMode("menu"),
956
+ disabled: isLoading,
957
+ children: "Back"
958
+ }, undefined, false, undefined, this),
959
+ /* @__PURE__ */ jsxDEV4(Button2, {
960
+ onPress: handleMove,
961
+ disabled: isLoading,
962
+ children: isLoading ? "Moving..." : "➡️ Move Deal"
963
+ }, undefined, false, undefined, this)
964
+ ]
965
+ }, undefined, true, undefined, this)
966
+ ]
967
+ }, undefined, true, undefined, this)
968
+ ]
969
+ }, undefined, true, undefined, this)
970
+ ]
971
+ }, undefined, true, undefined, this);
972
+ }
973
+
974
+ // src/ui/CrmDashboard.tsx
975
+ import { useCallback as useCallback3, useState as useState6 } from "react";
976
+ import {
977
+ Button as Button3,
978
+ ErrorState,
979
+ LoaderBlock,
980
+ StatCard,
981
+ StatCardGroup
982
+ } from "@contractspec/lib.design-system";
983
+ import {
984
+ Tabs,
985
+ TabsContent,
986
+ TabsList,
987
+ TabsTrigger
988
+ } from "@contractspec/lib.ui-kit-web/ui/tabs";
989
+ import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
990
+ "use client";
991
+ function formatCurrency4(value, currency = "USD") {
992
+ return new Intl.NumberFormat("en-US", {
993
+ style: "currency",
994
+ currency,
995
+ minimumFractionDigits: 0,
996
+ maximumFractionDigits: 0
997
+ }).format(value);
998
+ }
999
+ function CrmDashboard() {
1000
+ const [isCreateModalOpen, setIsCreateModalOpen] = useState6(false);
1001
+ const [selectedDeal, setSelectedDeal] = useState6(null);
1002
+ const [isDealActionsOpen, setIsDealActionsOpen] = useState6(false);
1003
+ const { data, dealsByStage, stages, loading, error, stats, refetch } = useDealList();
1004
+ const mutations = useDealMutations({
1005
+ onSuccess: () => {
1006
+ refetch();
1007
+ }
1008
+ });
1009
+ const handleDealClick = useCallback3((dealId) => {
1010
+ const deal = dealsByStage ? Object.values(dealsByStage).flat().find((d) => d.id === dealId) : null;
1011
+ if (deal) {
1012
+ setSelectedDeal(deal);
1013
+ setIsDealActionsOpen(true);
1014
+ }
1015
+ }, [dealsByStage]);
1016
+ const handleDealMove = useCallback3(async (dealId, toStageId) => {
1017
+ await mutations.moveDeal({ dealId, stageId: toStageId });
1018
+ }, [mutations]);
1019
+ if (loading && !data) {
1020
+ return /* @__PURE__ */ jsxDEV5(LoaderBlock, {
1021
+ label: "Loading CRM..."
1022
+ }, undefined, false, undefined, this);
1023
+ }
1024
+ if (error) {
1025
+ return /* @__PURE__ */ jsxDEV5(ErrorState, {
1026
+ title: "Failed to load CRM",
1027
+ description: error.message,
1028
+ onRetry: refetch,
1029
+ retryLabel: "Retry"
1030
+ }, undefined, false, undefined, this);
1031
+ }
1032
+ return /* @__PURE__ */ jsxDEV5("div", {
1033
+ className: "space-y-6",
1034
+ children: [
1035
+ /* @__PURE__ */ jsxDEV5("div", {
1036
+ className: "flex items-center justify-between",
1037
+ children: [
1038
+ /* @__PURE__ */ jsxDEV5("h2", {
1039
+ className: "text-2xl font-bold",
1040
+ children: "CRM Pipeline"
1041
+ }, undefined, false, undefined, this),
1042
+ /* @__PURE__ */ jsxDEV5(Button3, {
1043
+ onClick: () => setIsCreateModalOpen(true),
1044
+ children: [
1045
+ /* @__PURE__ */ jsxDEV5("span", {
1046
+ className: "mr-2",
1047
+ children: "+"
1048
+ }, undefined, false, undefined, this),
1049
+ " Create Deal"
1050
+ ]
1051
+ }, undefined, true, undefined, this)
1052
+ ]
1053
+ }, undefined, true, undefined, this),
1054
+ stats && /* @__PURE__ */ jsxDEV5(StatCardGroup, {
1055
+ children: [
1056
+ /* @__PURE__ */ jsxDEV5(StatCard, {
1057
+ label: "Total Pipeline",
1058
+ value: formatCurrency4(stats.totalValue),
1059
+ hint: `${stats.total} deals`
1060
+ }, undefined, false, undefined, this),
1061
+ /* @__PURE__ */ jsxDEV5(StatCard, {
1062
+ label: "Open Deals",
1063
+ value: formatCurrency4(stats.openValue),
1064
+ hint: `${stats.openCount} active`
1065
+ }, undefined, false, undefined, this),
1066
+ /* @__PURE__ */ jsxDEV5(StatCard, {
1067
+ label: "Won",
1068
+ value: formatCurrency4(stats.wonValue),
1069
+ hint: `${stats.wonCount} closed`
1070
+ }, undefined, false, undefined, this),
1071
+ /* @__PURE__ */ jsxDEV5(StatCard, {
1072
+ label: "Lost",
1073
+ value: stats.lostCount,
1074
+ hint: "deals lost"
1075
+ }, undefined, false, undefined, this)
1076
+ ]
1077
+ }, undefined, true, undefined, this),
1078
+ /* @__PURE__ */ jsxDEV5(Tabs, {
1079
+ defaultValue: "pipeline",
1080
+ className: "w-full",
1081
+ children: [
1082
+ /* @__PURE__ */ jsxDEV5(TabsList, {
1083
+ children: [
1084
+ /* @__PURE__ */ jsxDEV5(TabsTrigger, {
1085
+ value: "pipeline",
1086
+ children: [
1087
+ /* @__PURE__ */ jsxDEV5("span", {
1088
+ className: "mr-2",
1089
+ children: "\uD83D\uDCCA"
1090
+ }, undefined, false, undefined, this),
1091
+ "Pipeline"
1092
+ ]
1093
+ }, undefined, true, undefined, this),
1094
+ /* @__PURE__ */ jsxDEV5(TabsTrigger, {
1095
+ value: "list",
1096
+ children: [
1097
+ /* @__PURE__ */ jsxDEV5("span", {
1098
+ className: "mr-2",
1099
+ children: "\uD83D\uDCCB"
1100
+ }, undefined, false, undefined, this),
1101
+ "All Deals"
1102
+ ]
1103
+ }, undefined, true, undefined, this),
1104
+ /* @__PURE__ */ jsxDEV5(TabsTrigger, {
1105
+ value: "metrics",
1106
+ children: [
1107
+ /* @__PURE__ */ jsxDEV5("span", {
1108
+ className: "mr-2",
1109
+ children: "\uD83D\uDCC8"
1110
+ }, undefined, false, undefined, this),
1111
+ "Metrics"
1112
+ ]
1113
+ }, undefined, true, undefined, this)
1114
+ ]
1115
+ }, undefined, true, undefined, this),
1116
+ /* @__PURE__ */ jsxDEV5(TabsContent, {
1117
+ value: "pipeline",
1118
+ className: "min-h-[400px]",
1119
+ children: /* @__PURE__ */ jsxDEV5(CrmPipelineBoard, {
1120
+ dealsByStage,
1121
+ stages,
1122
+ onDealClick: handleDealClick,
1123
+ onDealMove: handleDealMove
1124
+ }, undefined, false, undefined, this)
1125
+ }, undefined, false, undefined, this),
1126
+ /* @__PURE__ */ jsxDEV5(TabsContent, {
1127
+ value: "list",
1128
+ className: "min-h-[400px]",
1129
+ children: /* @__PURE__ */ jsxDEV5(DealListTab, {
1130
+ data,
1131
+ onDealClick: handleDealClick
1132
+ }, undefined, false, undefined, this)
1133
+ }, undefined, false, undefined, this),
1134
+ /* @__PURE__ */ jsxDEV5(TabsContent, {
1135
+ value: "metrics",
1136
+ className: "min-h-[400px]",
1137
+ children: /* @__PURE__ */ jsxDEV5(MetricsTab, {
1138
+ stats
1139
+ }, undefined, false, undefined, this)
1140
+ }, undefined, false, undefined, this)
1141
+ ]
1142
+ }, undefined, true, undefined, this),
1143
+ /* @__PURE__ */ jsxDEV5(CreateDealModal, {
1144
+ isOpen: isCreateModalOpen,
1145
+ onClose: () => setIsCreateModalOpen(false),
1146
+ onSubmit: async (input) => {
1147
+ await mutations.createDeal(input);
1148
+ },
1149
+ stages,
1150
+ isLoading: mutations.createState.loading
1151
+ }, undefined, false, undefined, this),
1152
+ /* @__PURE__ */ jsxDEV5(DealActionsModal, {
1153
+ isOpen: isDealActionsOpen,
1154
+ deal: selectedDeal,
1155
+ stages,
1156
+ onClose: () => {
1157
+ setIsDealActionsOpen(false);
1158
+ setSelectedDeal(null);
1159
+ },
1160
+ onWin: async (input) => {
1161
+ await mutations.winDeal(input);
1162
+ },
1163
+ onLose: async (input) => {
1164
+ await mutations.loseDeal(input);
1165
+ },
1166
+ onMove: async (input) => {
1167
+ await mutations.moveDeal(input);
1168
+ refetch();
1169
+ },
1170
+ isLoading: mutations.isLoading
1171
+ }, undefined, false, undefined, this)
1172
+ ]
1173
+ }, undefined, true, undefined, this);
1174
+ }
1175
+ function DealListTab({ data, onDealClick }) {
1176
+ if (!data?.deals.length) {
1177
+ return /* @__PURE__ */ jsxDEV5("div", {
1178
+ className: "text-muted-foreground flex h-64 items-center justify-center",
1179
+ children: "No deals found"
1180
+ }, undefined, false, undefined, this);
1181
+ }
1182
+ return /* @__PURE__ */ jsxDEV5("div", {
1183
+ className: "border-border rounded-lg border",
1184
+ children: /* @__PURE__ */ jsxDEV5("table", {
1185
+ className: "w-full",
1186
+ children: [
1187
+ /* @__PURE__ */ jsxDEV5("thead", {
1188
+ className: "border-border bg-muted/30 border-b",
1189
+ children: /* @__PURE__ */ jsxDEV5("tr", {
1190
+ children: [
1191
+ /* @__PURE__ */ jsxDEV5("th", {
1192
+ className: "px-4 py-3 text-left text-sm font-medium",
1193
+ children: "Deal"
1194
+ }, undefined, false, undefined, this),
1195
+ /* @__PURE__ */ jsxDEV5("th", {
1196
+ className: "px-4 py-3 text-left text-sm font-medium",
1197
+ children: "Value"
1198
+ }, undefined, false, undefined, this),
1199
+ /* @__PURE__ */ jsxDEV5("th", {
1200
+ className: "px-4 py-3 text-left text-sm font-medium",
1201
+ children: "Status"
1202
+ }, undefined, false, undefined, this),
1203
+ /* @__PURE__ */ jsxDEV5("th", {
1204
+ className: "px-4 py-3 text-left text-sm font-medium",
1205
+ children: "Expected Close"
1206
+ }, undefined, false, undefined, this),
1207
+ /* @__PURE__ */ jsxDEV5("th", {
1208
+ className: "px-4 py-3 text-left text-sm font-medium",
1209
+ children: "Actions"
1210
+ }, undefined, false, undefined, this)
1211
+ ]
1212
+ }, undefined, true, undefined, this)
1213
+ }, undefined, false, undefined, this),
1214
+ /* @__PURE__ */ jsxDEV5("tbody", {
1215
+ className: "divide-border divide-y",
1216
+ children: data.deals.map((deal) => /* @__PURE__ */ jsxDEV5("tr", {
1217
+ className: "hover:bg-muted/50",
1218
+ children: [
1219
+ /* @__PURE__ */ jsxDEV5("td", {
1220
+ className: "px-4 py-3",
1221
+ children: /* @__PURE__ */ jsxDEV5("div", {
1222
+ className: "font-medium",
1223
+ children: deal.name
1224
+ }, undefined, false, undefined, this)
1225
+ }, undefined, false, undefined, this),
1226
+ /* @__PURE__ */ jsxDEV5("td", {
1227
+ className: "px-4 py-3 font-mono",
1228
+ children: formatCurrency4(deal.value, deal.currency)
1229
+ }, undefined, false, undefined, this),
1230
+ /* @__PURE__ */ jsxDEV5("td", {
1231
+ className: "px-4 py-3",
1232
+ children: /* @__PURE__ */ jsxDEV5("span", {
1233
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${deal.status === "WON" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : deal.status === "LOST" ? "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400" : "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"}`,
1234
+ children: deal.status
1235
+ }, undefined, false, undefined, this)
1236
+ }, undefined, false, undefined, this),
1237
+ /* @__PURE__ */ jsxDEV5("td", {
1238
+ className: "text-muted-foreground px-4 py-3",
1239
+ children: deal.expectedCloseDate?.toLocaleDateString() ?? "-"
1240
+ }, undefined, false, undefined, this),
1241
+ /* @__PURE__ */ jsxDEV5("td", {
1242
+ className: "px-4 py-3",
1243
+ children: /* @__PURE__ */ jsxDEV5(Button3, {
1244
+ variant: "ghost",
1245
+ size: "sm",
1246
+ onPress: () => onDealClick?.(deal.id),
1247
+ children: "Actions"
1248
+ }, undefined, false, undefined, this)
1249
+ }, undefined, false, undefined, this)
1250
+ ]
1251
+ }, deal.id, true, undefined, this))
1252
+ }, undefined, false, undefined, this)
1253
+ ]
1254
+ }, undefined, true, undefined, this)
1255
+ }, undefined, false, undefined, this);
1256
+ }
1257
+ function MetricsTab({
1258
+ stats
1259
+ }) {
1260
+ if (!stats)
1261
+ return null;
1262
+ return /* @__PURE__ */ jsxDEV5("div", {
1263
+ className: "space-y-6",
1264
+ children: /* @__PURE__ */ jsxDEV5("div", {
1265
+ className: "border-border bg-card rounded-xl border p-6",
1266
+ children: [
1267
+ /* @__PURE__ */ jsxDEV5("h3", {
1268
+ className: "mb-4 text-lg font-semibold",
1269
+ children: "Pipeline Overview"
1270
+ }, undefined, false, undefined, this),
1271
+ /* @__PURE__ */ jsxDEV5("dl", {
1272
+ className: "grid gap-4 sm:grid-cols-3",
1273
+ children: [
1274
+ /* @__PURE__ */ jsxDEV5("div", {
1275
+ children: [
1276
+ /* @__PURE__ */ jsxDEV5("dt", {
1277
+ className: "text-muted-foreground text-sm",
1278
+ children: "Win Rate"
1279
+ }, undefined, false, undefined, this),
1280
+ /* @__PURE__ */ jsxDEV5("dd", {
1281
+ className: "text-2xl font-semibold",
1282
+ children: [
1283
+ stats.total > 0 ? (stats.wonCount / stats.total * 100).toFixed(0) : 0,
1284
+ "%"
1285
+ ]
1286
+ }, undefined, true, undefined, this)
1287
+ ]
1288
+ }, undefined, true, undefined, this),
1289
+ /* @__PURE__ */ jsxDEV5("div", {
1290
+ children: [
1291
+ /* @__PURE__ */ jsxDEV5("dt", {
1292
+ className: "text-muted-foreground text-sm",
1293
+ children: "Avg Deal Size"
1294
+ }, undefined, false, undefined, this),
1295
+ /* @__PURE__ */ jsxDEV5("dd", {
1296
+ className: "text-2xl font-semibold",
1297
+ children: formatCurrency4(stats.total > 0 ? stats.totalValue / stats.total : 0)
1298
+ }, undefined, false, undefined, this)
1299
+ ]
1300
+ }, undefined, true, undefined, this),
1301
+ /* @__PURE__ */ jsxDEV5("div", {
1302
+ children: [
1303
+ /* @__PURE__ */ jsxDEV5("dt", {
1304
+ className: "text-muted-foreground text-sm",
1305
+ children: "Conversion"
1306
+ }, undefined, false, undefined, this),
1307
+ /* @__PURE__ */ jsxDEV5("dd", {
1308
+ className: "text-2xl font-semibold",
1309
+ children: [
1310
+ stats.wonCount,
1311
+ " / ",
1312
+ stats.total
1313
+ ]
1314
+ }, undefined, true, undefined, this)
1315
+ ]
1316
+ }, undefined, true, undefined, this)
1317
+ ]
1318
+ }, undefined, true, undefined, this)
1319
+ ]
1320
+ }, undefined, true, undefined, this)
1321
+ }, undefined, false, undefined, this);
1322
+ }
1323
+ export {
1324
+ CrmDashboard
1325
+ };