@burdenoff/microfe-subscriberbot 2026.1103.1 → 2026.1105.1

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 (200) hide show
  1. package/dist/index.js +3 -3
  2. package/dist/stories/Accessibility.stories.d.ts +13 -0
  3. package/dist/stories/Accessibility.stories.d.ts.map +1 -0
  4. package/dist/stories/pages/AgentDetailPage.stories.d.ts.map +1 -1
  5. package/dist/stories/pages/AgentNewPage.stories.d.ts.map +1 -1
  6. package/dist/stories/pages/AgentsListPage.stories.d.ts.map +1 -1
  7. package/dist/stories/pages/BankConnectionsPage.stories.d.ts +1 -0
  8. package/dist/stories/pages/BankConnectionsPage.stories.d.ts.map +1 -1
  9. package/dist/stories/pages/EnterpriseSpendPage.stories.d.ts.map +1 -1
  10. package/dist/stories/pages/InboxPage.stories.d.ts.map +1 -1
  11. package/dist/subscriberbot/admin/AdminDashboardPage.d.ts.map +1 -1
  12. package/dist/subscriberbot/admin/AdminDashboardPage.js +168 -168
  13. package/dist/subscriberbot/admin/AdminDashboardPage.js.map +1 -1
  14. package/dist/subscriberbot/admin/NegotiationDeskPanel.d.ts.map +1 -1
  15. package/dist/subscriberbot/admin/NegotiationDeskPanel.js +116 -116
  16. package/dist/subscriberbot/admin/NegotiationDeskPanel.js.map +1 -1
  17. package/dist/subscriberbot/admin/ProcurementDeskPanel.d.ts.map +1 -1
  18. package/dist/subscriberbot/admin/ProcurementDeskPanel.js +211 -211
  19. package/dist/subscriberbot/admin/ProcurementDeskPanel.js.map +1 -1
  20. package/dist/subscriberbot/components/Modal.d.ts.map +1 -1
  21. package/dist/subscriberbot/components/Modal.js +43 -33
  22. package/dist/subscriberbot/components/Modal.js.map +1 -1
  23. package/dist/subscriberbot/components/PostureOptions.d.ts.map +1 -1
  24. package/dist/subscriberbot/components/PostureOptions.js +10 -10
  25. package/dist/subscriberbot/components/PostureOptions.js.map +1 -1
  26. package/dist/subscriberbot/components/StateViews.d.ts.map +1 -1
  27. package/dist/subscriberbot/components/StateViews.js +45 -37
  28. package/dist/subscriberbot/components/StateViews.js.map +1 -1
  29. package/dist/subscriberbot/components/StatusBadge.d.ts.map +1 -1
  30. package/dist/subscriberbot/components/StatusBadge.js +6 -6
  31. package/dist/subscriberbot/components/StatusBadge.js.map +1 -1
  32. package/dist/subscriberbot/components/decisions/DecisionBanners.js +6 -6
  33. package/dist/subscriberbot/components/decisions/DecisionCard.d.ts.map +1 -1
  34. package/dist/subscriberbot/components/decisions/DecisionCard.js +149 -147
  35. package/dist/subscriberbot/components/decisions/DecisionCard.js.map +1 -1
  36. package/dist/subscriberbot/components/mobile/MobileDashboard.d.ts.map +1 -1
  37. package/dist/subscriberbot/components/mobile/MobileDashboard.js +127 -127
  38. package/dist/subscriberbot/components/mobile/MobileDashboard.js.map +1 -1
  39. package/dist/subscriberbot/components/mobile/MobileRelationshipList.d.ts.map +1 -1
  40. package/dist/subscriberbot/components/mobile/MobileRelationshipList.js +114 -114
  41. package/dist/subscriberbot/components/mobile/MobileRelationshipList.js.map +1 -1
  42. package/dist/subscriberbot/components/mobile/MobileScreen.js +1 -1
  43. package/dist/subscriberbot/components/mobile/MobileScreen.js.map +1 -1
  44. package/dist/subscriberbot/components/negotiations/NegotiationStatusPill.js +4 -4
  45. package/dist/subscriberbot/components/negotiations/NegotiationTimeline.d.ts.map +1 -1
  46. package/dist/subscriberbot/components/negotiations/NegotiationTimeline.js +11 -11
  47. package/dist/subscriberbot/components/negotiations/NegotiationTimeline.js.map +1 -1
  48. package/dist/subscriberbot/components/negotiations/OutcomeForm.d.ts.map +1 -1
  49. package/dist/subscriberbot/components/negotiations/OutcomeForm.js +29 -29
  50. package/dist/subscriberbot/components/negotiations/OutcomeForm.js.map +1 -1
  51. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.d.ts.map +1 -1
  52. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js +43 -43
  53. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js.map +1 -1
  54. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js +4 -4
  55. package/dist/subscriberbot/components/procurement/ProcurementThread.d.ts.map +1 -1
  56. package/dist/subscriberbot/components/procurement/ProcurementThread.js +14 -14
  57. package/dist/subscriberbot/components/procurement/ProcurementThread.js.map +1 -1
  58. package/dist/subscriberbot/components/savings/SavingsCards.d.ts.map +1 -1
  59. package/dist/subscriberbot/components/savings/SavingsCards.js +242 -237
  60. package/dist/subscriberbot/components/savings/SavingsCards.js.map +1 -1
  61. package/dist/subscriberbot/components/viz.d.ts +1 -0
  62. package/dist/subscriberbot/components/viz.d.ts.map +1 -1
  63. package/dist/subscriberbot/components/viz.js +100 -101
  64. package/dist/subscriberbot/components/viz.js.map +1 -1
  65. package/dist/subscriberbot/hooks/index.js +1 -1
  66. package/dist/subscriberbot/hooks/useFormError.d.ts +7 -0
  67. package/dist/subscriberbot/hooks/useFormError.d.ts.map +1 -0
  68. package/dist/subscriberbot/hooks/useFormError.js +28 -0
  69. package/dist/subscriberbot/hooks/useFormError.js.map +1 -0
  70. package/dist/subscriberbot/hooks/useFormatters.d.ts +11 -0
  71. package/dist/subscriberbot/hooks/useFormatters.d.ts.map +1 -0
  72. package/dist/subscriberbot/hooks/useFormatters.js +13 -0
  73. package/dist/subscriberbot/hooks/useFormatters.js.map +1 -0
  74. package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
  75. package/dist/subscriberbot/hooks/useSubscriberBotApi.js +371 -370
  76. package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
  77. package/dist/subscriberbot/hooks/useTr.d.ts.map +1 -1
  78. package/dist/subscriberbot/hooks/useTr.js +1 -1
  79. package/dist/subscriberbot/hooks/useTr.js.map +1 -1
  80. package/dist/subscriberbot/index.js +1 -1
  81. package/dist/subscriberbot/pages/AssetVaultPage.d.ts.map +1 -1
  82. package/dist/subscriberbot/pages/AssetVaultPage.js +124 -124
  83. package/dist/subscriberbot/pages/AssetVaultPage.js.map +1 -1
  84. package/dist/subscriberbot/pages/DashboardPage.d.ts +0 -10
  85. package/dist/subscriberbot/pages/DashboardPage.d.ts.map +1 -1
  86. package/dist/subscriberbot/pages/DashboardPage.js +107 -98
  87. package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
  88. package/dist/subscriberbot/pages/InboxPage.d.ts +0 -10
  89. package/dist/subscriberbot/pages/InboxPage.d.ts.map +1 -1
  90. package/dist/subscriberbot/pages/InboxPage.js +421 -402
  91. package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
  92. package/dist/subscriberbot/pages/InsightsPage.d.ts.map +1 -1
  93. package/dist/subscriberbot/pages/InsightsPage.js +130 -121
  94. package/dist/subscriberbot/pages/InsightsPage.js.map +1 -1
  95. package/dist/subscriberbot/pages/InvoicesPage.d.ts +0 -12
  96. package/dist/subscriberbot/pages/InvoicesPage.d.ts.map +1 -1
  97. package/dist/subscriberbot/pages/InvoicesPage.js +237 -215
  98. package/dist/subscriberbot/pages/InvoicesPage.js.map +1 -1
  99. package/dist/subscriberbot/pages/RenewalsPage.d.ts.map +1 -1
  100. package/dist/subscriberbot/pages/RenewalsPage.js +303 -295
  101. package/dist/subscriberbot/pages/RenewalsPage.js.map +1 -1
  102. package/dist/subscriberbot/pages/SavingsPage.d.ts.map +1 -1
  103. package/dist/subscriberbot/pages/SavingsPage.js +57 -57
  104. package/dist/subscriberbot/pages/SavingsPage.js.map +1 -1
  105. package/dist/subscriberbot/pages/WorkflowsPage.d.ts +0 -13
  106. package/dist/subscriberbot/pages/WorkflowsPage.d.ts.map +1 -1
  107. package/dist/subscriberbot/pages/WorkflowsPage.js +202 -196
  108. package/dist/subscriberbot/pages/WorkflowsPage.js.map +1 -1
  109. package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts +0 -18
  110. package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts.map +1 -1
  111. package/dist/subscriberbot/pages/agents/AgentDetailPage.js +283 -275
  112. package/dist/subscriberbot/pages/agents/AgentDetailPage.js.map +1 -1
  113. package/dist/subscriberbot/pages/agents/AgentNewPage.d.ts +0 -6
  114. package/dist/subscriberbot/pages/agents/AgentNewPage.d.ts.map +1 -1
  115. package/dist/subscriberbot/pages/agents/AgentNewPage.js +85 -77
  116. package/dist/subscriberbot/pages/agents/AgentNewPage.js.map +1 -1
  117. package/dist/subscriberbot/pages/agents/AgentsListPage.d.ts +0 -9
  118. package/dist/subscriberbot/pages/agents/AgentsListPage.d.ts.map +1 -1
  119. package/dist/subscriberbot/pages/agents/AgentsListPage.js +136 -136
  120. package/dist/subscriberbot/pages/agents/AgentsListPage.js.map +1 -1
  121. package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts +0 -9
  122. package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts.map +1 -1
  123. package/dist/subscriberbot/pages/banking/BankConnectionsPage.js +267 -260
  124. package/dist/subscriberbot/pages/banking/BankConnectionsPage.js.map +1 -1
  125. package/dist/subscriberbot/pages/decisions/DecisionDetailPage.d.ts +0 -10
  126. package/dist/subscriberbot/pages/decisions/DecisionDetailPage.d.ts.map +1 -1
  127. package/dist/subscriberbot/pages/decisions/DecisionDetailPage.js +96 -96
  128. package/dist/subscriberbot/pages/decisions/DecisionDetailPage.js.map +1 -1
  129. package/dist/subscriberbot/pages/decisions/DecisionsPage.d.ts +0 -11
  130. package/dist/subscriberbot/pages/decisions/DecisionsPage.d.ts.map +1 -1
  131. package/dist/subscriberbot/pages/decisions/DecisionsPage.js +46 -46
  132. package/dist/subscriberbot/pages/decisions/DecisionsPage.js.map +1 -1
  133. package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.d.ts +0 -11
  134. package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.d.ts.map +1 -1
  135. package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js +181 -171
  136. package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js.map +1 -1
  137. package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.d.ts +0 -9
  138. package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.d.ts.map +1 -1
  139. package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.js +164 -164
  140. package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.js.map +1 -1
  141. package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.d.ts +0 -9
  142. package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.d.ts.map +1 -1
  143. package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.js +197 -181
  144. package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.js.map +1 -1
  145. package/dist/subscriberbot/pages/negotiations/NegotiationsPage.d.ts +0 -8
  146. package/dist/subscriberbot/pages/negotiations/NegotiationsPage.d.ts.map +1 -1
  147. package/dist/subscriberbot/pages/negotiations/NegotiationsPage.js +79 -79
  148. package/dist/subscriberbot/pages/negotiations/NegotiationsPage.js.map +1 -1
  149. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts +0 -9
  150. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts.map +1 -1
  151. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js +147 -147
  152. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js.map +1 -1
  153. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts +0 -10
  154. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts.map +1 -1
  155. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js +204 -188
  156. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js.map +1 -1
  157. package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts +0 -9
  158. package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts.map +1 -1
  159. package/dist/subscriberbot/pages/procurement/ProcurementPage.js +80 -80
  160. package/dist/subscriberbot/pages/procurement/ProcurementPage.js.map +1 -1
  161. package/dist/subscriberbot/pages/providers/ProviderDetailPage.d.ts +0 -10
  162. package/dist/subscriberbot/pages/providers/ProviderDetailPage.d.ts.map +1 -1
  163. package/dist/subscriberbot/pages/providers/ProviderDetailPage.js +484 -458
  164. package/dist/subscriberbot/pages/providers/ProviderDetailPage.js.map +1 -1
  165. package/dist/subscriberbot/pages/providers/ProviderNewPage.d.ts +0 -8
  166. package/dist/subscriberbot/pages/providers/ProviderNewPage.d.ts.map +1 -1
  167. package/dist/subscriberbot/pages/providers/ProviderNewPage.js +146 -136
  168. package/dist/subscriberbot/pages/providers/ProviderNewPage.js.map +1 -1
  169. package/dist/subscriberbot/pages/providers/ProvidersListPage.d.ts +0 -10
  170. package/dist/subscriberbot/pages/providers/ProvidersListPage.d.ts.map +1 -1
  171. package/dist/subscriberbot/pages/providers/ProvidersListPage.js +88 -87
  172. package/dist/subscriberbot/pages/providers/ProvidersListPage.js.map +1 -1
  173. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts +0 -11
  174. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts.map +1 -1
  175. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +520 -490
  176. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
  177. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.d.ts +0 -8
  178. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.d.ts.map +1 -1
  179. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js +104 -90
  180. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js.map +1 -1
  181. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.d.ts +0 -8
  182. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.d.ts.map +1 -1
  183. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js +97 -96
  184. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js.map +1 -1
  185. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.d.ts.map +1 -1
  186. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js +76 -74
  187. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js.map +1 -1
  188. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.d.ts +5 -3
  189. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.d.ts.map +1 -1
  190. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js +26 -25
  191. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js.map +1 -1
  192. package/dist/subscriberbot/utils/formatters.d.ts +16 -5
  193. package/dist/subscriberbot/utils/formatters.d.ts.map +1 -1
  194. package/dist/subscriberbot/utils/formatters.js +57 -25
  195. package/dist/subscriberbot/utils/formatters.js.map +1 -1
  196. package/dist/subscriberbot/utils/plaidLink.d.ts +2 -1
  197. package/dist/subscriberbot/utils/plaidLink.d.ts.map +1 -1
  198. package/dist/subscriberbot/utils/plaidLink.js +21 -21
  199. package/dist/subscriberbot/utils/plaidLink.js.map +1 -1
  200. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ProcurementNewPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/procurement/ProcurementNewPage.tsx"],"sourcesContent":["/**\n * New expert procurement request\n * @module subscriberbot/pages/procurement\n *\n * `/subscriberbot/procurement/new[?relationshipId=…]` — describe the contract\n * (vendor, current price or quote, term, seats, decision deadline,\n * priorities). Creates a DRAFT through `subCreateProcurementRequest`; the\n * customer accepts the procurement authorisation and submits from the detail\n * page.\n */\n\nimport { useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { ArrowLeft, CalendarClock, FileText, Target } from 'lucide-react';\nimport { GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { REQUEST_TYPES, REQUEST_TYPE_LABEL } from '../../components/procurement';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useCreateProcurementRequest, useProcurementTerms } from '../../hooks/useProcurementApi';\nimport { useRelationship, useRelationships } from '../../hooks/useSubscriberBotApi';\nimport { useTr } from '../../hooks/useTr';\nimport type {\n SubCreateProcurementRequestInput,\n SubProcurementRequestType,\n} from '../../types/procurement';\n\nconst PERIODS_PER_YEAR: Record<string, number> = {\n DAILY: 365,\n WEEKLY: 52,\n MONTHLY: 12,\n QUARTERLY: 4,\n YEARLY: 1,\n};\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst labelCls = 'mb-1.5 block text-xs font-medium text-text-secondary';\n\nfunction FormSection({\n icon,\n title,\n description,\n children,\n}: {\n icon: ReactNode;\n title: string;\n description: string;\n children: ReactNode;\n}) {\n return (\n <GlassCard treatment=\"metric\" className=\"p-5 sm:p-6\">\n <div className=\"flex items-start gap-3\">\n <span className=\"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-bg-sunken text-text-secondary\">\n {icon}\n </span>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">{title}</h2>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{description}</p>\n </div>\n </div>\n <div className=\"mt-4\">{children}</div>\n </GlassCard>\n );\n}\n\n/** `YYYY-MM-DD` for a date input. */\nfunction toDateInput(value: string | Date | null | undefined): string {\n if (!value) return '';\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10);\n}\n\nconst positive = (value: string): number | null => {\n if (!value.trim()) return null;\n const n = Number(value);\n return Number.isFinite(n) && n > 0 ? n : null;\n};\n\nexport function ProcurementNewPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [params] = useSearchParams();\n const create = useCreateProcurementRequest();\n const terms = useProcurementTerms();\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const [relationshipId, setRelationshipId] = useState(params.get('relationshipId') ?? '');\n // The selected subscription is fetched by id, so pre-fill works even when it\n // is not on the first page of the picker (opened from its detail page).\n const linkedQ = useRelationship(relationshipId || undefined);\n const relationships = useMemo(() => {\n const items = relationshipsQ.data?.items ?? [];\n const selected = linkedQ.data;\n return selected && !items.some((r) => r.id === selected.id) ? [selected, ...items] : items;\n }, [relationshipsQ.data, linkedQ.data]);\n const [vendorName, setVendorName] = useState('');\n const [productName, setProductName] = useState('');\n const [category, setCategory] = useState('');\n const [requestType, setRequestType] = useState<SubProcurementRequestType>('RENEWAL');\n const [currency, setCurrency] = useState('USD');\n const [currentAnnualValue, setCurrentAnnualValue] = useState('');\n const [quotedAnnualValue, setQuotedAnnualValue] = useState('');\n const [targetAnnualValue, setTargetAnnualValue] = useState('');\n const [termMonths, setTermMonths] = useState('12');\n const [seats, setSeats] = useState('');\n const [deadline, setDeadline] = useState('');\n const [notes, setNotes] = useState('');\n const [formError, setFormError] = useState<string | null>(null);\n\n // Prefill from the linked relationship once per selection, so a background\n // refetch of the relationships list never overwrites the user's edits.\n const linked = relationshipId ? relationships.find((r) => r.id === relationshipId) : undefined;\n const prefilledFor = useRef<string | null>(null);\n useEffect(() => {\n if (!linked || prefilledFor.current === linked.id) return;\n prefilledFor.current = linked.id;\n setVendorName(linked.label);\n setCurrency(linked.currency);\n // Every relationship-derived value is replaced (or cleared when this\n // subscription cannot supply it), so a previous selection's price or\n // renewal date never leaks into this request.\n const periods = PERIODS_PER_YEAR[linked.interval] ?? 0;\n setCurrentAnnualValue(\n linked.amount > 0 && periods > 0\n ? String(Math.round(linked.amount * periods * 100) / 100)\n : ''\n );\n setDeadline(linked.renewsAt ? toDateInput(linked.renewsAt) : '');\n }, [linked]);\n\n const feePct = terms.data ? Math.round(terms.data.feeRate * 100) : null;\n const today = toDateInput(new Date());\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n setFormError(null);\n const current = positive(currentAnnualValue);\n const quoted = positive(quotedAnnualValue);\n const term = Number(termMonths);\n if (!vendorName.trim()) {\n setFormError(tr('procurement.form.vendorRequired', 'Which vendor is the contract with?'));\n return;\n }\n if (current == null && quoted == null) {\n setFormError(\n tr(\n 'procurement.form.baselineRequired',\n 'Enter what you pay per year today or the annual value of the vendor quote.'\n )\n );\n return;\n }\n if (!deadline) {\n setFormError(tr('procurement.form.deadlineRequired', 'When must the decision be made?'));\n return;\n }\n if (!Number.isInteger(term) || term < 1 || term > (terms.data?.maxTermMonths ?? 60)) {\n setFormError(\n tr('procurement.form.termInvalid', 'The term must be between 1 and {{max}} months.', {\n max: terms.data?.maxTermMonths ?? 60,\n })\n );\n return;\n }\n const target = positive(targetAnnualValue);\n const seatCount = positive(seats);\n const input: SubCreateProcurementRequestInput = {\n vendorName: vendorName.trim(),\n requestType,\n currency: currency.trim().toUpperCase() || 'USD',\n termMonths: term,\n // End of the chosen day, so a same-day deadline can still be submitted.\n deadline: new Date(`${deadline}T23:59:59`).toISOString(),\n ...(relationshipId ? { relationshipId } : {}),\n ...(productName.trim() ? { productName: productName.trim() } : {}),\n ...(category.trim() ? { category: category.trim() } : {}),\n ...(current != null ? { currentAnnualValue: current } : {}),\n ...(quoted != null ? { quotedAnnualValue: quoted } : {}),\n ...(target != null ? { targetAnnualValue: target } : {}),\n ...(seatCount != null ? { seats: Math.round(seatCount) } : {}),\n ...(notes.trim() ? { notes: notes.trim() } : {}),\n };\n create.mutate(\n { input },\n {\n onSuccess: (p) => navigateTo(`/procurement/${p.id}`),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('procurement.form.error', 'Could not create the request.')\n ),\n }\n );\n };\n\n return (\n <PageLayout\n title={tr('procurement.new.title', 'Request an expert negotiation')}\n description={tr(\n 'procurement.new.description',\n 'Tell the procurement desk about the contract and what matters to you.'\n )}\n actions={\n <button\n type=\"button\"\n onClick={() => navigateTo('/procurement')}\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"h-4 w-4\" /> {tr('procurement.back', 'Back')}\n </button>\n }\n >\n <PagePurpose className=\"mb-6\">\n {feePct != null\n ? tr(\n 'procurement.new.purposeFee',\n 'Nothing reaches the vendor until you submit the request. The fee is {{pct}}% of the first-year savings against the vendor quote (or your current price), and only when the expert gets the price down.',\n { pct: feePct }\n )\n : tr(\n 'procurement.new.purpose',\n 'Nothing reaches the vendor until you submit the request. You only pay a share of the savings the expert secures.'\n )}\n </PagePurpose>\n\n <form onSubmit={handleSubmit} className=\"max-w-3xl space-y-5\" data-testid=\"procurement-form\">\n {formError && (\n <div\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <FormSection\n icon={<FileText className=\"h-4 w-4\" />}\n title={tr('procurement.form.contract.title', 'The contract')}\n description={tr(\n 'procurement.form.contract.description',\n 'Link a tracked subscription to prefill it, or describe the contract.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div className=\"sm:col-span-2\">\n <label htmlFor=\"proc-relationship\" className={labelCls}>\n {tr('procurement.form.relationship', 'Tracked subscription (optional)')}\n </label>\n <select\n id=\"proc-relationship\"\n value={relationshipId}\n onChange={(e) => setRelationshipId(e.target.value)}\n className={inputCls}\n >\n <option value=\"\">{tr('procurement.form.noRelationship', 'Not linked')}</option>\n {relationships.map((r) => (\n <option key={r.id} value={r.id}>\n {r.label}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"proc-vendor\" className={labelCls}>\n {tr('procurement.form.vendor', 'Vendor')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"proc-vendor\"\n value={vendorName}\n onChange={(e) => setVendorName(e.target.value)}\n placeholder={tr('procurement.form.vendorPlaceholder', 'e.g. Salesforce')}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-product\" className={labelCls}>\n {tr('procurement.form.product', 'Product or plan')}\n </label>\n <input\n id=\"proc-product\"\n value={productName}\n onChange={(e) => setProductName(e.target.value)}\n placeholder={tr(\n 'procurement.form.productPlaceholder',\n 'e.g. Sales Cloud Enterprise'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-type\" className={labelCls}>\n {tr('procurement.form.type', 'Type of request')}\n </label>\n <select\n id=\"proc-type\"\n value={requestType}\n onChange={(e) => setRequestType(e.target.value as SubProcurementRequestType)}\n className={inputCls}\n >\n {REQUEST_TYPES.map((t) => (\n <option key={t} value={t}>\n {tr(REQUEST_TYPE_LABEL[t].key, REQUEST_TYPE_LABEL[t].fallback)}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"proc-category\" className={labelCls}>\n {tr('procurement.form.category', 'Software category')}\n </label>\n <input\n id=\"proc-category\"\n value={category}\n onChange={(e) => setCategory(e.target.value)}\n placeholder={tr('procurement.form.categoryPlaceholder', 'e.g. CRM, Security, HR')}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <FormSection\n icon={<Target className=\"h-4 w-4\" />}\n title={tr('procurement.form.value.title', 'Price and terms')}\n description={tr(\n 'procurement.form.value.description',\n 'Annual values. Savings are measured against the quote, or the current price when there is no quote.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"proc-current\" className={labelCls}>\n {tr('procurement.form.current', 'What you pay per year today')}\n </label>\n <input\n id=\"proc-current\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={currentAnnualValue}\n onChange={(e) => setCurrentAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-quoted\" className={labelCls}>\n {tr('procurement.form.quoted', 'Vendor quote per year')}\n </label>\n <input\n id=\"proc-quoted\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={quotedAnnualValue}\n onChange={(e) => setQuotedAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-target\" className={labelCls}>\n {tr('procurement.form.target', 'Annual price you would be happy with')}\n </label>\n <input\n id=\"proc-target\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={targetAnnualValue}\n onChange={(e) => setTargetAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-currency\" className={labelCls}>\n {tr('procurement.form.currency', 'Currency')}\n </label>\n <input\n id=\"proc-currency\"\n value={currency}\n maxLength={3}\n onChange={(e) => setCurrency(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-term\" className={labelCls}>\n {tr('procurement.form.term', 'Contract term (months)')}\n </label>\n <input\n id=\"proc-term\"\n type=\"number\"\n min=\"1\"\n max={terms.data?.maxTermMonths ?? 60}\n step=\"1\"\n value={termMonths}\n onChange={(e) => setTermMonths(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-seats\" className={labelCls}>\n {tr('procurement.form.seats', 'Seats or licences')}\n </label>\n <input\n id=\"proc-seats\"\n type=\"number\"\n min=\"1\"\n step=\"1\"\n value={seats}\n onChange={(e) => setSeats(e.target.value)}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <FormSection\n icon={<CalendarClock className=\"h-4 w-4\" />}\n title={tr('procurement.form.deadline.title', 'Deadline and priorities')}\n description={tr(\n 'procurement.form.deadline.description',\n 'The earlier the expert starts, the more leverage there is. Requests are worked in deadline order.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4\">\n <div className=\"sm:max-w-xs\">\n <label htmlFor=\"proc-deadline\" className={labelCls}>\n {tr('procurement.form.deadline', 'Decision deadline (renewal or signature date)')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"proc-deadline\"\n type=\"date\"\n min={today}\n value={deadline}\n onChange={(e) => setDeadline(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-notes\" className={labelCls}>\n {tr(\n 'procurement.form.notes',\n 'Priorities and constraints (must-have features, budget, flexibility on term or seats)'\n )}\n </label>\n <textarea\n id=\"proc-notes\"\n rows={4}\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <div className=\"flex justify-end\">\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-5 py-2.5 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('procurement.form.creating', 'Creating…')\n : tr('procurement.form.create', 'Create request')}\n </button>\n </div>\n </form>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,IAAM,KAA2C;CAC/C,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW;CACX,QAAQ;AACV,GAEM,IACJ,0MACI,IAAW;AAEjB,SAAS,EAAY,EACnB,SACA,UACA,gBACA,eAMC;CACD,OACE,kBAAC,GAAD;EAAW,WAAU;EAAS,WAAU;YAAxC,CACE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cACb;GACG,CAAA,GACN,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,MAAD;KAAI,WAAU;eAA2C;IAAU,CAAA,GACnE,kBAAC,KAAD;KAAG,WAAU;eAAsC;IAAe,CAAA,CAC/D;KACF;MACL,kBAAC,OAAD;GAAK,WAAU;GAAQ;EAAc,CAAA,CAC5B;;AAEf;AAGA,SAAS,EAAY,GAAiD;CACpE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAO,aAAiB,OAAO,IAAQ,IAAI,KAAK,CAAK;CAC3D,OAAO,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAI,KAAK,EAAK,YAAY,EAAE,MAAM,GAAG,EAAE;AAC3E;AAEA,IAAM,KAAY,MAAiC;CACjD,IAAI,CAAC,EAAM,KAAK,GAAG,OAAO;CAC1B,IAAM,IAAI,OAAO,CAAK;CACtB,OAAO,OAAO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;KACtE,aAAa,EACX,yCACA,mGACF;eAEA,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,SAAD;QAAO,SAAQ;QAAgB,WAAW;kBAA1C;SACG,EAAG,6BAA6B,+CAA+C;SAAG;SACnF,kBAAC,QAAD;UAAM,WAAU;oBAAyB;SAAO,CAAA;QAC3C;WACP,kBAAC,SAAD;QACE,IAAG;QACH,MAAK;QACL,KAAK;QACL,OAAO;QACP,WAAW,MAAM,EAAY,EAAE,OAAO,KAAK;QAC3C,WAAW;OACZ,CAAA,CACE;UACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;OAAO,SAAQ;OAAa,WAAW;iBACpC,EACC,0BACA,uFACF;MACK,CAAA,GACP,kBAAC,YAAD;OACE,IAAG;OACH,MAAM;OACN,OAAO;OACP,WAAW,MAAM,GAAS,EAAE,OAAO,KAAK;OACxC,WAAW;MACZ,CAAA,CACE,EAAA,CAAA,CACF;;IACM,CAAA;IAEb,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,UAAD;MACE,MAAK;MACL,UAAU,EAAO;MACjB,WAAU;gBAET,EAAO,YACJ,EAAG,6BAA6B,WAAW,IAC3C,EAAG,2BAA2B,gBAAgB;KAC5C,CAAA;IACL,CAAA;GACD;IACI;;AAEhB"}
1
+ {"version":3,"file":"ProcurementNewPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/procurement/ProcurementNewPage.tsx"],"sourcesContent":["import { useFormError } from '../../hooks/useFormError';\n/**\n * New expert procurement request\n * @module subscriberbot/pages/procurement\n *\n * `/subscriberbot/procurement/new[?relationshipId=…]` — describe the contract\n * (vendor, current price or quote, term, seats, decision deadline,\n * priorities). Creates a DRAFT through `subCreateProcurementRequest`; the\n * customer accepts the procurement authorisation and submits from the detail\n * page.\n */\n\nimport { useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { ArrowLeft, CalendarClock, FileText, Target } from 'lucide-react';\nimport { GlassCard, PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { REQUEST_TYPES, REQUEST_TYPE_LABEL } from '../../components/procurement';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useCreateProcurementRequest, useProcurementTerms } from '../../hooks/useProcurementApi';\nimport { useRelationship, useRelationships } from '../../hooks/useSubscriberBotApi';\nimport { useTr } from '../../hooks/useTr';\nimport type {\n SubCreateProcurementRequestInput,\n SubProcurementRequestType,\n} from '../../types/procurement';\n\nconst PERIODS_PER_YEAR: Record<string, number> = {\n DAILY: 365,\n WEEKLY: 52,\n MONTHLY: 12,\n QUARTERLY: 4,\n YEARLY: 1,\n};\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst labelCls = 'mb-1.5 block text-xs font-medium text-text-secondary';\n\nfunction FormSection({\n icon,\n title,\n description,\n children,\n}: {\n icon: ReactNode;\n title: string;\n description: string;\n children: ReactNode;\n}) {\n return (\n <GlassCard treatment=\"metric\" className=\"p-5 sm:p-6\">\n <div className=\"flex items-start gap-3\">\n <span className=\"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-bg-sunken text-text-secondary\">\n {icon}\n </span>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">{title}</h2>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{description}</p>\n </div>\n </div>\n <div className=\"mt-4\">{children}</div>\n </GlassCard>\n );\n}\n\n/** `YYYY-MM-DD` for a date input. */\nfunction toDateInput(value: string | Date | null | undefined): string {\n if (!value) return '';\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10);\n}\n\nconst positive = (value: string): number | null => {\n if (!value.trim()) return null;\n const n = Number(value);\n return Number.isFinite(n) && n > 0 ? n : null;\n};\n\nexport function ProcurementNewPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [params] = useSearchParams();\n const create = useCreateProcurementRequest();\n const terms = useProcurementTerms();\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const [relationshipId, setRelationshipId] = useState(params.get('relationshipId') ?? '');\n // The selected subscription is fetched by id, so pre-fill works even when it\n // is not on the first page of the picker (opened from its detail page).\n const linkedQ = useRelationship(relationshipId || undefined);\n const relationships = useMemo(() => {\n const items = relationshipsQ.data?.items ?? [];\n const selected = linkedQ.data;\n return selected && !items.some((r) => r.id === selected.id) ? [selected, ...items] : items;\n }, [relationshipsQ.data, linkedQ.data]);\n const [vendorName, setVendorName] = useState('');\n const [productName, setProductName] = useState('');\n const [category, setCategory] = useState('');\n const [requestType, setRequestType] = useState<SubProcurementRequestType>('RENEWAL');\n const [currency, setCurrency] = useState('USD');\n const [currentAnnualValue, setCurrentAnnualValue] = useState('');\n const [quotedAnnualValue, setQuotedAnnualValue] = useState('');\n const [targetAnnualValue, setTargetAnnualValue] = useState('');\n const [termMonths, setTermMonths] = useState('12');\n const [seats, setSeats] = useState('');\n const [deadline, setDeadline] = useState('');\n const [notes, setNotes] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n // Prefill from the linked relationship once per selection, so a background\n // refetch of the relationships list never overwrites the user's edits.\n const linked = relationshipId ? relationships.find((r) => r.id === relationshipId) : undefined;\n const prefilledFor = useRef<string | null>(null);\n useEffect(() => {\n if (!linked || prefilledFor.current === linked.id) return;\n prefilledFor.current = linked.id;\n setVendorName(linked.label);\n setCurrency(linked.currency);\n // Every relationship-derived value is replaced (or cleared when this\n // subscription cannot supply it), so a previous selection's price or\n // renewal date never leaks into this request.\n const periods = PERIODS_PER_YEAR[linked.interval] ?? 0;\n setCurrentAnnualValue(\n linked.amount > 0 && periods > 0\n ? String(Math.round(linked.amount * periods * 100) / 100)\n : ''\n );\n setDeadline(linked.renewsAt ? toDateInput(linked.renewsAt) : '');\n }, [linked]);\n\n const feePct = terms.data ? Math.round(terms.data.feeRate * 100) : null;\n const today = toDateInput(new Date());\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n setFormError(null);\n const current = positive(currentAnnualValue);\n const quoted = positive(quotedAnnualValue);\n const term = Number(termMonths);\n if (!vendorName.trim()) {\n setFormError(\n tr('procurement.form.vendorRequired', 'Which vendor is the contract with?'),\n 'proc-vendor'\n );\n return;\n }\n if (current == null && quoted == null) {\n setFormError(\n tr(\n 'procurement.form.baselineRequired',\n 'Enter what you pay per year today or the annual value of the vendor quote.'\n ),\n ['proc-current', 'proc-quoted']\n );\n return;\n }\n if (!deadline) {\n setFormError(\n tr('procurement.form.deadlineRequired', 'When must the decision be made?'),\n 'proc-deadline'\n );\n return;\n }\n if (!Number.isInteger(term) || term < 1 || term > (terms.data?.maxTermMonths ?? 60)) {\n setFormError(\n tr('procurement.form.termInvalid', 'The term must be between 1 and {{max}} months.', {\n max: terms.data?.maxTermMonths ?? 60,\n }),\n 'proc-term'\n );\n return;\n }\n const target = positive(targetAnnualValue);\n const seatCount = positive(seats);\n const input: SubCreateProcurementRequestInput = {\n vendorName: vendorName.trim(),\n requestType,\n currency: currency.trim().toUpperCase() || 'USD',\n termMonths: term,\n // End of the chosen day, so a same-day deadline can still be submitted.\n deadline: new Date(`${deadline}T23:59:59`).toISOString(),\n ...(relationshipId ? { relationshipId } : {}),\n ...(productName.trim() ? { productName: productName.trim() } : {}),\n ...(category.trim() ? { category: category.trim() } : {}),\n ...(current != null ? { currentAnnualValue: current } : {}),\n ...(quoted != null ? { quotedAnnualValue: quoted } : {}),\n ...(target != null ? { targetAnnualValue: target } : {}),\n ...(seatCount != null ? { seats: Math.round(seatCount) } : {}),\n ...(notes.trim() ? { notes: notes.trim() } : {}),\n };\n create.mutate(\n { input },\n {\n onSuccess: (p) => navigateTo(`/procurement/${p.id}`),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('procurement.form.error', 'Could not create the request.')\n ),\n }\n );\n };\n\n return (\n <PageLayout\n title={tr('procurement.new.title', 'Request an expert negotiation')}\n description={tr(\n 'procurement.new.description',\n 'Tell the procurement desk about the contract and what matters to you.'\n )}\n actions={\n <button\n type=\"button\"\n onClick={() => navigateTo('/procurement')}\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" /> {tr('procurement.back', 'Back')}\n </button>\n }\n >\n <PagePurpose className=\"mb-6\">\n {feePct != null\n ? tr(\n 'procurement.new.purposeFee',\n 'Nothing reaches the vendor until you submit the request. The fee is {{pct}}% of the first-year savings against the vendor quote (or your current price), and only when the expert gets the price down.',\n { pct: feePct }\n )\n : tr(\n 'procurement.new.purpose',\n 'Nothing reaches the vendor until you submit the request. You only pay a share of the savings the expert secures.'\n )}\n </PagePurpose>\n\n <form onSubmit={handleSubmit} className=\"max-w-3xl space-y-5\" data-testid=\"procurement-form\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <FormSection\n icon={<FileText className=\"h-4 w-4\" />}\n title={tr('procurement.form.contract.title', 'The contract')}\n description={tr(\n 'procurement.form.contract.description',\n 'Link a tracked subscription to prefill it, or describe the contract.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div className=\"sm:col-span-2\">\n <label htmlFor=\"proc-relationship\" className={labelCls}>\n {tr('procurement.form.relationship', 'Tracked subscription (optional)')}\n </label>\n <select\n {...fieldErrorProps('proc-relationship')}\n id=\"proc-relationship\"\n value={relationshipId}\n onChange={(e) => setRelationshipId(e.target.value)}\n className={inputCls}\n >\n <option value=\"\">{tr('procurement.form.noRelationship', 'Not linked')}</option>\n {relationships.map((r) => (\n <option key={r.id} value={r.id}>\n {r.label}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"proc-vendor\" className={labelCls}>\n {tr('procurement.form.vendor', 'Vendor')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('proc-vendor')}\n id=\"proc-vendor\"\n value={vendorName}\n onChange={(e) => setVendorName(e.target.value)}\n placeholder={tr('procurement.form.vendorPlaceholder', 'e.g. Salesforce')}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-product\" className={labelCls}>\n {tr('procurement.form.product', 'Product or plan')}\n </label>\n <input\n {...fieldErrorProps('proc-product')}\n id=\"proc-product\"\n value={productName}\n onChange={(e) => setProductName(e.target.value)}\n placeholder={tr(\n 'procurement.form.productPlaceholder',\n 'e.g. Sales Cloud Enterprise'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-type\" className={labelCls}>\n {tr('procurement.form.type', 'Type of request')}\n </label>\n <select\n {...fieldErrorProps('proc-type')}\n id=\"proc-type\"\n value={requestType}\n onChange={(e) => setRequestType(e.target.value as SubProcurementRequestType)}\n className={inputCls}\n >\n {REQUEST_TYPES.map((t) => (\n <option key={t} value={t}>\n {tr(REQUEST_TYPE_LABEL[t].key, REQUEST_TYPE_LABEL[t].fallback)}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"proc-category\" className={labelCls}>\n {tr('procurement.form.category', 'Software category')}\n </label>\n <input\n {...fieldErrorProps('proc-category')}\n id=\"proc-category\"\n value={category}\n onChange={(e) => setCategory(e.target.value)}\n placeholder={tr('procurement.form.categoryPlaceholder', 'e.g. CRM, Security, HR')}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <FormSection\n icon={<Target className=\"h-4 w-4\" />}\n title={tr('procurement.form.value.title', 'Price and terms')}\n description={tr(\n 'procurement.form.value.description',\n 'Annual values. Savings are measured against the quote, or the current price when there is no quote.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"proc-current\" className={labelCls}>\n {tr('procurement.form.current', 'What you pay per year today')}\n </label>\n <input\n {...fieldErrorProps('proc-current')}\n id=\"proc-current\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={currentAnnualValue}\n onChange={(e) => setCurrentAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-quoted\" className={labelCls}>\n {tr('procurement.form.quoted', 'Vendor quote per year')}\n </label>\n <input\n {...fieldErrorProps('proc-quoted')}\n id=\"proc-quoted\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={quotedAnnualValue}\n onChange={(e) => setQuotedAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-target\" className={labelCls}>\n {tr('procurement.form.target', 'Annual price you would be happy with')}\n </label>\n <input\n {...fieldErrorProps('proc-target')}\n id=\"proc-target\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={targetAnnualValue}\n onChange={(e) => setTargetAnnualValue(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-currency\" className={labelCls}>\n {tr('procurement.form.currency', 'Currency')}\n </label>\n <input\n {...fieldErrorProps('proc-currency')}\n id=\"proc-currency\"\n value={currency}\n maxLength={3}\n onChange={(e) => setCurrency(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-term\" className={labelCls}>\n {tr('procurement.form.term', 'Contract term (months)')}\n </label>\n <input\n {...fieldErrorProps('proc-term')}\n id=\"proc-term\"\n type=\"number\"\n min=\"1\"\n max={terms.data?.maxTermMonths ?? 60}\n step=\"1\"\n value={termMonths}\n onChange={(e) => setTermMonths(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-seats\" className={labelCls}>\n {tr('procurement.form.seats', 'Seats or licences')}\n </label>\n <input\n {...fieldErrorProps('proc-seats')}\n id=\"proc-seats\"\n type=\"number\"\n min=\"1\"\n step=\"1\"\n value={seats}\n onChange={(e) => setSeats(e.target.value)}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <FormSection\n icon={<CalendarClock className=\"h-4 w-4\" />}\n title={tr('procurement.form.deadline.title', 'Deadline and priorities')}\n description={tr(\n 'procurement.form.deadline.description',\n 'The earlier the expert starts, the more leverage there is. Requests are worked in deadline order.'\n )}\n >\n <div className=\"grid grid-cols-1 gap-4\">\n <div className=\"sm:max-w-xs\">\n <label htmlFor=\"proc-deadline\" className={labelCls}>\n {tr('procurement.form.deadline', 'Decision deadline (renewal or signature date)')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('proc-deadline')}\n id=\"proc-deadline\"\n type=\"date\"\n min={today}\n value={deadline}\n onChange={(e) => setDeadline(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"proc-notes\" className={labelCls}>\n {tr(\n 'procurement.form.notes',\n 'Priorities and constraints (must-have features, budget, flexibility on term or seats)'\n )}\n </label>\n <textarea\n {...fieldErrorProps('proc-notes')}\n id=\"proc-notes\"\n rows={4}\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n className={inputCls}\n />\n </div>\n </div>\n </FormSection>\n\n <div className=\"flex justify-end\">\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-5 py-2.5 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('procurement.form.creating', 'Creating…')\n : tr('procurement.form.create', 'Create request')}\n </button>\n </div>\n </form>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,IAAM,KAA2C;CAC/C,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW;CACX,QAAQ;AACV,GAEM,IACJ,0MACI,IAAW;AAEjB,SA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AA6B,+CAA+C;SAAG;SACnF,kBAAC,QAAD;UAAM,WAAU;oBAAyB;SAAO,CAAA;QAC3C;WACP,kBAAC,SAAD;QACE,GAAI,EAAgB,eAAe;QACnC,IAAG;QACH,MAAK;QACL,KAAK;QACL,OAAO;QACP,WAAW,MAAM,EAAY,EAAE,OAAO,KAAK;QAC3C,WAAW;OACZ,CAAA,CACE;UACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;OAAO,SAAQ;OAAa,WAAW;iBACpC,EACC,0BACA,uFACF;MACK,CAAA,GACP,kBAAC,YAAD;OACE,GAAI,EAAgB,YAAY;OAChC,IAAG;OACH,MAAM;OACN,OAAO;OACP,WAAW,MAAM,GAAS,EAAE,OAAO,KAAK;OACxC,WAAW;MACZ,CAAA,CACE,EAAA,CAAA,CACF;;IACM,CAAA;IAEb,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,UAAD;MACE,MAAK;MACL,UAAU,EAAO;MACjB,WAAU;gBAET,EAAO,YACJ,EAAG,6BAA6B,WAAW,IAC3C,EAAG,2BAA2B,gBAAgB;KAC5C,CAAA;IACL,CAAA;GACD;IACI;;AAEhB"}
@@ -1,11 +1,2 @@
1
- /**
2
- * Human procurement overview
3
- * @module subscriberbot/pages/procurement
4
- *
5
- * `/subscriberbot/procurement` — every expert procurement request in the
6
- * workspace (BOFF-4158) with the savings Subscriber Bot's procurement experts
7
- * secured, backed by the real `subListProcurementRequests` /
8
- * `subProcurementSummary` queries.
9
- */
10
1
  export declare function ProcurementPage(): import("react").JSX.Element;
11
2
  //# sourceMappingURL=ProcurementPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProcurementPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/procurement/ProcurementPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8BH,wBAAgB,eAAe,gCAyL9B"}
1
+ {"version":3,"file":"ProcurementPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/procurement/ProcurementPage.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,eAAe,gCA2L9B"}
@@ -1,22 +1,22 @@
1
1
  import { useSubscriberBot as e } from "../../context/SubscriberBotContext.js";
2
- import { cn as t } from "../../utils/cn.js";
3
- import { PageLayout as n } from "../../components/PageLayout.js";
4
- import { MetricsCard as r } from "../../components/MetricsCard.js";
5
- import { formatCurrency as i, formatDate as a } from "../../utils/formatters.js";
2
+ import { useTr as t } from "../../hooks/useTr.js";
3
+ import { useFormatters as n } from "../../hooks/useFormatters.js";
4
+ import { cn as r } from "../../utils/cn.js";
5
+ import { PageLayout as i } from "../../components/PageLayout.js";
6
+ import { MetricsCard as a } from "../../components/MetricsCard.js";
6
7
  import { EmptyState as o } from "../../components/EmptyState.js";
7
- import { useTr as s } from "../../hooks/useTr.js";
8
- import { ErrorView as c, LoadingView as l } from "../../components/StateViews.js";
8
+ import { ErrorView as s, LoadingView as c } from "../../components/StateViews.js";
9
9
  import "../../components/index.js";
10
- import { REQUEST_TYPE_LABEL as u, STATUS_LABEL as d } from "../../components/procurement/labels.js";
11
- import { ProcurementStatusPill as f } from "../../components/procurement/ProcurementStatusPill.js";
10
+ import { REQUEST_TYPE_LABEL as l, STATUS_LABEL as u } from "../../components/procurement/labels.js";
11
+ import { ProcurementStatusPill as d } from "../../components/procurement/ProcurementStatusPill.js";
12
12
  import "../../components/procurement/index.js";
13
- import { useProcurementRequests as p, useProcurementSummary as m } from "../../hooks/useProcurementApi.js";
14
- import { useState as h } from "react";
15
- import { BadgePercent as g, Briefcase as _, PiggyBank as v, Plus as y, Timer as b } from "lucide-react";
16
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
17
- import { PagePurpose as w } from "@burdenoff/fe-libs/ui";
13
+ import { useProcurementRequests as f, useProcurementSummary as p } from "../../hooks/useProcurementApi.js";
14
+ import { useState as m } from "react";
15
+ import { BadgePercent as h, Briefcase as g, PiggyBank as _, Plus as v, Timer as y } from "lucide-react";
16
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
17
+ import { PagePurpose as C } from "@burdenoff/fe-libs/ui";
18
18
  //#region src/subscriberbot/pages/procurement/ProcurementPage.tsx
19
- var T = [
19
+ var w = [
20
20
  "ALL",
21
21
  "DRAFT",
22
22
  "SUBMITTED",
@@ -27,123 +27,123 @@ var T = [
27
27
  "NO_SAVINGS",
28
28
  "CANCELLED"
29
29
  ];
30
- function E() {
31
- let E = s(), { navigateTo: D } = e(), [O, k] = h("ALL"), A = p(O === "ALL" ? null : O), j = m(), M = A.data?.pages.flatMap((e) => e.items) ?? [], N = j.data?.totals.filter((e) => e.firstYearSavings > 0).map((e) => i(e.firstYearSavings, e.currency)).join(" + ") || i(0, "USD"), P = /* @__PURE__ */ C("button", {
30
+ function T() {
31
+ let { formatCurrency: T, formatDate: E } = n(), D = t(), { navigateTo: O } = e(), [k, A] = m("ALL"), j = f(k === "ALL" ? null : k), M = p(), N = j.data?.pages.flatMap((e) => e.items) ?? [], P = M.data?.totals.filter((e) => e.firstYearSavings > 0).map((e) => T(e.firstYearSavings, e.currency)).join(" + ") || T(0, "USD"), F = /* @__PURE__ */ S("button", {
32
32
  type: "button",
33
- onClick: () => D("/procurement/new"),
33
+ onClick: () => O("/procurement/new"),
34
34
  className: "inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90",
35
35
  children: [
36
- /* @__PURE__ */ S(y, {
36
+ /* @__PURE__ */ x(v, {
37
37
  className: "h-4 w-4",
38
38
  "aria-hidden": !0
39
39
  }),
40
40
  " ",
41
- E("procurement.new", "Request an expert negotiation")
41
+ D("procurement.new", "Request an expert negotiation")
42
42
  ]
43
43
  });
44
- return /* @__PURE__ */ C(n, {
45
- title: E("procurement.title", "Expert procurement"),
46
- description: E("procurement.description", "A Subscriber Bot procurement expert negotiates your SaaS renewals and purchases for you."),
47
- actions: P,
44
+ return /* @__PURE__ */ S(i, {
45
+ title: D("procurement.title", "Expert procurement"),
46
+ description: D("procurement.description", "A Subscriber Bot procurement expert negotiates your SaaS renewals and purchases for you."),
47
+ actions: F,
48
48
  children: [
49
- /* @__PURE__ */ S(w, {
49
+ /* @__PURE__ */ x(C, {
50
50
  className: "mb-6",
51
- children: E("procurement.purpose", "Send a renewal, a new purchase or an expansion to the procurement desk. An expert is assigned, talks to the vendor for you and brings back the best offer; you review and sign it yourself. The desk only charges a share of the first-year savings it secures: no savings, no fee.")
51
+ children: D("procurement.purpose", "Send a renewal, a new purchase or an expansion to the procurement desk. An expert is assigned, talks to the vendor for you and brings back the best offer; you review and sign it yourself. The desk only charges a share of the first-year savings it secures: no savings, no fee.")
52
52
  }),
53
- !j.isError && /* @__PURE__ */ C("div", {
53
+ !M.isError && /* @__PURE__ */ S("div", {
54
54
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
55
55
  children: [
56
- /* @__PURE__ */ S(r, {
57
- icon: /* @__PURE__ */ S(b, { className: "h-5 w-5" }),
58
- value: j.isLoading ? "—" : j.data?.openCount ?? 0,
59
- label: E("procurement.metrics.open", "Open requests")
56
+ /* @__PURE__ */ x(a, {
57
+ icon: /* @__PURE__ */ x(y, { className: "h-5 w-5" }),
58
+ value: M.isLoading ? "—" : M.data?.openCount ?? 0,
59
+ label: D("procurement.metrics.open", "Open requests")
60
60
  }),
61
- /* @__PURE__ */ S(r, {
62
- icon: /* @__PURE__ */ S(_, { className: "h-5 w-5" }),
63
- value: j.isLoading ? "—" : j.data?.succeededCount ?? 0,
64
- label: E("procurement.metrics.succeeded", "Contracts negotiated down")
61
+ /* @__PURE__ */ x(a, {
62
+ icon: /* @__PURE__ */ x(g, { className: "h-5 w-5" }),
63
+ value: M.isLoading ? "—" : M.data?.succeededCount ?? 0,
64
+ label: D("procurement.metrics.succeeded", "Contracts negotiated down")
65
65
  }),
66
- /* @__PURE__ */ S(r, {
67
- icon: /* @__PURE__ */ S(v, { className: "h-5 w-5" }),
68
- value: j.isLoading ? "—" : N,
69
- label: E("procurement.metrics.savings", "First-year savings")
66
+ /* @__PURE__ */ x(a, {
67
+ icon: /* @__PURE__ */ x(_, { className: "h-5 w-5" }),
68
+ value: M.isLoading ? "—" : P,
69
+ label: D("procurement.metrics.savings", "First-year savings")
70
70
  }),
71
- /* @__PURE__ */ S(r, {
72
- icon: /* @__PURE__ */ S(g, { className: "h-5 w-5" }),
73
- value: j.isLoading ? "—" : j.data?.noSavingsCount ?? 0,
74
- label: E("procurement.metrics.noSavings", "No savings (no fee)")
71
+ /* @__PURE__ */ x(a, {
72
+ icon: /* @__PURE__ */ x(h, { className: "h-5 w-5" }),
73
+ value: M.isLoading ? "—" : M.data?.noSavingsCount ?? 0,
74
+ label: D("procurement.metrics.noSavings", "No savings (no fee)")
75
75
  })
76
76
  ]
77
77
  }),
78
- /* @__PURE__ */ S("div", {
78
+ /* @__PURE__ */ x("div", {
79
79
  role: "tablist",
80
- "aria-label": E("procurement.filter.label", "Request status"),
80
+ "aria-label": D("procurement.filter.label", "Request status"),
81
81
  className: "mt-6 flex flex-wrap gap-1.5",
82
- children: T.map((e) => /* @__PURE__ */ S("button", {
82
+ children: w.map((e) => /* @__PURE__ */ x("button", {
83
83
  type: "button",
84
84
  role: "tab",
85
- "aria-selected": O === e,
86
- onClick: () => k(e),
87
- className: t("rounded-lg px-3 py-1.5 text-xs font-medium", O === e ? "bg-action-primary-bg text-action-primary-text" : "border border-border-subtle text-text-primary hover:bg-bg-sunken"),
88
- children: e === "ALL" ? E("procurement.filter.all", "All") : E(d[e].key, d[e].fallback)
85
+ "aria-selected": k === e,
86
+ onClick: () => A(e),
87
+ className: r("rounded-lg px-3 py-1.5 text-xs font-medium", k === e ? "bg-action-primary-bg text-action-primary-text" : "border border-border-subtle text-text-primary hover:bg-bg-sunken"),
88
+ children: e === "ALL" ? D("procurement.filter.all", "All") : D(u[e].key, u[e].fallback)
89
89
  }, e))
90
90
  }),
91
- /* @__PURE__ */ C("div", {
91
+ /* @__PURE__ */ S("div", {
92
92
  className: "mt-4",
93
- children: [A.isLoading ? /* @__PURE__ */ S(l, { label: E("procurement.loading", "Loading procurement requests…") }) : A.isError ? /* @__PURE__ */ S(c, {
94
- message: A.error instanceof Error ? A.error.message : void 0,
95
- onRetry: () => void A.refetch()
96
- }) : M.length === 0 ? /* @__PURE__ */ S(o, {
93
+ children: [j.isLoading ? /* @__PURE__ */ x(c, { label: D("procurement.loading", "Loading procurement requests…") }) : j.isError ? /* @__PURE__ */ x(s, {
94
+ message: j.error instanceof Error ? j.error.message : void 0,
95
+ onRetry: () => void j.refetch()
96
+ }) : N.length === 0 ? /* @__PURE__ */ x(o, {
97
97
  illustration: "empty-data",
98
- title: E("procurement.empty.title", "No procurement requests yet"),
99
- description: E("procurement.empty.description", "Have a renewal coming up or a quote on the table? Send it to the procurement desk and an expert will negotiate it for you."),
100
- action: P
101
- }) : /* @__PURE__ */ S("ul", {
98
+ title: D("procurement.empty.title", "No procurement requests yet"),
99
+ description: D("procurement.empty.description", "Have a renewal coming up or a quote on the table? Send it to the procurement desk and an expert will negotiate it for you."),
100
+ action: F
101
+ }) : /* @__PURE__ */ x("ul", {
102
102
  className: "grid grid-cols-1 gap-3 lg:grid-cols-2",
103
103
  "data-testid": "procurement-list",
104
- children: M.map((e) => /* @__PURE__ */ S("li", { children: /* @__PURE__ */ C("button", {
104
+ children: N.map((e) => /* @__PURE__ */ x("li", { children: /* @__PURE__ */ S("button", {
105
105
  type: "button",
106
- onClick: () => D(`/procurement/${e.id}`),
107
- className: "w-full rounded-xl border border-border-subtle bg-bg-surface p-4 text-left hover:bg-bg-sunken focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
108
- children: [/* @__PURE__ */ C("div", {
106
+ onClick: () => O(`/procurement/${e.id}`),
107
+ className: "w-full rounded-xl border border-border-subtle bg-bg-surface p-4 text-start hover:bg-bg-sunken focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
108
+ children: [/* @__PURE__ */ S("div", {
109
109
  className: "flex items-start justify-between gap-3",
110
- children: [/* @__PURE__ */ C("div", {
110
+ children: [/* @__PURE__ */ S("div", {
111
111
  className: "min-w-0",
112
- children: [/* @__PURE__ */ C("p", {
112
+ children: [/* @__PURE__ */ S("p", {
113
113
  className: "truncate text-sm font-semibold text-text-primary",
114
114
  children: [e.vendorName, e.productName ? ` · ${e.productName}` : ""]
115
- }), /* @__PURE__ */ C("p", {
115
+ }), /* @__PURE__ */ S("p", {
116
116
  className: "mt-0.5 text-xs text-text-secondary",
117
117
  children: [
118
- E(u[e.requestType].key, u[e.requestType].fallback),
118
+ D(l[e.requestType].key, l[e.requestType].fallback),
119
119
  " · ",
120
- E("procurement.card.deadline", "Decide by {{date}}", { date: a(e.deadline) }),
120
+ D("procurement.card.deadline", "Decide by {{date}}", { date: E(e.deadline) }),
121
121
  e.expertName ? ` · ${e.expertName}` : ""
122
122
  ]
123
123
  })]
124
- }), /* @__PURE__ */ S(f, { status: e.status })]
125
- }), /* @__PURE__ */ C("div", {
124
+ }), /* @__PURE__ */ x(d, { status: e.status })]
125
+ }), /* @__PURE__ */ S("div", {
126
126
  className: "mt-3 flex flex-wrap items-end justify-between gap-2 text-sm",
127
- children: [/* @__PURE__ */ C("span", {
127
+ children: [/* @__PURE__ */ S("span", {
128
128
  className: "text-text-primary",
129
- children: [e.baselineAnnualValue == null ? "—" : E("procurement.card.perYear", "{{amount}} / year", { amount: i(e.baselineAnnualValue, e.currency) }), e.finalAnnualValue != null && e.status === "SUCCEEDED" && /* @__PURE__ */ C(x, { children: [" → ", /* @__PURE__ */ S("span", {
129
+ children: [e.baselineAnnualValue == null ? "—" : D("procurement.card.perYear", "{{amount}} / year", { amount: T(e.baselineAnnualValue, e.currency) }), e.finalAnnualValue != null && e.status === "SUCCEEDED" && /* @__PURE__ */ S(b, { children: [" → ", /* @__PURE__ */ x("span", {
130
130
  className: "font-semibold text-status-success-text",
131
- children: i(e.finalAnnualValue, e.currency)
131
+ children: T(e.finalAnnualValue, e.currency)
132
132
  })] })]
133
- }), /* @__PURE__ */ S("span", {
133
+ }), /* @__PURE__ */ x("span", {
134
134
  className: "text-xs text-text-secondary",
135
- children: e.firstYearSavings > 0 ? E("procurement.card.saved", "Saves {{amount}} in year one", { amount: i(e.firstYearSavings, e.currency) }) : a(e.createdAt)
135
+ children: e.firstYearSavings > 0 ? D("procurement.card.saved", "Saves {{amount}} in year one", { amount: T(e.firstYearSavings, e.currency) }) : E(e.createdAt)
136
136
  })]
137
137
  })]
138
138
  }) }, e.id))
139
- }), A.hasNextPage && /* @__PURE__ */ S("div", {
139
+ }), j.hasNextPage && /* @__PURE__ */ x("div", {
140
140
  className: "mt-4 flex justify-center",
141
- children: /* @__PURE__ */ S("button", {
141
+ children: /* @__PURE__ */ x("button", {
142
142
  type: "button",
143
- disabled: A.isFetchingNextPage,
144
- onClick: () => void A.fetchNextPage(),
143
+ disabled: j.isFetchingNextPage,
144
+ onClick: () => void j.fetchNextPage(),
145
145
  className: "rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50",
146
- children: A.isFetchingNextPage ? E("procurement.loadingMore", "Loading…") : E("procurement.loadMore", "Load more")
146
+ children: j.isFetchingNextPage ? D("procurement.loadingMore", "Loading…") : D("procurement.loadMore", "Load more")
147
147
  })
148
148
  })]
149
149
  })
@@ -151,6 +151,6 @@ function E() {
151
151
  });
152
152
  }
153
153
  //#endregion
154
- export { E as ProcurementPage };
154
+ export { T as ProcurementPage };
155
155
 
156
156
  //# sourceMappingURL=ProcurementPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProcurementPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/procurement/ProcurementPage.tsx"],"sourcesContent":["/**\n * Human procurement overview\n * @module subscriberbot/pages/procurement\n *\n * `/subscriberbot/procurement` — every expert procurement request in the\n * workspace (BOFF-4158) with the savings Subscriber Bot's procurement experts\n * secured, backed by the real `subListProcurementRequests` /\n * `subProcurementSummary` queries.\n */\n\nimport { useState } from 'react';\nimport { BadgePercent, Briefcase, PiggyBank, Plus, Timer } from 'lucide-react';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { EmptyState, ErrorView, LoadingView, MetricsCard, PageLayout } from '../../components';\nimport {\n ProcurementStatusPill,\n REQUEST_TYPE_LABEL,\n STATUS_LABEL,\n} from '../../components/procurement';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useProcurementRequests, useProcurementSummary } from '../../hooks/useProcurementApi';\nimport { useTr } from '../../hooks/useTr';\nimport { cn } from '../../utils/cn';\nimport { formatCurrency, formatDate } from '../../utils/formatters';\nimport type { SubProcurementStatus } from '../../types/procurement';\n\nconst FILTERS: Array<SubProcurementStatus | 'ALL'> = [\n 'ALL',\n 'DRAFT',\n 'SUBMITTED',\n 'ASSIGNED',\n 'IN_PROGRESS',\n 'AWAITING_CUSTOMER',\n 'SUCCEEDED',\n 'NO_SAVINGS',\n 'CANCELLED',\n];\n\nexport function ProcurementPage() {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [filter, setFilter] = useState<SubProcurementStatus | 'ALL'>('ALL');\n const list = useProcurementRequests(filter === 'ALL' ? null : filter);\n const summary = useProcurementSummary();\n const items = list.data?.pages.flatMap((page) => page.items) ?? [];\n\n const savingsText =\n summary.data?.totals\n .filter((t) => t.firstYearSavings > 0)\n .map((t) => formatCurrency(t.firstYearSavings, t.currency))\n .join(' + ') || formatCurrency(0, 'USD');\n\n const newButton = (\n <button\n type=\"button\"\n onClick={() => navigateTo('/procurement/new')}\n className=\"inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n <Plus className=\"h-4 w-4\" aria-hidden />{' '}\n {tr('procurement.new', 'Request an expert negotiation')}\n </button>\n );\n\n return (\n <PageLayout\n title={tr('procurement.title', 'Expert procurement')}\n description={tr(\n 'procurement.description',\n 'A Subscriber Bot procurement expert negotiates your SaaS renewals and purchases for you.'\n )}\n actions={newButton}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'procurement.purpose',\n 'Send a renewal, a new purchase or an expansion to the procurement desk. An expert is assigned, talks to the vendor for you and brings back the best offer; you review and sign it yourself. The desk only charges a share of the first-year savings it secures: no savings, no fee.'\n )}\n </PagePurpose>\n\n {!summary.isError && (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <MetricsCard\n icon={<Timer className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.openCount ?? 0)}\n label={tr('procurement.metrics.open', 'Open requests')}\n />\n <MetricsCard\n icon={<Briefcase className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.succeededCount ?? 0)}\n label={tr('procurement.metrics.succeeded', 'Contracts negotiated down')}\n />\n <MetricsCard\n icon={<PiggyBank className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : savingsText}\n label={tr('procurement.metrics.savings', 'First-year savings')}\n />\n <MetricsCard\n icon={<BadgePercent className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.noSavingsCount ?? 0)}\n label={tr('procurement.metrics.noSavings', 'No savings (no fee)')}\n />\n </div>\n )}\n\n <div\n role=\"tablist\"\n aria-label={tr('procurement.filter.label', 'Request status')}\n className=\"mt-6 flex flex-wrap gap-1.5\"\n >\n {FILTERS.map((f) => (\n <button\n key={f}\n type=\"button\"\n role=\"tab\"\n aria-selected={filter === f}\n onClick={() => setFilter(f)}\n className={cn(\n 'rounded-lg px-3 py-1.5 text-xs font-medium',\n filter === f\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'border border-border-subtle text-text-primary hover:bg-bg-sunken'\n )}\n >\n {f === 'ALL'\n ? tr('procurement.filter.all', 'All')\n : tr(STATUS_LABEL[f].key, STATUS_LABEL[f].fallback)}\n </button>\n ))}\n </div>\n\n <div className=\"mt-4\">\n {list.isLoading ? (\n <LoadingView label={tr('procurement.loading', 'Loading procurement requests…')} />\n ) : list.isError ? (\n <ErrorView\n message={list.error instanceof Error ? list.error.message : undefined}\n onRetry={() => void list.refetch()}\n />\n ) : items.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('procurement.empty.title', 'No procurement requests yet')}\n description={tr(\n 'procurement.empty.description',\n 'Have a renewal coming up or a quote on the table? Send it to the procurement desk and an expert will negotiate it for you.'\n )}\n action={newButton}\n />\n ) : (\n <ul className=\"grid grid-cols-1 gap-3 lg:grid-cols-2\" data-testid=\"procurement-list\">\n {items.map((p) => (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/procurement/${p.id}`)}\n className=\"w-full rounded-xl border border-border-subtle bg-bg-surface p-4 text-left hover:bg-bg-sunken focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {p.vendorName}\n {p.productName ? ` · ${p.productName}` : ''}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n REQUEST_TYPE_LABEL[p.requestType].key,\n REQUEST_TYPE_LABEL[p.requestType].fallback\n )}\n {' · '}\n {tr('procurement.card.deadline', 'Decide by {{date}}', {\n date: formatDate(p.deadline),\n })}\n {p.expertName ? ` · ${p.expertName}` : ''}\n </p>\n </div>\n <ProcurementStatusPill status={p.status} />\n </div>\n <div className=\"mt-3 flex flex-wrap items-end justify-between gap-2 text-sm\">\n <span className=\"text-text-primary\">\n {p.baselineAnnualValue != null\n ? tr('procurement.card.perYear', '{{amount}} / year', {\n amount: formatCurrency(p.baselineAnnualValue, p.currency),\n })\n : '—'}\n {p.finalAnnualValue != null && p.status === 'SUCCEEDED' && (\n <>\n {' → '}\n <span className=\"font-semibold text-status-success-text\">\n {formatCurrency(p.finalAnnualValue, p.currency)}\n </span>\n </>\n )}\n </span>\n <span className=\"text-xs text-text-secondary\">\n {p.firstYearSavings > 0\n ? tr('procurement.card.saved', 'Saves {{amount}} in year one', {\n amount: formatCurrency(p.firstYearSavings, p.currency),\n })\n : formatDate(p.createdAt)}\n </span>\n </div>\n </button>\n </li>\n ))}\n </ul>\n )}\n {list.hasNextPage && (\n <div className=\"mt-4 flex justify-center\">\n <button\n type=\"button\"\n disabled={list.isFetchingNextPage}\n onClick={() => void list.fetchNextPage()}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n {list.isFetchingNextPage\n ? tr('procurement.loadingMore', 'Loading…')\n : tr('procurement.loadMore', 'Load more')}\n </button>\n </div>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAM,IAA+C;CACnD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,IAAkB;CAChC,IAAM,IAAK,EAAM,GACX,EAAE,kBAAe,EAAiB,GAClC,CAAC,GAAQ,KAAa,EAAuC,KAAK,GAClE,IAAO,EAAuB,MAAW,QAAQ,OAAO,CAAM,GAC9D,IAAU,EAAsB,GAChC,IAAQ,EAAK,MAAM,MAAM,SAAS,MAAS,EAAK,KAAK,KAAK,CAAC,GAE3D,IACJ,EAAQ,MAAM,OACX,QAAQ,MAAM,EAAE,mBAAmB,CAAC,EACpC,KAAK,MAAM,EAAe,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EACzD,KAAK,KAAK,KAAK,EAAe,GAAG,KAAK,GAErC,IACJ,kBAAC,UAAD;EACE,MAAK;EACL,eAAe,EAAW,kBAAkB;EAC5C,WAAU;YAHZ;GAKE,kBAAC,GAAD;IAAM,WAAU;IAAU,eAAA;GAAa,CAAA;GAAE;GACxC,EAAG,mBAAmB,+BAA+B;EAChD;;CAGV,OACE,kBAAC,GAAD;EACE,OAAO,EAAG,qBAAqB,oBAAoB;EACnD,aAAa,EACX,2BACA,0FACF;EACA,SAAS;YANX;GAQE,kBAAC,G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A,CAEA;WACN,kBAAC,QAAD;QAAM,WAAU;kBACb,EAAE,mBAAmB,IAClB,EAAG,0BAA0B,gCAAgC,EAC3D,QAAQ,EAAe,EAAE,kBAAkB,EAAE,QAAQ,EACvD,CAAC,IACD,EAAW,EAAE,SAAS;OACtB,CAAA,CACH;QACC;QACN,GAnDK,EAAE,EAmDP,CACL;IACC,CAAA,GAEL,EAAK,eACJ,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,UAAD;MACE,MAAK;MACL,UAAU,EAAK;MACf,eAAe,KAAK,EAAK,cAAc;MACvC,WAAU;gBAET,EAAK,qBACF,EAAG,2BAA2B,UAAU,IACxC,EAAG,wBAAwB,WAAW;KACpC,CAAA;IACL,CAAA,CAEJ;;EACK;;AAEhB"}
1
+ {"version":3,"file":"ProcurementPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/procurement/ProcurementPage.tsx"],"sourcesContent":["import { useFormatters } from '../../hooks/useFormatters';\n/**\n * Human procurement overview\n * @module subscriberbot/pages/procurement\n *\n * `/subscriberbot/procurement` — every expert procurement request in the\n * workspace (BOFF-4158) with the savings Subscriber Bot's procurement experts\n * secured, backed by the real `subListProcurementRequests` /\n * `subProcurementSummary` queries.\n */\n\nimport { useState } from 'react';\nimport { BadgePercent, Briefcase, PiggyBank, Plus, Timer } from 'lucide-react';\nimport { PagePurpose } from '@burdenoff/fe-libs/ui';\nimport { EmptyState, ErrorView, LoadingView, MetricsCard, PageLayout } from '../../components';\nimport {\n ProcurementStatusPill,\n REQUEST_TYPE_LABEL,\n STATUS_LABEL,\n} from '../../components/procurement';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useProcurementRequests, useProcurementSummary } from '../../hooks/useProcurementApi';\nimport { useTr } from '../../hooks/useTr';\nimport { cn } from '../../utils/cn';\n\nimport type { SubProcurementStatus } from '../../types/procurement';\n\nconst FILTERS: Array<SubProcurementStatus | 'ALL'> = [\n 'ALL',\n 'DRAFT',\n 'SUBMITTED',\n 'ASSIGNED',\n 'IN_PROGRESS',\n 'AWAITING_CUSTOMER',\n 'SUCCEEDED',\n 'NO_SAVINGS',\n 'CANCELLED',\n];\n\nexport function ProcurementPage() {\n const { formatCurrency, formatDate } = useFormatters();\n\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [filter, setFilter] = useState<SubProcurementStatus | 'ALL'>('ALL');\n const list = useProcurementRequests(filter === 'ALL' ? null : filter);\n const summary = useProcurementSummary();\n const items = list.data?.pages.flatMap((page) => page.items) ?? [];\n\n const savingsText =\n summary.data?.totals\n .filter((t) => t.firstYearSavings > 0)\n .map((t) => formatCurrency(t.firstYearSavings, t.currency))\n .join(' + ') || formatCurrency(0, 'USD');\n\n const newButton = (\n <button\n type=\"button\"\n onClick={() => navigateTo('/procurement/new')}\n className=\"inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n <Plus className=\"h-4 w-4\" aria-hidden />{' '}\n {tr('procurement.new', 'Request an expert negotiation')}\n </button>\n );\n\n return (\n <PageLayout\n title={tr('procurement.title', 'Expert procurement')}\n description={tr(\n 'procurement.description',\n 'A Subscriber Bot procurement expert negotiates your SaaS renewals and purchases for you.'\n )}\n actions={newButton}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'procurement.purpose',\n 'Send a renewal, a new purchase or an expansion to the procurement desk. An expert is assigned, talks to the vendor for you and brings back the best offer; you review and sign it yourself. The desk only charges a share of the first-year savings it secures: no savings, no fee.'\n )}\n </PagePurpose>\n\n {!summary.isError && (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <MetricsCard\n icon={<Timer className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.openCount ?? 0)}\n label={tr('procurement.metrics.open', 'Open requests')}\n />\n <MetricsCard\n icon={<Briefcase className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.succeededCount ?? 0)}\n label={tr('procurement.metrics.succeeded', 'Contracts negotiated down')}\n />\n <MetricsCard\n icon={<PiggyBank className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : savingsText}\n label={tr('procurement.metrics.savings', 'First-year savings')}\n />\n <MetricsCard\n icon={<BadgePercent className=\"h-5 w-5\" />}\n value={summary.isLoading ? '—' : (summary.data?.noSavingsCount ?? 0)}\n label={tr('procurement.metrics.noSavings', 'No savings (no fee)')}\n />\n </div>\n )}\n\n <div\n role=\"tablist\"\n aria-label={tr('procurement.filter.label', 'Request status')}\n className=\"mt-6 flex flex-wrap gap-1.5\"\n >\n {FILTERS.map((f) => (\n <button\n key={f}\n type=\"button\"\n role=\"tab\"\n aria-selected={filter === f}\n onClick={() => setFilter(f)}\n className={cn(\n 'rounded-lg px-3 py-1.5 text-xs font-medium',\n filter === f\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'border border-border-subtle text-text-primary hover:bg-bg-sunken'\n )}\n >\n {f === 'ALL'\n ? tr('procurement.filter.all', 'All')\n : tr(STATUS_LABEL[f].key, STATUS_LABEL[f].fallback)}\n </button>\n ))}\n </div>\n\n <div className=\"mt-4\">\n {list.isLoading ? (\n <LoadingView label={tr('procurement.loading', 'Loading procurement requests…')} />\n ) : list.isError ? (\n <ErrorView\n message={list.error instanceof Error ? list.error.message : undefined}\n onRetry={() => void list.refetch()}\n />\n ) : items.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('procurement.empty.title', 'No procurement requests yet')}\n description={tr(\n 'procurement.empty.description',\n 'Have a renewal coming up or a quote on the table? Send it to the procurement desk and an expert will negotiate it for you.'\n )}\n action={newButton}\n />\n ) : (\n <ul className=\"grid grid-cols-1 gap-3 lg:grid-cols-2\" data-testid=\"procurement-list\">\n {items.map((p) => (\n <li key={p.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/procurement/${p.id}`)}\n className=\"w-full rounded-xl border border-border-subtle bg-bg-surface p-4 text-start hover:bg-bg-sunken focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">\n {p.vendorName}\n {p.productName ? ` · ${p.productName}` : ''}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n REQUEST_TYPE_LABEL[p.requestType].key,\n REQUEST_TYPE_LABEL[p.requestType].fallback\n )}\n {' · '}\n {tr('procurement.card.deadline', 'Decide by {{date}}', {\n date: formatDate(p.deadline),\n })}\n {p.expertName ? ` · ${p.expertName}` : ''}\n </p>\n </div>\n <ProcurementStatusPill status={p.status} />\n </div>\n <div className=\"mt-3 flex flex-wrap items-end justify-between gap-2 text-sm\">\n <span className=\"text-text-primary\">\n {p.baselineAnnualValue != null\n ? tr('procurement.card.perYear', '{{amount}} / year', {\n amount: formatCurrency(p.baselineAnnualValue, p.currency),\n })\n : '—'}\n {p.finalAnnualValue != null && p.status === 'SUCCEEDED' && (\n <>\n {' → '}\n <span className=\"font-semibold text-status-success-text\">\n {formatCurrency(p.finalAnnualValue, p.currency)}\n </span>\n </>\n )}\n </span>\n <span className=\"text-xs text-text-secondary\">\n {p.firstYearSavings > 0\n ? tr('procurement.card.saved', 'Saves {{amount}} in year one', {\n amount: formatCurrency(p.firstYearSavings, p.currency),\n })\n : formatDate(p.createdAt)}\n </span>\n </div>\n </button>\n </li>\n ))}\n </ul>\n )}\n {list.hasNextPage && (\n <div className=\"mt-4 flex justify-center\">\n <button\n type=\"button\"\n disabled={list.isFetchingNextPage}\n onClick={() => void list.fetchNextPage()}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n {list.isFetchingNextPage\n ? tr('procurement.loadingMore', 'Loading…')\n : tr('procurement.loadMore', 'Load more')}\n </button>\n </div>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,IAAM,IAA+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,CAAA,CAEJ;;EACK;;AAEhB"}
@@ -1,12 +1,2 @@
1
- /**
2
- * Provider detail
3
- * @module subscriberbot/pages/providers
4
- *
5
- * A provider profile from the registry: category, status, region, scores,
6
- * tags and its published plans. Reads `subProvider(id)` and
7
- * `subListBenchmarkDataPoints` (the observed price points behind the "Price
8
- * history" card); writes `subUpdateProvider`, `subArchiveProvider`,
9
- * `subCreatePlan`.
10
- */
11
1
  export declare function ProviderDetailPage(): import("react").JSX.Element;
12
2
  //# sourceMappingURL=ProviderDetailPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProviderDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/providers/ProviderDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoxBH,wBAAgB,kBAAkB,gCAsWjC"}
1
+ {"version":3,"file":"ProviderDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/providers/ProviderDetailPage.tsx"],"names":[],"mappings":"AAo0BA,wBAAgB,kBAAkB,gCAyWjC"}