@prenta/admin 2.9.2 → 2.10.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 (360) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/design-system/tokens.css +2 -1
  3. package/design-system/tokens.json +5 -1
  4. package/design-system/tokens.scss +1 -1
  5. package/dist/AdminRoot.d.ts.map +1 -1
  6. package/dist/AdminRoot.js +5 -3
  7. package/dist/AdminRoot.js.map +1 -1
  8. package/dist/__tests__/components/attribution-rows.test.js +1 -1
  9. package/dist/__tests__/components/attribution-rows.test.js.map +1 -1
  10. package/dist/__tests__/components/date-range-picker.test.d.ts +2 -0
  11. package/dist/__tests__/components/date-range-picker.test.d.ts.map +1 -0
  12. package/dist/__tests__/components/date-range-picker.test.js +59 -0
  13. package/dist/__tests__/components/date-range-picker.test.js.map +1 -0
  14. package/dist/__tests__/components/form-build-model.test.d.ts +2 -0
  15. package/dist/__tests__/components/form-build-model.test.d.ts.map +1 -0
  16. package/dist/__tests__/components/form-build-model.test.js +162 -0
  17. package/dist/__tests__/components/form-build-model.test.js.map +1 -0
  18. package/dist/__tests__/components/form-build.test.d.ts +2 -0
  19. package/dist/__tests__/components/form-build.test.d.ts.map +1 -0
  20. package/dist/__tests__/components/form-build.test.js +120 -0
  21. package/dist/__tests__/components/form-build.test.js.map +1 -0
  22. package/dist/__tests__/components/qa-a11y.render.test.d.ts +2 -0
  23. package/dist/__tests__/components/qa-a11y.render.test.d.ts.map +1 -0
  24. package/dist/__tests__/components/qa-a11y.render.test.js +30 -0
  25. package/dist/__tests__/components/qa-a11y.render.test.js.map +1 -0
  26. package/dist/__tests__/components/responsive-tiers.render.test.js +12 -0
  27. package/dist/__tests__/components/responsive-tiers.render.test.js.map +1 -1
  28. package/dist/__tests__/components/ui-primitives.test.js +7 -0
  29. package/dist/__tests__/components/ui-primitives.test.js.map +1 -1
  30. package/dist/__tests__/layout/shell-nav.render.test.js +5 -0
  31. package/dist/__tests__/layout/shell-nav.render.test.js.map +1 -1
  32. package/dist/__tests__/lib/batch-wizard.test.js +2 -0
  33. package/dist/__tests__/lib/batch-wizard.test.js.map +1 -1
  34. package/dist/__tests__/lib/forms-settings-normalize.test.d.ts +2 -0
  35. package/dist/__tests__/lib/forms-settings-normalize.test.d.ts.map +1 -0
  36. package/dist/__tests__/lib/forms-settings-normalize.test.js +16 -0
  37. package/dist/__tests__/lib/forms-settings-normalize.test.js.map +1 -0
  38. package/dist/__tests__/styles/qa-contrast.test.d.ts +2 -0
  39. package/dist/__tests__/styles/qa-contrast.test.d.ts.map +1 -0
  40. package/dist/__tests__/styles/qa-contrast.test.js +78 -0
  41. package/dist/__tests__/styles/qa-contrast.test.js.map +1 -0
  42. package/dist/__tests__/views/ai-settings.render.test.js +21 -0
  43. package/dist/__tests__/views/ai-settings.render.test.js.map +1 -1
  44. package/dist/__tests__/views/appearance-chrome.render.test.js +9 -0
  45. package/dist/__tests__/views/appearance-chrome.render.test.js.map +1 -1
  46. package/dist/__tests__/views/dashboard.test.js +105 -30
  47. package/dist/__tests__/views/dashboard.test.js.map +1 -1
  48. package/dist/__tests__/views/form-editor.render.test.js +17 -9
  49. package/dist/__tests__/views/form-editor.render.test.js.map +1 -1
  50. package/dist/__tests__/views/form-entries.render.test.js +23 -9
  51. package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
  52. package/dist/__tests__/views/form-submissions.render.test.js +13 -14
  53. package/dist/__tests__/views/form-submissions.render.test.js.map +1 -1
  54. package/dist/__tests__/views/forms-list.render.test.js +139 -16
  55. package/dist/__tests__/views/forms-list.render.test.js.map +1 -1
  56. package/dist/__tests__/views/forms-settings.fixture.d.ts +3 -0
  57. package/dist/__tests__/views/forms-settings.fixture.d.ts.map +1 -0
  58. package/dist/__tests__/views/forms-settings.fixture.js +31 -0
  59. package/dist/__tests__/views/forms-settings.fixture.js.map +1 -0
  60. package/dist/__tests__/views/forms-settings.render.test.d.ts +2 -0
  61. package/dist/__tests__/views/forms-settings.render.test.d.ts.map +1 -0
  62. package/dist/__tests__/views/forms-settings.render.test.js +120 -0
  63. package/dist/__tests__/views/forms-settings.render.test.js.map +1 -0
  64. package/dist/__tests__/views/inbox-format.test.d.ts +2 -0
  65. package/dist/__tests__/views/inbox-format.test.d.ts.map +1 -0
  66. package/dist/__tests__/views/inbox-format.test.js +47 -0
  67. package/dist/__tests__/views/inbox-format.test.js.map +1 -0
  68. package/dist/__tests__/views/jobs-list.render.test.js +2 -0
  69. package/dist/__tests__/views/jobs-list.render.test.js.map +1 -1
  70. package/dist/__tests__/views/jobs-wizard.render.test.js +17 -3
  71. package/dist/__tests__/views/jobs-wizard.render.test.js.map +1 -1
  72. package/dist/__tests__/views/onboarding-block.render.test.js +9 -7
  73. package/dist/__tests__/views/onboarding-block.render.test.js.map +1 -1
  74. package/dist/__tests__/views/run-with-ai.render.test.js +9 -0
  75. package/dist/__tests__/views/run-with-ai.render.test.js.map +1 -1
  76. package/dist/__tests__/views/script-tags.render.test.js +8 -0
  77. package/dist/__tests__/views/script-tags.render.test.js.map +1 -1
  78. package/dist/__tests__/views/settings-tabs.render.test.js +5 -0
  79. package/dist/__tests__/views/settings-tabs.render.test.js.map +1 -1
  80. package/dist/components/SEOConfigPanel.js +2 -2
  81. package/dist/components/SEOConfigPanel.js.map +1 -1
  82. package/dist/components/forms/BlocklistDialog.d.ts +19 -0
  83. package/dist/components/forms/BlocklistDialog.d.ts.map +1 -0
  84. package/dist/components/forms/BlocklistDialog.js +225 -0
  85. package/dist/components/forms/BlocklistDialog.js.map +1 -0
  86. package/dist/components/forms/ExportMenu.d.ts +3 -1
  87. package/dist/components/forms/ExportMenu.d.ts.map +1 -1
  88. package/dist/components/forms/ExportMenu.js +2 -2
  89. package/dist/components/forms/ExportMenu.js.map +1 -1
  90. package/dist/components/forms/FieldOptions.d.ts +11 -0
  91. package/dist/components/forms/FieldOptions.d.ts.map +1 -0
  92. package/dist/components/forms/FieldOptions.js +106 -0
  93. package/dist/components/forms/FieldOptions.js.map +1 -0
  94. package/dist/components/forms/FormBuild.d.ts +11 -0
  95. package/dist/components/forms/FormBuild.d.ts.map +1 -0
  96. package/dist/components/forms/FormBuild.js +299 -0
  97. package/dist/components/forms/FormBuild.js.map +1 -0
  98. package/dist/components/forms/FormsListTable.d.ts +14 -0
  99. package/dist/components/forms/FormsListTable.d.ts.map +1 -0
  100. package/dist/components/forms/FormsListTable.js +84 -0
  101. package/dist/components/forms/FormsListTable.js.map +1 -0
  102. package/dist/components/forms/form-build-model.d.ts +74 -0
  103. package/dist/components/forms/form-build-model.d.ts.map +1 -0
  104. package/dist/components/forms/form-build-model.js +297 -0
  105. package/dist/components/forms/form-build-model.js.map +1 -0
  106. package/dist/components/forms/form-build-ui.d.ts +35 -0
  107. package/dist/components/forms/form-build-ui.d.ts.map +1 -0
  108. package/dist/components/forms/form-build-ui.js +59 -0
  109. package/dist/components/forms/form-build-ui.js.map +1 -0
  110. package/dist/components/forms/primitives.d.ts +3 -22
  111. package/dist/components/forms/primitives.d.ts.map +1 -1
  112. package/dist/components/forms/primitives.js +4 -19
  113. package/dist/components/forms/primitives.js.map +1 -1
  114. package/dist/components/seo/PageAuditPanel.js +2 -2
  115. package/dist/components/seo/PageAuditPanel.js.map +1 -1
  116. package/dist/components/seo/primitives.d.ts +1 -1
  117. package/dist/components/seo/primitives.d.ts.map +1 -1
  118. package/dist/components/seo/primitives.js +10 -1
  119. package/dist/components/seo/primitives.js.map +1 -1
  120. package/dist/components/ui/Badge.d.ts +1 -1
  121. package/dist/components/ui/Card.d.ts +1 -1
  122. package/dist/components/ui/DateRangePicker.d.ts +7 -0
  123. package/dist/components/ui/DateRangePicker.d.ts.map +1 -0
  124. package/dist/components/ui/DateRangePicker.js +112 -0
  125. package/dist/components/ui/DateRangePicker.js.map +1 -0
  126. package/dist/components/ui/FilterPill.d.ts.map +1 -1
  127. package/dist/components/ui/FilterPill.js +2 -2
  128. package/dist/components/ui/FilterPill.js.map +1 -1
  129. package/dist/components/ui/Input.d.ts +1 -1
  130. package/dist/components/ui/PageHeader.d.ts +7 -1
  131. package/dist/components/ui/PageHeader.d.ts.map +1 -1
  132. package/dist/components/ui/PageHeader.js +4 -2
  133. package/dist/components/ui/PageHeader.js.map +1 -1
  134. package/dist/components/ui/Segmented.d.ts +3 -1
  135. package/dist/components/ui/Segmented.d.ts.map +1 -1
  136. package/dist/components/ui/Segmented.js +3 -3
  137. package/dist/components/ui/Segmented.js.map +1 -1
  138. package/dist/components/ui/StatusBadge.d.ts +3 -2
  139. package/dist/components/ui/StatusBadge.d.ts.map +1 -1
  140. package/dist/components/ui/StatusBadge.js +9 -3
  141. package/dist/components/ui/StatusBadge.js.map +1 -1
  142. package/dist/components/ui/Toggle.d.ts +1 -1
  143. package/dist/components/ui/Toggle.d.ts.map +1 -1
  144. package/dist/components/ui/Toggle.js +3 -0
  145. package/dist/components/ui/Toggle.js.map +1 -1
  146. package/dist/components/ui/UnderlineTabs.d.ts +5 -1
  147. package/dist/components/ui/UnderlineTabs.d.ts.map +1 -1
  148. package/dist/components/ui/UnderlineTabs.js +14 -11
  149. package/dist/components/ui/UnderlineTabs.js.map +1 -1
  150. package/dist/layout/Sidebar.d.ts.map +1 -1
  151. package/dist/layout/Sidebar.js +7 -2
  152. package/dist/layout/Sidebar.js.map +1 -1
  153. package/dist/lib/batch-wizard.d.ts +1 -1
  154. package/dist/lib/batch-wizard.d.ts.map +1 -1
  155. package/dist/lib/batch-wizard.js +2 -2
  156. package/dist/lib/batch-wizard.js.map +1 -1
  157. package/dist/lib/entry-attribution.d.ts +13 -0
  158. package/dist/lib/entry-attribution.d.ts.map +1 -0
  159. package/dist/lib/entry-attribution.js +81 -0
  160. package/dist/lib/entry-attribution.js.map +1 -0
  161. package/dist/lib/forms-service.d.ts +100 -0
  162. package/dist/lib/forms-service.d.ts.map +1 -1
  163. package/dist/lib/forms-service.js +101 -0
  164. package/dist/lib/forms-service.js.map +1 -1
  165. package/dist/lib/job-drawer.d.ts +1 -0
  166. package/dist/lib/job-drawer.d.ts.map +1 -1
  167. package/dist/lib/job-drawer.js +23 -1
  168. package/dist/lib/job-drawer.js.map +1 -1
  169. package/dist/lib/job-view.d.ts +6 -0
  170. package/dist/lib/job-view.d.ts.map +1 -1
  171. package/dist/lib/job-view.js +7 -0
  172. package/dist/lib/job-view.js.map +1 -1
  173. package/dist/prenta-admin.css +1 -1
  174. package/dist/router/admin-routes.d.ts.map +1 -1
  175. package/dist/router/admin-routes.js +1 -0
  176. package/dist/router/admin-routes.js.map +1 -1
  177. package/dist/views/Dashboard.d.ts.map +1 -1
  178. package/dist/views/Dashboard.js +438 -309
  179. package/dist/views/Dashboard.js.map +1 -1
  180. package/dist/views/FormEditor.d.ts.map +1 -1
  181. package/dist/views/FormEditor.js +68 -13
  182. package/dist/views/FormEditor.js.map +1 -1
  183. package/dist/views/FormEntries.d.ts.map +1 -1
  184. package/dist/views/FormEntries.js +4 -190
  185. package/dist/views/FormEntries.js.map +1 -1
  186. package/dist/views/FormSubmissions.d.ts +1 -1
  187. package/dist/views/FormSubmissions.d.ts.map +1 -1
  188. package/dist/views/FormSubmissions.js +6 -195
  189. package/dist/views/FormSubmissions.js.map +1 -1
  190. package/dist/views/Forms.d.ts +11 -1
  191. package/dist/views/Forms.d.ts.map +1 -1
  192. package/dist/views/Forms.js +141 -93
  193. package/dist/views/Forms.js.map +1 -1
  194. package/dist/views/FormsSettings.d.ts +6 -1
  195. package/dist/views/FormsSettings.d.ts.map +1 -1
  196. package/dist/views/FormsSettings.js +434 -30
  197. package/dist/views/FormsSettings.js.map +1 -1
  198. package/dist/views/Jobs/DrawerReview.d.ts.map +1 -1
  199. package/dist/views/Jobs/DrawerReview.js +8 -7
  200. package/dist/views/Jobs/DrawerReview.js.map +1 -1
  201. package/dist/views/Jobs/NewBatchJob.d.ts.map +1 -1
  202. package/dist/views/Jobs/NewBatchJob.js +2 -1
  203. package/dist/views/Jobs/NewBatchJob.js.map +1 -1
  204. package/dist/views/Jobs.d.ts.map +1 -1
  205. package/dist/views/Jobs.js +1 -1
  206. package/dist/views/Jobs.js.map +1 -1
  207. package/dist/views/MediaBrowser.d.ts.map +1 -1
  208. package/dist/views/MediaBrowser.js +5 -1
  209. package/dist/views/MediaBrowser.js.map +1 -1
  210. package/dist/views/Pages/PagesListView.js +1 -1
  211. package/dist/views/Pages/PagesListView.js.map +1 -1
  212. package/dist/views/Redirects.d.ts.map +1 -1
  213. package/dist/views/Redirects.js +1 -3
  214. package/dist/views/Redirects.js.map +1 -1
  215. package/dist/views/ScriptTags.js +1 -1
  216. package/dist/views/Settings.js +1 -1
  217. package/dist/views/Settings.js.map +1 -1
  218. package/dist/views/SpamFolder.js +1 -1
  219. package/dist/views/SpamFolder.js.map +1 -1
  220. package/dist/views/dashboard/Delta.d.ts +7 -0
  221. package/dist/views/dashboard/Delta.d.ts.map +1 -0
  222. package/dist/views/dashboard/Delta.js +21 -0
  223. package/dist/views/dashboard/Delta.js.map +1 -0
  224. package/dist/views/dashboard/KpiCard.d.ts +22 -0
  225. package/dist/views/dashboard/KpiCard.d.ts.map +1 -0
  226. package/dist/views/dashboard/KpiCard.js +15 -0
  227. package/dist/views/dashboard/KpiCard.js.map +1 -0
  228. package/dist/views/dashboard/Sparkline.d.ts +11 -0
  229. package/dist/views/dashboard/Sparkline.d.ts.map +1 -0
  230. package/dist/views/dashboard/Sparkline.js +15 -0
  231. package/dist/views/dashboard/Sparkline.js.map +1 -0
  232. package/dist/views/dashboard/TrendChart.d.ts +8 -0
  233. package/dist/views/dashboard/TrendChart.d.ts.map +1 -0
  234. package/dist/views/dashboard/TrendChart.js +98 -0
  235. package/dist/views/dashboard/TrendChart.js.map +1 -0
  236. package/dist/views/dashboard/dashboard-date.d.ts +33 -0
  237. package/dist/views/dashboard/dashboard-date.d.ts.map +1 -0
  238. package/dist/views/dashboard/dashboard-date.js +136 -0
  239. package/dist/views/dashboard/dashboard-date.js.map +1 -0
  240. package/dist/views/entries/EntriesInbox.d.ts +8 -0
  241. package/dist/views/entries/EntriesInbox.d.ts.map +1 -0
  242. package/dist/views/entries/EntriesInbox.js +516 -0
  243. package/dist/views/entries/EntriesInbox.js.map +1 -0
  244. package/dist/views/entries/inbox-format.d.ts +27 -0
  245. package/dist/views/entries/inbox-format.d.ts.map +1 -0
  246. package/dist/views/entries/inbox-format.js +119 -0
  247. package/dist/views/entries/inbox-format.js.map +1 -0
  248. package/dist/views/header-footer/ChromePreview.d.ts.map +1 -1
  249. package/dist/views/header-footer/ChromePreview.js +12 -6
  250. package/dist/views/header-footer/ChromePreview.js.map +1 -1
  251. package/dist/views/settings/AISettingsTab.js +1 -1
  252. package/dist/views/settings/SecurityStatusCard.js +1 -1
  253. package/dist/views/settings/SecurityStatusCard.js.map +1 -1
  254. package/dist/views/settings/SiteIndexStatusCard.js +1 -1
  255. package/dist/views/settings/SiteIndexStatusCard.js.map +1 -1
  256. package/dist/views/settings/brand-voice/BrandVoiceAlignmentPanel.js +1 -1
  257. package/dist/views/settings/brand-voice/BrandVoiceRulesSections.js +3 -3
  258. package/dist/views/settings/components.d.ts +1 -1
  259. package/dist/views/settings/components.d.ts.map +1 -1
  260. package/dist/views/settings/components.js +1 -1
  261. package/package.json +4 -4
  262. package/src/AdminRoot.tsx +7 -3
  263. package/src/__tests__/components/attribution-rows.test.ts +1 -1
  264. package/src/__tests__/components/date-range-picker.test.tsx +69 -0
  265. package/src/__tests__/components/form-build-model.test.ts +200 -0
  266. package/src/__tests__/components/form-build.test.tsx +157 -0
  267. package/src/__tests__/components/qa-a11y.render.test.tsx +44 -0
  268. package/src/__tests__/components/responsive-tiers.render.test.tsx +13 -0
  269. package/src/__tests__/components/ui-primitives.test.tsx +11 -0
  270. package/src/__tests__/layout/shell-nav.render.test.tsx +6 -0
  271. package/src/__tests__/lib/batch-wizard.test.ts +2 -0
  272. package/src/__tests__/lib/forms-settings-normalize.test.ts +17 -0
  273. package/src/__tests__/styles/qa-contrast.test.ts +90 -0
  274. package/src/__tests__/views/ai-settings.render.test.tsx +23 -0
  275. package/src/__tests__/views/appearance-chrome.render.test.tsx +12 -0
  276. package/src/__tests__/views/dashboard.test.tsx +110 -32
  277. package/src/__tests__/views/form-editor.render.test.tsx +18 -10
  278. package/src/__tests__/views/form-entries.render.test.tsx +27 -9
  279. package/src/__tests__/views/form-submissions.render.test.tsx +15 -14
  280. package/src/__tests__/views/forms-list.render.test.tsx +157 -17
  281. package/src/__tests__/views/forms-settings.fixture.ts +32 -0
  282. package/src/__tests__/views/forms-settings.render.test.tsx +145 -0
  283. package/src/__tests__/views/inbox-format.test.ts +72 -0
  284. package/src/__tests__/views/jobs-list.render.test.tsx +2 -0
  285. package/src/__tests__/views/jobs-wizard.render.test.tsx +18 -3
  286. package/src/__tests__/views/onboarding-block.render.test.tsx +9 -7
  287. package/src/__tests__/views/run-with-ai.render.test.tsx +10 -0
  288. package/src/__tests__/views/script-tags.render.test.tsx +11 -0
  289. package/src/__tests__/views/settings-tabs.render.test.tsx +6 -0
  290. package/src/components/SEOConfigPanel.tsx +2 -2
  291. package/src/components/forms/BlocklistDialog.tsx +552 -0
  292. package/src/components/forms/ExportMenu.tsx +8 -2
  293. package/src/components/forms/FieldOptions.tsx +629 -0
  294. package/src/components/forms/FormBuild.tsx +900 -0
  295. package/src/components/forms/FormsListTable.tsx +300 -0
  296. package/src/components/forms/form-build-model.ts +365 -0
  297. package/src/components/forms/form-build-ui.tsx +130 -0
  298. package/src/components/forms/primitives.tsx +6 -55
  299. package/src/components/seo/PageAuditPanel.tsx +2 -2
  300. package/src/components/seo/primitives.tsx +15 -3
  301. package/src/components/ui/DateRangePicker.tsx +358 -0
  302. package/src/components/ui/FilterPill.tsx +4 -2
  303. package/src/components/ui/PageHeader.tsx +14 -1
  304. package/src/components/ui/Segmented.tsx +9 -2
  305. package/src/components/ui/StatusBadge.tsx +17 -4
  306. package/src/components/ui/Toggle.tsx +3 -0
  307. package/src/components/ui/UnderlineTabs.tsx +20 -9
  308. package/src/layout/Sidebar.tsx +7 -2
  309. package/src/lib/batch-wizard.ts +2 -2
  310. package/src/lib/entry-attribution.ts +94 -0
  311. package/src/lib/forms-service.ts +194 -0
  312. package/src/lib/job-drawer.ts +21 -1
  313. package/src/lib/job-view.ts +7 -0
  314. package/src/router/admin-routes.ts +1 -0
  315. package/src/styles/prenta-tokens.css +2 -1
  316. package/src/styles/theme.css +86 -0
  317. package/src/views/Dashboard.tsx +1183 -772
  318. package/src/views/FormEditor.tsx +397 -199
  319. package/src/views/FormEntries.tsx +3 -422
  320. package/src/views/FormSubmissions.tsx +5 -411
  321. package/src/views/Forms.tsx +333 -321
  322. package/src/views/FormsSettings.tsx +1381 -73
  323. package/src/views/Jobs/DrawerReview.tsx +14 -8
  324. package/src/views/Jobs/NewBatchJob.tsx +5 -1
  325. package/src/views/Jobs.tsx +1 -0
  326. package/src/views/MediaBrowser.tsx +6 -1
  327. package/src/views/Pages/PagesListView.tsx +1 -1
  328. package/src/views/Redirects.tsx +1 -3
  329. package/src/views/ScriptTags.tsx +1 -1
  330. package/src/views/Settings.tsx +1 -1
  331. package/src/views/SpamFolder.tsx +2 -2
  332. package/src/views/dashboard/Delta.tsx +44 -0
  333. package/src/views/dashboard/KpiCard.tsx +98 -0
  334. package/src/views/dashboard/Sparkline.tsx +51 -0
  335. package/src/views/dashboard/TrendChart.tsx +246 -0
  336. package/src/views/dashboard/dashboard-date.ts +168 -0
  337. package/src/views/entries/EntriesInbox.tsx +1277 -0
  338. package/src/views/entries/inbox-format.ts +128 -0
  339. package/src/views/header-footer/ChromePreview.tsx +18 -8
  340. package/src/views/settings/AISettingsTab.tsx +1 -1
  341. package/src/views/settings/SecurityStatusCard.tsx +1 -1
  342. package/src/views/settings/SiteIndexStatusCard.tsx +1 -1
  343. package/src/views/settings/brand-voice/BrandVoiceAlignmentPanel.tsx +1 -1
  344. package/src/views/settings/brand-voice/BrandVoiceRulesSections.tsx +3 -3
  345. package/src/views/settings/components.tsx +2 -2
  346. package/dist/components/forms/EntriesTable.d.ts +0 -29
  347. package/dist/components/forms/EntriesTable.d.ts.map +0 -1
  348. package/dist/components/forms/EntriesTable.js +0 -29
  349. package/dist/components/forms/EntriesTable.js.map +0 -1
  350. package/dist/components/forms/FormEntryDetailPane.d.ts +0 -23
  351. package/dist/components/forms/FormEntryDetailPane.d.ts.map +0 -1
  352. package/dist/components/forms/FormEntryDetailPane.js +0 -208
  353. package/dist/components/forms/FormEntryDetailPane.js.map +0 -1
  354. package/dist/components/ui/PanelSection.d.ts +0 -16
  355. package/dist/components/ui/PanelSection.d.ts.map +0 -1
  356. package/dist/components/ui/PanelSection.js +0 -15
  357. package/dist/components/ui/PanelSection.js.map +0 -1
  358. package/src/components/forms/EntriesTable.tsx +0 -206
  359. package/src/components/forms/FormEntryDetailPane.tsx +0 -402
  360. package/src/components/ui/PanelSection.tsx +0 -53
@@ -1,31 +1,33 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  /**
4
- * Dashboard
5
- * ----------
6
- * Single-file, lean dashboard implementation. Two API calls only
7
- * (`/stats` + `/health`, both shared with the rest of the admin), everything
8
- * else derived client-side via `useMemo`. No charting libraries on this view
9
- * (the design uses plain progress bars + colored dots), keeping the bundle
10
- * and TTI cost low.
4
+ * Dashboard — period report (design_handoff_dashboard).
11
5
  *
12
- * Responsive layout (SHELL.md §8, cms-layouts.css):
13
- * ≤ 768px (mobile): stat cards 2-col (an odd last card spans both), main
14
- * grid stacks, quick actions scroll-x
15
- * 769–1024 (tablet): stat cards 2+3, main grid stacks
16
- * 1025–1399: stat cards 2+3, main grid is `1fr 320px`
17
- * ≥ 1400: stat cards in one row
6
+ * The page is driven by `/stats/dashboard`: pick a range and comparison and
7
+ * the KPIs, chart, tables and bars all recompute. Organic sessions and
8
+ * pageviews have no analytics source yet, so the endpoint returns them as
9
+ * null and those surfaces render the kit's "Connect analytics" state.
18
10
  */
19
11
  import { useEffect, useMemo, useState } from 'react';
20
- import { usePublicSiteUrl } from '../hooks/usePublicSiteUrl.js';
21
- import { FileText, File as FileIcon, Image as ImageIcon, ClipboardList, Search, Plus, Upload, Globe, ExternalLink, Activity, AlertTriangle, Clock, Zap, Database, ChevronRight, Loader2, TrendingUp, TrendingDown, Gauge, AlertCircle, } from 'lucide-react';
12
+ import { Activity, AlertCircle, AlertTriangle, Clock, Database, Download, Eye, FileText, Gauge, Globe, Inbox, Plus, Search, Target, Zap, } from 'lucide-react';
22
13
  import { useApiData } from '../lib/useApiData.js';
23
14
  import { editPathForDoc } from '../lib/collection-routes.js';
24
15
  import { AuthorAvatar } from '../components/ui/AuthorAvatar.js';
25
- import { PanelSection, PANEL_LIST_ROW_CLASS } from '../components/ui/PanelSection.js';
16
+ import { DateRangePicker } from '../components/ui/DateRangePicker.js';
17
+ import { Button } from '../components/ui/Button.js';
26
18
  import { OnboardingBlock, shouldShowOnboarding } from './dashboard/OnboardingBlock.js';
27
19
  import { kpiCardSpan, kpiGridClass } from './dashboard/kpi-grid.js';
28
- // ─── helpers (kept top-level so they aren't re-created on every render) ──────
20
+ import { comparisonFor, dateKey, inclusiveDays, isCompareMode, isMetricKey, rangeFromUrlValue, rangeLabel, rangeToUrlValue, } from './dashboard/dashboard-date.js';
21
+ import { Delta, deltaPercent } from './dashboard/Delta.js';
22
+ import { KpiCard } from './dashboard/KpiCard.js';
23
+ import { TrendChart } from './dashboard/TrendChart.js';
24
+ const METRIC_META = {
25
+ entries: { label: 'Form entries', icon: Inbox },
26
+ sessions: { label: 'Organic sessions', icon: Globe },
27
+ views: { label: 'Pageviews', icon: Eye },
28
+ published: { label: 'Content published', icon: FileText },
29
+ };
30
+ const number = new Intl.NumberFormat('en-US');
29
31
  function resolveCollections(config) {
30
32
  if (!config?.collections)
31
33
  return [];
@@ -63,16 +65,10 @@ function timeOfDayGreeting() {
63
65
  const h = new Date().getHours();
64
66
  if (h < 12)
65
67
  return 'Good morning';
66
- if (h < 17)
68
+ if (h < 18)
67
69
  return 'Good afternoon';
68
70
  return 'Good evening';
69
71
  }
70
- /**
71
- * Return the user's first name for the greeting. Falls back to the
72
- * email local-part, then a generic "there". Strips role-style names
73
- * like "Admin" / "Administrator" / "Editor" — a literal
74
- * `Good morning, Admin` reads as bot-output, not a person.
75
- */
76
72
  function firstNameForGreeting(session) {
77
73
  const raw = (session?.user?.name ?? session?.name ?? '').trim();
78
74
  const email = session?.user?.email ?? session?.email;
@@ -88,244 +84,163 @@ function firstNameForGreeting(session) {
88
84
  }
89
85
  return 'there';
90
86
  }
91
- function todayDateString() {
92
- return new Date().toLocaleDateString('en-US', {
93
- weekday: 'long',
94
- month: 'long',
95
- day: 'numeric',
96
- year: 'numeric',
97
- });
98
- }
99
- /**
100
- * Semantic state styling uses theme tokens (`success` / `warning` / `info`
101
- * / `brand`) so the dashboard tracks the design system in both light and
102
- * dark mode. One deliberate exception remains as raw values:
103
- * - Error states keep `text-red-*` / `bg-red-*`. The `--destructive`
104
- * token's dark value is intentionally dark (low contrast as TEXT on a
105
- * dark card), so tokenizing error text here would regress contrast.
106
- * Promoting error to a token is a separate, admin-wide change.
107
- * Author avatar colors moved to the shared `AuthorAvatar` component.
108
- */
109
87
  function statusBadge(status) {
110
88
  switch (status) {
111
89
  case 'PUBLISHED':
112
- return { label: 'Published', cls: 'bg-success/10 text-success' };
90
+ return { label: 'Published', cls: 'bg-[var(--suc-l)] text-[var(--suc)]' };
113
91
  case 'DRAFT':
114
- return { label: 'Draft', cls: 'bg-muted text-muted-foreground' };
92
+ return { label: 'Draft', cls: 'bg-[var(--warn-l)] text-[var(--warn)]' };
115
93
  case 'SCHEDULED':
116
- return { label: 'Scheduled', cls: 'bg-warn-l text-warning' };
94
+ return { label: 'Scheduled', cls: 'bg-[var(--bg)] text-[var(--sub)]' };
117
95
  case 'IN_REVIEW':
118
- return { label: 'In Review', cls: 'bg-info/10 text-info' };
96
+ return { label: 'In Review', cls: 'bg-[var(--info-l)] text-[var(--info)]' };
119
97
  default:
120
- return { label: status, cls: 'bg-muted text-muted-foreground' };
98
+ return { label: status, cls: 'bg-[var(--bg)] text-[var(--sub)]' };
99
+ }
100
+ }
101
+ function activityVerb(status) {
102
+ switch (status) {
103
+ case 'PUBLISHED':
104
+ return 'published';
105
+ case 'DRAFT':
106
+ return 'saved as draft';
107
+ case 'SCHEDULED':
108
+ return 'scheduled';
109
+ case 'IN_REVIEW':
110
+ return 'submitted for review';
111
+ default:
112
+ return 'updated';
113
+ }
114
+ }
115
+ function userPreferenceKey(session) {
116
+ const id = session?.user?.id ?? session?.user?.email ?? session?.userId ?? session?.email ?? 'anon';
117
+ return `prenta.dashboard.${String(id)}`;
118
+ }
119
+ function readPreference(session) {
120
+ try {
121
+ const raw = window.localStorage.getItem(userPreferenceKey(session));
122
+ if (!raw)
123
+ return null;
124
+ const parsed = JSON.parse(raw);
125
+ return {
126
+ range: typeof parsed.range === 'string' ? parsed.range : '28d',
127
+ compare: typeof parsed.compare === 'string' ? parsed.compare : 'prev',
128
+ metric: typeof parsed.metric === 'string' ? parsed.metric : 'entries',
129
+ };
121
130
  }
131
+ catch {
132
+ return null;
133
+ }
134
+ }
135
+ function initialDashboardState(session) {
136
+ const today = dateKey(new Date());
137
+ let range = rangeFromUrlValue('28d', today);
138
+ let metric = 'entries';
139
+ if (typeof window !== 'undefined') {
140
+ const params = new URLSearchParams(window.location.search);
141
+ const preference = readPreference(session);
142
+ const urlRange = rangeFromUrlValue(params.get('range'), today);
143
+ const storedRange = preference ? rangeFromUrlValue(preference.range, today) : null;
144
+ range = urlRange ?? storedRange ?? range;
145
+ const compareValue = params.get('compare') ?? preference?.compare ?? range.compare;
146
+ if (isCompareMode(compareValue))
147
+ range = { ...range, compare: compareValue };
148
+ const metricValue = params.get('metric') ?? preference?.metric ?? metric;
149
+ if (isMetricKey(metricValue))
150
+ metric = metricValue;
151
+ }
152
+ return { range, metric };
153
+ }
154
+ function csvCell(value) {
155
+ if (value === null)
156
+ return '';
157
+ const text = String(value);
158
+ return /[",\n]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text;
122
159
  }
123
- // ─── Dashboard ───────────────────────────────────────────────────────────────
124
160
  export function Dashboard({ config, session, onNavigate }) {
125
161
  const nav = (path) => onNavigate?.(path);
126
- // Cache responses for 30s so navigating away and back doesn't re-fire
127
- // all four dashboard requests on every visit. First load is unaffected
128
- // (cold cache) and each request still streams independently; `refetch`
129
- // (the Retry button) bypasses the cache.
130
162
  const DASH_CACHE_MS = 30_000;
131
- const { data: stats, loading, error, exhausted, refetch, } = useApiData('/stats', null, {
163
+ const [initial] = useState(() => initialDashboardState(session));
164
+ const [range, setRange] = useState(initial.range);
165
+ const [metric, setMetric] = useState(initial.metric);
166
+ const reportEndpoint = `/stats/dashboard?start=${range.start}&end=${range.end}&compare=${range.compare}`;
167
+ const { data: stats, error, exhausted, refetch, } = useApiData('/stats', null, {
168
+ cacheMs: DASH_CACHE_MS,
169
+ });
170
+ const { data: report, loading: reportLoading } = useApiData(reportEndpoint, null, {
171
+ cacheMs: DASH_CACHE_MS,
172
+ });
173
+ const { data: scheduled } = useApiData('/stats/scheduled?limit=5', null, {
132
174
  cacheMs: DASH_CACHE_MS,
133
175
  });
134
176
  const { data: health } = useApiData('/health', null, { cacheMs: DASH_CACHE_MS });
135
177
  const { data: delivery, loading: deliveryLoading } = useApiData('/stats/api-delivery', null, { cacheMs: DASH_CACHE_MS });
136
178
  const { data: contentHealthData, loading: contentHealthLoading } = useApiData('/stats/content-health', null, { cacheMs: DASH_CACHE_MS });
137
- // A slow ticker (60s) so the greeting, calendar date, and "x minutes
138
- // ago" relative times stay correct on a dashboard left open for hours
139
- // — without it, a tab opened at 11:58am would read "Good morning" all
140
- // afternoon and show stale activity timestamps.
141
179
  const [now, setNow] = useState(() => Date.now());
142
180
  useEffect(() => {
143
181
  const id = setInterval(() => setNow(Date.now()), 60_000);
144
182
  return () => clearInterval(id);
145
183
  }, []);
146
- const greeting = useMemo(() => timeOfDayGreeting(), [now]);
147
- const dateStr = useMemo(() => todayDateString(), [now]);
148
- const userName = useMemo(() => firstNameForGreeting(session), [session]);
149
- const collections = useMemo(() => resolveCollections(config), [config]);
150
- // Hero CTA targets (mirrors the quick-action "New Post" resolution).
151
- const heroNewPostPath = useMemo(() => {
152
- const postTypes = collections.filter((c) => c.type === 'post');
153
- if (postTypes.length === 1)
154
- return `/${postTypes[0].slug}/new`;
155
- return postTypes.length > 1 ? '/posts/new' : '/posts/types/new';
156
- }, [collections]);
157
- const { siteUrl: resolvedSiteUrl, loading: siteUrlLoading } = usePublicSiteUrl(config?.site?.url ?? config?.seo?.siteUrl ?? null);
158
- // Hide View Site while /site/public-url is in flight so the hero actions
159
- // don't flash when the resolved URL arrives after first paint.
160
- const siteUrl = siteUrlLoading || !resolvedSiteUrl ? null : resolvedSiteUrl;
161
- // ── Stat cards ──────────────────────────────────────────────────────────
162
- const statCards = useMemo(() => {
163
- const counts = stats?.collectionCounts ?? {};
164
- // Prefer two real collections (the user's primary content types) over
165
- // hard-coded Posts/Pages so the dashboard adapts to admin-managed types.
166
- const primary = [];
167
- const posts = collections.find((c) => c.slug === 'posts' || c.type === 'post');
168
- const pages = collections.find((c) => c.slug === 'pages' || c.type === 'page');
169
- if (posts)
170
- primary.push(posts);
171
- if (pages)
172
- primary.push(pages);
173
- if (primary.length < 2) {
174
- for (const c of collections) {
175
- if (primary.length >= 2)
176
- break;
177
- if (!primary.includes(c))
178
- primary.push(c);
184
+ // Applied range/metric round-trip through the URL and the per-user
185
+ // preference. replaceState keeps these changes out of the history stack.
186
+ useEffect(() => {
187
+ try {
188
+ const params = new URLSearchParams(window.location.search);
189
+ params.set('range', rangeToUrlValue(range));
190
+ params.set('compare', range.compare);
191
+ params.set('metric', metric);
192
+ const nextUrl = `${window.location.pathname}?${params.toString()}`;
193
+ // Only write when something changed: Next's router intercepts
194
+ // replaceState as a navigation and remounts the admin panel, so an
195
+ // unconditional write here loops the page.
196
+ if (nextUrl !== `${window.location.pathname}${window.location.search}`) {
197
+ window.history.replaceState(null, '', nextUrl);
179
198
  }
199
+ window.localStorage.setItem(userPreferenceKey(session), JSON.stringify({ range: rangeToUrlValue(range), compare: range.compare, metric }));
180
200
  }
181
- const cards = [];
182
- if (primary[0]) {
183
- cards.push({
184
- label: collectionLabel(primary[0]),
185
- value: String(counts[primary[0].slug] ?? 0),
186
- icon: primary[0].type === 'page' ? FileIcon : FileText,
187
- iconBg: 'bg-chart-1/15',
188
- iconColor: 'text-chart-1',
189
- href: `/${primary[0].slug}`,
190
- });
191
- }
192
- else {
193
- cards.push({
194
- label: 'Documents',
195
- value: String(stats?.totalDocuments ?? 0),
196
- icon: FileText,
197
- iconBg: 'bg-chart-1/15',
198
- iconColor: 'text-chart-1',
199
- });
201
+ catch {
202
+ // Private-mode storage / non-browser test environments.
200
203
  }
201
- if (primary[1]) {
202
- cards.push({
203
- label: collectionLabel(primary[1]),
204
- value: String(counts[primary[1].slug] ?? 0),
205
- icon: primary[1].type === 'page' ? FileIcon : FileText,
206
- iconBg: 'bg-chart-2/15',
207
- iconColor: 'text-chart-2',
208
- href: `/${primary[1].slug}`,
209
- });
210
- }
211
- cards.push({
212
- label: 'Media',
213
- value: String(stats?.totalMedia ?? 0),
214
- hint: stats && stats.totalMedia > 0
215
- ? `${stats.totalMedia} file${stats.totalMedia === 1 ? '' : 's'}`
216
- : undefined,
217
- icon: ImageIcon,
218
- iconBg: 'bg-chart-3/15',
219
- iconColor: 'text-chart-3',
220
- href: '/media',
221
- });
222
- // `formCount` in /stats is the *submission* count; the number of
223
- // forms is the count of `collection: forms` documents.
224
- const formsCount = stats?.formCount ?? counts['forms'] ?? 0;
225
- const submissions = stats?.formSubmissionCount ?? 0;
226
- cards.push({
227
- label: 'Forms',
228
- value: String(formsCount),
229
- hint: submissions > 0 ? `${submissions} response${submissions === 1 ? '' : 's'}` : undefined,
230
- icon: ClipboardList,
231
- iconBg: 'bg-chart-4/15',
232
- iconColor: 'text-chart-4',
233
- href: '/forms',
234
- });
235
- const seo = stats?.avgSeoScore ?? 0;
236
- cards.push({
237
- label: 'SEO Score',
238
- value: seo > 0 ? String(seo) : '—',
239
- unit: seo > 0 ? '/100' : undefined,
240
- hint: seo > 0 ? (seo >= 70 ? 'Good' : seo >= 40 ? 'Fair' : 'Needs work') : 'No content yet',
241
- hintUp: seo >= 70,
242
- icon: Search,
243
- iconBg: 'bg-chart-5/15',
244
- iconColor: 'text-chart-5',
245
- href: '/seo',
246
- });
247
- return cards;
248
- }, [stats, collections]);
249
- // ── Quick actions ───────────────────────────────────────────────────────
250
- // 5-button strip matching the reference dashboard. The "+ New Post" entry
251
- // intentionally duplicates the top-bar primary action: the top bar
252
- // surface is for chrome-level navigation, the quick-action row is the
253
- // dashboard's content-creation toolbar. Order mirrors the natural
254
- // authoring flow (post → page → media → form → integration).
204
+ }, [range, metric, session]);
205
+ const greeting = useMemo(() => timeOfDayGreeting(), [now]);
206
+ const userName = useMemo(() => firstNameForGreeting(session), [session]);
207
+ const collections = useMemo(() => resolveCollections(config), [config]);
255
208
  const quickActions = useMemo(() => {
256
209
  const postTypes = collections.filter((c) => c.type === 'post');
257
210
  const pages = collections.find((c) => c.slug === 'pages' || c.type === 'page');
258
211
  const pagesSlug = pages?.slug ?? 'pages';
259
- // "New Post": one Post Type → straight to its editor; several →
260
- // the picker; none → the Post Type setup instructions (avoids a
261
- // broken slug-based new URL).
262
212
  const newPostPath = postTypes.length === 1
263
213
  ? `/${postTypes[0].slug}/new`
264
214
  : postTypes.length > 1
265
215
  ? '/posts/new'
266
216
  : '/posts/types/new';
267
- const items = [
268
- {
269
- label: 'New Post',
270
- icon: Plus,
271
- onClick: () => nav(newPostPath),
272
- },
273
- { label: 'New Page', icon: Plus, onClick: () => nav(`/${pagesSlug}/new`) },
274
- { label: 'Upload Media', icon: Upload, onClick: () => nav('/media') },
275
- { label: 'New Form', icon: Plus, onClick: () => nav('/forms') },
276
- { label: 'View API', icon: Globe, onClick: () => nav('/settings?tab=api-keys') },
217
+ return [
218
+ { label: 'New Post', onClick: () => nav(newPostPath) },
219
+ { label: 'New Page', onClick: () => nav(`/${pagesSlug}/new`) },
220
+ { label: 'Upload Media', onClick: () => nav('/media') },
221
+ { label: 'New Form', onClick: () => nav('/forms') },
222
+ { label: 'Run SEO Audit', onClick: () => nav('/seo?run=1') },
277
223
  ];
278
- return items;
279
- }, [collections, onNavigate]); // eslint-disable-line react-hooks/exhaustive-deps
280
- // ── Recent activity ─────────────────────────────────────────────────────
281
- const [activityLimit, setActivityLimit] = useState(8);
224
+ // eslint-disable-next-line react-hooks/exhaustive-deps
225
+ }, [collections, onNavigate]);
282
226
  const activity = useMemo(() => {
283
227
  const docs = stats?.recentDocuments ?? [];
284
- return docs.slice(0, activityLimit).map((d) => {
228
+ return docs.slice(0, 5).map((d) => {
285
229
  const col = collections.find((c) => c.slug === d.collection);
286
230
  return {
287
231
  ...d,
288
232
  typeLabel: col ? collectionLabel(col, false) : d.collection,
289
233
  relTime: relativeTime(d.updatedAt),
290
234
  statusInfo: statusBadge(d.status),
291
- editPath: editPathForDoc(col, d.collection, d.id),
292
- };
293
- });
294
- // `now` keeps the relative timestamps fresh on a long-open tab.
295
- // eslint-disable-next-line react-hooks/exhaustive-deps
296
- }, [stats, collections, activityLimit, now]);
297
- // ── Publishing queue (scheduled docs only) ──────────────────────────────
298
- const publishQueue = useMemo(() => {
299
- const docs = stats?.recentDocuments ?? [];
300
- return docs
301
- .filter((d) => d.status === 'SCHEDULED')
302
- .slice(0, 5)
303
- .map((d) => {
304
- const col = collections.find((c) => c.slug === d.collection);
305
- return {
306
- id: d.id,
307
- collection: d.collection,
308
- title: d.title || 'Untitled',
309
- type: col ? collectionLabel(col, false) : d.collection,
310
- date: relativeTime(d.updatedAt),
311
- author: d.author,
235
+ verb: activityVerb(d.status),
312
236
  editPath: editPathForDoc(col, d.collection, d.id),
313
237
  };
314
238
  });
315
239
  // eslint-disable-next-line react-hooks/exhaustive-deps
316
240
  }, [stats, collections, now]);
317
- // ── Content health (sourced from /stats/content-health) ─────────────────
318
- // Persisted by the nightly content-health cron. The four issue rows
319
- // map 1:1 to ContentIssueType in the schema; the labels are
320
- // user-facing and intentionally read like the reference dashboard.
321
241
  const contentHealth = useMemo(() => {
322
242
  const counts = contentHealthData?.counts ?? {};
323
243
  const score = contentHealthData?.score ?? 100;
324
- const label = contentHealthData?.label ?? 'Good';
325
- const tone = score >= 70 ? 'ok' : score >= 40 ? 'warn' : score > 0 ? 'err' : 'muted';
326
- // Issue list — only render rows that have non-zero counts so the
327
- // card stays compact when the corpus is healthy. The empty state
328
- // below picks up when all four are zero.
329
244
  const issues = [];
330
245
  const missingMeta = counts['MISSING_META_DESCRIPTION'] ?? 0;
331
246
  const brokenLinks = counts['BROKEN_INTERNAL_LINK'] ?? 0;
@@ -336,50 +251,41 @@ export function Dashboard({ config, session, onNavigate }) {
336
251
  kind: 'MISSING_META_DESCRIPTION',
337
252
  label: 'Missing meta descriptions',
338
253
  count: missingMeta,
339
- tone: 'warn',
254
+ dot: 'var(--warn)',
340
255
  });
341
256
  if (brokenLinks > 0)
342
257
  issues.push({
343
258
  kind: 'BROKEN_INTERNAL_LINK',
344
259
  label: 'Broken internal links',
345
260
  count: brokenLinks,
346
- tone: 'err',
261
+ dot: 'var(--err)',
347
262
  });
348
263
  if (missingAlt > 0)
349
264
  issues.push({
350
265
  kind: 'MISSING_ALT_TEXT',
351
266
  label: 'Missing alt text',
352
267
  count: missingAlt,
353
- tone: 'warn',
268
+ dot: 'var(--warn)',
354
269
  });
355
270
  if (outdated > 0)
356
271
  issues.push({
357
272
  kind: 'OUTDATED_CONTENT',
358
273
  label: 'Outdated content (90+ days)',
359
274
  count: outdated,
360
- tone: 'warn',
275
+ dot: 'var(--sub)',
361
276
  });
362
277
  return {
363
278
  score,
364
- label,
365
- tone,
279
+ label: contentHealthData?.label ?? 'Good',
366
280
  issues,
281
+ total: contentHealthData?.totalIssues ?? issues.reduce((sum, i) => sum + i.count, 0),
367
282
  hasData: contentHealthData !== null,
368
283
  loading: contentHealthLoading,
369
284
  };
370
285
  }, [contentHealthData, contentHealthLoading]);
371
- const totalIssues = contentHealth.issues.reduce((s, i) => s + i.count, 0);
372
- // ── Onboarding (empty-site getting-started block) ───────────────────────
373
- // Signals come exclusively from data already fetched above (/stats +
374
- // /stats/api-delivery) — see OnboardingBlock.tsx for the per-step
375
- // derivation rationale. When the site is effectively empty (zero
376
- // posts+pages AND zero media) the onboarding block REPLACES the
377
- // Recent Activity / Publishing Queue / Content Health grid.
378
286
  const onboardingSignals = useMemo(() => {
379
287
  const counts = stats?.collectionCounts ?? {};
380
288
  const contentCollections = collections.filter((c) => c.type === 'post' || c.type === 'page' || c.slug === 'posts' || c.slug === 'pages');
381
- // No post/page collections configured → fall back to the total document
382
- // count so a populated site never regresses to the onboarding view.
383
289
  const postsAndPagesCount = contentCollections.length > 0
384
290
  ? contentCollections.reduce((sum, c) => sum + (counts[c.slug] ?? 0), 0)
385
291
  : (stats?.totalDocuments ?? 0);
@@ -391,59 +297,278 @@ export function Dashboard({ config, session, onNavigate }) {
391
297
  hasApiTraffic: delivery?.hasData ?? false,
392
298
  };
393
299
  }, [stats, collections, delivery]);
394
- // Belt-and-braces: any recent activity means the site is not empty even
395
- // if collection counts are missing/stale, so never hide it behind
396
- // onboarding.
397
300
  const showOnboarding = stats !== null &&
398
301
  (stats.recentDocuments?.length ?? 0) === 0 &&
399
302
  shouldShowOnboarding(onboardingSignals);
400
- // ── Render ──────────────────────────────────────────────────────────────
401
- if (loading && !stats) {
402
- return (_jsx("div", { className: "flex h-64 items-center justify-center p-4 sm:p-6", children: _jsx(Loader2, { className: "text-brand h-6 w-6 animate-spin" }) }));
303
+ const analyticsConnected = report?.analyticsConnected ?? false;
304
+ const comparing = Boolean(report?.compareRange);
305
+ const comparisonRange = comparisonFor(range.compare, range.start, range.end);
306
+ const effectiveMetric = (metric === 'sessions' || metric === 'views') && !analyticsConnected ? 'entries' : metric;
307
+ const metricMeta = METRIC_META[effectiveMetric];
308
+ const totals = report?.totals;
309
+ const entriesCur = totals?.entries.cur ?? 0;
310
+ const entriesPrev = totals?.entries.prev ?? null;
311
+ const sessionsCur = totals?.sessions.cur ?? null;
312
+ const sessionsPrev = totals?.sessions.prev ?? null;
313
+ const viewsCur = totals?.views.cur ?? null;
314
+ const viewsPrev = totals?.views.prev ?? null;
315
+ const publishedCur = totals?.published.cur ?? 0;
316
+ const publishedPrev = totals?.published.prev ?? null;
317
+ const convCur = sessionsCur !== null && sessionsCur !== 0
318
+ ? (entriesCur / sessionsCur) * 100
319
+ : sessionsCur === 0
320
+ ? 0
321
+ : null;
322
+ const convPrev = sessionsPrev !== null && sessionsPrev !== 0 && entriesPrev !== null
323
+ ? (entriesPrev / sessionsPrev) * 100
324
+ : sessionsPrev === 0
325
+ ? 0
326
+ : null;
327
+ const chartSeries = report?.series[effectiveMetric] ?? [];
328
+ const chartCompare = report?.compare?.[effectiveMetric] ?? null;
329
+ const chartCurTotal = effectiveMetric === 'entries'
330
+ ? entriesCur
331
+ : effectiveMetric === 'published'
332
+ ? publishedCur
333
+ : effectiveMetric === 'sessions'
334
+ ? (sessionsCur ?? 0)
335
+ : (viewsCur ?? 0);
336
+ const chartPrevTotal = effectiveMetric === 'entries'
337
+ ? entriesPrev
338
+ : effectiveMetric === 'published'
339
+ ? publishedPrev
340
+ : effectiveMetric === 'sessions'
341
+ ? sessionsPrev
342
+ : viewsPrev;
343
+ const chartDelta = chartPrevTotal !== null ? deltaPercent(chartCurTotal, chartPrevTotal) : null;
344
+ const chartAria = chartDelta === null || !comparing
345
+ ? `${metricMeta.label}, ${number.format(chartCurTotal)} this period`
346
+ : `${metricMeta.label}, ${number.format(chartCurTotal)} this period, ${chartDelta >= 0 ? 'up' : 'down'} ${Math.abs(chartDelta).toFixed(1)}% from ${number.format(chartPrevTotal ?? 0)}`;
347
+ const unread = report?.unreadEntries ?? 0;
348
+ function exportCsv() {
349
+ if (!report)
350
+ return;
351
+ const lines = [];
352
+ lines.push([
353
+ 'date',
354
+ 'entries',
355
+ 'entries_comparison',
356
+ 'sessions',
357
+ 'sessions_comparison',
358
+ 'pageviews',
359
+ 'pageviews_comparison',
360
+ 'published',
361
+ 'published_comparison',
362
+ ].join(','));
363
+ report.series.entries?.forEach((point, index) => {
364
+ lines.push([
365
+ point.date,
366
+ point.v,
367
+ report.compare?.entries?.[index]?.v ?? '',
368
+ report.series.sessions?.[index]?.v ?? '',
369
+ report.compare?.sessions?.[index]?.v ?? '',
370
+ report.series.views?.[index]?.v ?? '',
371
+ report.compare?.views?.[index]?.v ?? '',
372
+ report.series.published?.[index]?.v ?? '',
373
+ report.compare?.published?.[index]?.v ?? '',
374
+ ]
375
+ .map(csvCell)
376
+ .join(','));
377
+ });
378
+ lines.push('');
379
+ lines.push('measure,this_period,comparison');
380
+ lines.push(['Form entries', entriesCur, entriesPrev].map(csvCell).join(','));
381
+ lines.push(['Organic sessions', sessionsCur, sessionsPrev].map(csvCell).join(','));
382
+ lines.push(['Pageviews', viewsCur, viewsPrev].map(csvCell).join(','));
383
+ lines.push([
384
+ 'Entries / day',
385
+ (entriesCur / report.range.days).toFixed(1),
386
+ entriesPrev !== null ? (entriesPrev / report.range.days).toFixed(1) : '',
387
+ ]
388
+ .map(csvCell)
389
+ .join(','));
390
+ lines.push([
391
+ 'Conversion rate',
392
+ convCur !== null ? `${convCur.toFixed(2)}%` : '',
393
+ convPrev !== null ? `${convPrev.toFixed(2)}%` : '',
394
+ ]
395
+ .map(csvCell)
396
+ .join(','));
397
+ lines.push('');
398
+ lines.push('path,title,sessions,sessions_comparison,entries,entries_comparison');
399
+ for (const page of report.topPages) {
400
+ lines.push([page.path, page.title, page.sessions, page.sessionsPrev, page.entries, page.entriesPrev]
401
+ .map(csvCell)
402
+ .join(','));
403
+ }
404
+ const blob = new Blob([lines.join('\n')], { type: 'text/csv;charset=utf-8' });
405
+ const url = URL.createObjectURL(blob);
406
+ const anchor = document.createElement('a');
407
+ anchor.href = url;
408
+ anchor.download = `prenta-dashboard_${report.range.start}_${report.range.end}.csv`;
409
+ anchor.click();
410
+ URL.revokeObjectURL(url);
403
411
  }
404
- return (_jsxs("div", { className: "w-full space-y-5 p-4 sm:p-6 lg:px-8", children: [health && health.status === 'degraded' && (_jsxs("div", { className: "border-info/30 bg-info/10 flex items-start gap-3 rounded-lg border p-4", children: [_jsx(Database, { className: "text-info mt-0.5 h-5 w-5 shrink-0" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "text-info text-sm font-medium", children: "Database setup required" }), _jsx("p", { className: "text-muted-foreground mt-0.5 text-xs", children: !health.databaseConnected
405
- ? 'Cannot connect to the database. Check your DATABASE_URL environment variable.'
406
- : !health.secretConfigured
407
- ? 'CMS secret not configured. Set CMS_SECRET or CMS_SESSION_SECRET (min 32 characters).'
408
- : `Some CMS models are missing: ${Object.entries(health.models)
409
- .filter(([, v]) => !v)
410
- .map(([k]) => k)
411
- .join(', ')}. Run your database migrations.` })] })] })), error && exhausted && (_jsxs("div", { className: "border-warning/30 bg-warn-l flex items-center gap-3 rounded-lg border p-4", children: [_jsx(AlertTriangle, { className: "text-warning h-5 w-5 shrink-0" }), _jsx("span", { className: "text-warning flex-1 text-sm", children: "Some dashboard data may be unavailable." }), _jsx("button", { onClick: refetch, className: "border-warning/40 text-warning hover:bg-warn-l rounded-lg border px-3 py-1 text-sm transition-colors", children: "Retry" })] })), _jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1 sm:gap-0.5", children: [_jsxs("h1", { className: "text-foreground", children: [greeting, ", ", userName, " ", _jsx("span", { "aria-hidden": true, children: "\uD83D\uDC4B" })] }), _jsxs("p", { className: "text-muted-foreground text-sm", "data-volatile": true, children: [dateStr, totalIssues > 0 && (_jsxs("span", { className: "hidden sm:inline", children: [' · ', totalIssues, " content item", totalIssues === 1 ? '' : 's', " need attention"] }))] })] }), _jsxs("div", { "data-header-actions": "", className: "flex items-center gap-2", children: [_jsxs("button", { type: "button", onClick: () => nav(heroNewPostPath), "data-variant": "primary", "data-fab": "", className: "bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:ring-ring inline-flex items-center gap-1.5 rounded-lg px-3.5 py-1.5 text-sm font-medium shadow-sm transition-colors focus:outline-none focus-visible:ring-2", children: [_jsx(Plus, { className: "h-3.5 w-3.5", "aria-hidden": true }), "New Post"] }), siteUrl ? (_jsxs("a", { href: siteUrl, target: "_blank", rel: "noopener noreferrer", "data-variant": "secondary", className: "border-border bg-card text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-sm font-medium transition-colors", children: [_jsx(ExternalLink, { className: "h-3.5 w-3.5", "aria-hidden": true }), "View Site"] })) : null] })] }), _jsx("div", { className: "-mx-1 flex gap-2 overflow-x-auto px-1 pb-1 [scrollbar-width:thin]", children: quickActions.map((a) => (_jsxs("button", { onClick: a.onClick, className: "border-border bg-card hover:border-brand/50 hover:bg-brand/10 hover:text-brand inline-flex shrink-0 items-center gap-1.5 rounded-lg border px-3.5 py-2 text-sm shadow-sm transition-colors", children: [_jsx(a.icon, { className: "h-3.5 w-3.5" }), a.label] }, a.label))) }), _jsx("div", { "data-kpi-grid": "", className: kpiGridClass(statCards.length), children: statCards.map((card, index) => {
412
- const span = kpiCardSpan(index, statCards.length);
413
- const Inner = (_jsxs(_Fragment, { children: [_jsx("div", { className: `mb-3 flex h-8 w-8 items-center justify-center rounded-lg ${card.iconBg}`, children: _jsx(card.icon, { className: `h-4 w-4 ${card.iconColor}` }) }), _jsxs("div", { className: "flex items-baseline gap-1", children: [_jsx("span", { className: "text-foreground text-2xl leading-none font-medium tracking-tight", children: card.value }), card.unit && (_jsx("span", { className: "text-muted-foreground text-sm font-medium", children: card.unit }))] }), _jsx("p", { className: "text-muted-foreground mt-1 text-xs", children: card.label }), card.hint && (_jsx("p", { className: `mt-1.5 text-[11px] ${card.hintUp ? 'text-success' : 'text-muted-foreground'}`, children: card.hint }))] }));
414
- return card.href ? (_jsx("button", { type: "button", onClick: () => nav(card.href), className: `bg-card border-border rounded-xl border p-4 text-left shadow-sm transition-shadow hover:shadow-md ${span}`, children: Inner }, card.label)) : (_jsx("div", { className: `bg-card border-border rounded-xl border p-4 shadow-sm ${span}`, children: Inner }, card.label));
415
- }) }), showOnboarding ? (_jsx(OnboardingBlock, { signals: onboardingSignals, onNavigate: onNavigate })) : (
416
- // One column up to 1024px (cms-layouts.css `.grid2`, tablet).
417
- _jsxs("div", { className: "not-narrow:grid-cols-[minmax(0,1fr)_320px] grid grid-cols-1 gap-4", children: [_jsx(PanelSection, { title: "Recent Activity", description: "Last 7 days across all content", action: (stats?.recentDocuments?.length ?? 0) > 8 ? (_jsx("button", { className: "text-brand text-xs font-medium hover:underline", onClick: () => setActivityLimit((n) => (n >= 20 ? 8 : 20)), children: activityLimit >= 20 ? 'Show less' : 'Show more' })) : undefined, children: activity.length === 0 ? (_jsx(EmptyState, { icon: Activity, title: "No activity yet", subtitle: "Content changes will appear here as your team works." })) : (_jsx("ul", { role: "list", className: "divide-border divide-y", children: activity.map((it) => (_jsx("li", { children: _jsx("button", { type: "button", onClick: () => nav(it.editPath), className: PANEL_LIST_ROW_CLASS, children: _jsxs("div", { className: "flex min-w-0 items-start gap-3", children: [_jsx(AuthorAvatar, { name: it.author, size: 28, className: "mt-0.5" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("p", { className: "text-foreground truncate text-sm leading-snug", children: [_jsxs("span", { className: "font-medium", children: ["\u201C", it.title || 'Untitled', "\u201D"] }), ' ', _jsxs("span", { className: "text-muted-foreground", children: ["\u2014 ", it.typeLabel] })] }), _jsxs("div", { className: "text-muted-foreground mt-1 flex flex-wrap items-center gap-2 text-[11px]", children: [_jsx("span", { className: `inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium ${it.statusInfo.cls}`, children: it.statusInfo.label }), _jsx("span", { className: "max-w-[120px] truncate", children: it.author }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx("span", { children: it.relTime })] })] })] }) }) }, it.id))) })) }), _jsxs("aside", { className: "flex min-w-0 flex-col gap-4", children: [_jsx(PanelSection, { title: "Publishing Queue", description: `${publishQueue.length} item${publishQueue.length === 1 ? '' : 's'} scheduled`, action: _jsx("button", { className: "text-brand text-xs font-medium hover:underline disabled:cursor-default disabled:no-underline disabled:opacity-50", disabled: publishQueue.length === 0, onClick: () => {
418
- const first = publishQueue[0];
419
- if (first)
420
- nav(first.editPath);
421
- }, children: "Manage" }), children: publishQueue.length === 0 ? (_jsx(EmptyState, { icon: Clock, title: "No scheduled content", subtitle: "Scheduled posts and pages appear here.", compact: true })) : (_jsx("ul", { role: "list", className: "divide-border divide-y", children: publishQueue.map((q) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => nav(q.editPath), className: `${PANEL_LIST_ROW_CLASS} flex min-w-0 cursor-pointer items-center gap-2.5`, children: [_jsx("span", { className: "bg-warning h-2 w-2 shrink-0 rounded-full", "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "text-foreground truncate text-sm font-medium", children: q.title }), _jsxs("p", { className: "text-muted-foreground truncate text-[11px]", children: [q.date, " \u00B7 ", q.author] })] }), _jsx("span", { className: "border-border bg-background text-muted-foreground shrink-0 rounded border px-1.5 py-0.5 text-[10px] capitalize", children: q.type })] }) }, q.id))) })) }), _jsxs(PanelSection, { title: "Content Health", description: "SEO & quality issues", action: _jsx("button", { className: "text-brand text-xs font-medium hover:underline", onClick: () => nav('/seo'), children: "Fix issues" }), children: [_jsxs("div", { className: "px-6 pt-4 pb-2.5", children: [_jsxs("div", { className: "mb-1.5 flex items-baseline justify-between", children: [_jsxs("p", { className: "text-foreground text-2xl leading-none font-medium tracking-tight", children: [contentHealth.score > 0 ? contentHealth.score : '—', contentHealth.score > 0 && (_jsx("span", { className: "text-muted-foreground ml-0.5 text-sm font-normal", children: "/100" }))] }), _jsx("span", { className: `text-xs font-medium ${contentHealth.tone === 'ok'
422
- ? 'text-success'
423
- : contentHealth.tone === 'warn'
424
- ? 'text-warning'
425
- : contentHealth.tone === 'err'
426
- ? 'text-destructive dark:text-red-400'
427
- : 'text-muted-foreground'}`, children: contentHealth.label })] }), _jsx("div", { className: "bg-muted h-1.5 overflow-hidden rounded-full", children: _jsx("div", { className: `h-full rounded-full transition-all ${contentHealth.tone === 'ok'
428
- ? 'bg-success'
429
- : contentHealth.tone === 'warn'
430
- ? 'bg-warning'
431
- : contentHealth.tone === 'err'
432
- ? 'bg-destructive'
433
- : 'bg-muted-foreground/40'}`, style: { width: `${Math.max(0, Math.min(100, contentHealth.score))}%` } }) })] }), contentHealth.issues.length === 0 ? (_jsx("div", { className: "text-muted-foreground px-6 pt-1 pb-4 text-xs", children: "No outstanding issues. Nice work." })) : (_jsx("ul", { role: "list", className: "divide-border divide-y", children: contentHealth.issues.map((iss, i) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => nav('/seo'), className: `${PANEL_LIST_ROW_CLASS} flex items-center gap-2.5 py-3.5`, children: [_jsx("span", { className: `h-1.5 w-1.5 shrink-0 rounded-full ${iss.tone === 'err'
434
- ? 'bg-destructive'
435
- : iss.tone === 'warn'
436
- ? 'bg-warning'
437
- : 'bg-muted-foreground'}`, "aria-hidden": true }), _jsx("span", { className: "text-muted-foreground flex-1 truncate text-xs", children: iss.label }), _jsx("span", { className: `shrink-0 text-sm font-medium ${iss.tone === 'err'
438
- ? 'text-destructive dark:text-red-400'
439
- : iss.tone === 'warn'
440
- ? 'text-warning'
441
- : 'text-muted-foreground'}`, children: iss.count }), _jsx(ChevronRight, { className: "text-muted-foreground/60 h-3.5 w-3.5 shrink-0" })] }) }, i))) }))] })] })] })), _jsx(PanelSection, { title: "Delivery API", description: "Headless content delivery \u00B7 last 24 hours", action: _jsxs("button", { className: "text-brand inline-flex items-center gap-1 text-xs font-medium hover:underline", onClick: () => nav('/settings?tab=api-keys'), children: ["API docs ", _jsx(ExternalLink, { className: "h-3 w-3" })] }), children: _jsx(DeliveryGrid, { delivery: delivery, loading: deliveryLoading }) })] }));
412
+ const kpis = [
413
+ {
414
+ key: 'entries',
415
+ label: 'Form entries',
416
+ icon: Inbox,
417
+ value: number.format(entriesCur),
418
+ cur: entriesCur,
419
+ prev: entriesPrev,
420
+ prevLabel: entriesPrev !== null ? number.format(entriesPrev) : '',
421
+ series: report?.series.entries ?? [],
422
+ compareSeries: report?.compare?.entries ?? null,
423
+ selectable: true,
424
+ unavailable: false,
425
+ },
426
+ {
427
+ key: 'sessions',
428
+ label: 'Organic sessions',
429
+ icon: Globe,
430
+ value: sessionsCur !== null ? number.format(sessionsCur) : '—',
431
+ cur: sessionsCur,
432
+ prev: sessionsPrev,
433
+ prevLabel: sessionsPrev !== null ? number.format(sessionsPrev) : '',
434
+ series: report?.series.sessions ?? null,
435
+ compareSeries: report?.compare?.sessions ?? null,
436
+ selectable: analyticsConnected,
437
+ unavailable: !analyticsConnected,
438
+ },
439
+ {
440
+ key: 'views',
441
+ label: 'Pageviews',
442
+ icon: Eye,
443
+ value: viewsCur !== null ? number.format(viewsCur) : '—',
444
+ cur: viewsCur,
445
+ prev: viewsPrev,
446
+ prevLabel: viewsPrev !== null ? number.format(viewsPrev) : '',
447
+ series: report?.series.views ?? null,
448
+ compareSeries: report?.compare?.views ?? null,
449
+ selectable: analyticsConnected,
450
+ unavailable: !analyticsConnected,
451
+ },
452
+ {
453
+ key: 'published',
454
+ label: 'Content published',
455
+ icon: FileText,
456
+ value: number.format(publishedCur),
457
+ cur: publishedCur,
458
+ prev: publishedPrev,
459
+ prevLabel: publishedPrev !== null ? number.format(publishedPrev) : '',
460
+ series: report?.series.published ?? [],
461
+ compareSeries: report?.compare?.published ?? null,
462
+ selectable: true,
463
+ unavailable: false,
464
+ },
465
+ ];
466
+ return (_jsx("div", { className: "mx-auto w-full max-w-[1520px] p-[20px_24px_48px]", children: _jsxs("div", { className: "flex flex-col gap-[14px]", children: [health && health.status === 'degraded' && (_jsxs("div", { className: "flex items-start gap-3 rounded-[10px] border border-[var(--info)] bg-[var(--info-l)] p-4", children: [_jsx(Database, { className: "mt-0.5 h-5 w-5 shrink-0 text-[var(--info)]", "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "text-sm font-medium text-[var(--info)]", children: "Database setup required" }), _jsx("p", { className: "mt-0.5 text-xs text-[var(--sub)]", children: !health.databaseConnected
467
+ ? 'Cannot connect to the database. Check your DATABASE_URL environment variable.'
468
+ : !health.secretConfigured
469
+ ? 'CMS secret not configured. Set CMS_SECRET or CMS_SESSION_SECRET (min 32 characters).'
470
+ : `Some CMS models are missing: ${Object.entries(health.models)
471
+ .filter(([, v]) => !v)
472
+ .map(([k]) => k)
473
+ .join(', ')}. Run your database migrations.` })] })] })), error && exhausted && (_jsxs("div", { className: "flex items-center gap-3 rounded-[10px] border border-[var(--warn)] bg-[var(--warn-l)] p-4", children: [_jsx(AlertTriangle, { className: "h-5 w-5 shrink-0 text-[var(--warn)]", "aria-hidden": true }), _jsx("span", { className: "flex-1 text-sm text-[var(--warn)]", children: "Some dashboard data may be unavailable." }), _jsx(Button, { type: "button", variant: "secondary", size: "sm", onClick: refetch, children: "Retry" })] })), _jsxs("header", { className: "mb-[4px] flex flex-wrap items-end gap-4", children: [_jsxs("div", { children: [_jsxs("h1", { className: "text-[23px] leading-[1.15] font-bold tracking-[-0.6px] text-[var(--txt)]", children: [greeting, ", ", userName] }), _jsx("p", { className: "mt-1 text-[13px] text-[var(--sub)]", children: unread === 0 ? (_jsxs(_Fragment, { children: ["No unread leads \u00B7", ' ', _jsx("button", { type: "button", className: "text-[var(--acc)] hover:underline", onClick: () => nav('/forms/entries?filter=unread'), children: "open the inbox" })] })) : (_jsxs(_Fragment, { children: [unread, " unread lead", unread === 1 ? '' : 's', " waiting \u00B7", ' ', _jsx("button", { type: "button", className: "text-[var(--acc)] hover:underline", onClick: () => nav('/forms/entries?filter=unread'), children: "open the inbox" })] })) })] }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [_jsx(DateRangePicker, { value: range, onChange: setRange }), _jsx(Button, { type: "button", variant: "secondary", "aria-label": "Export", onClick: exportCsv, disabled: !report, className: "h-11 px-[11px]", leftIcon: _jsx(Download, { size: 14, "aria-hidden": true }), children: _jsx("span", { className: "max-[1024px]:hidden", children: "Export" }) })] })] }), _jsx("div", { className: "grid [grid-template-columns:repeat(auto-fit,minmax(146px,1fr))] gap-2 max-[768px]:flex max-[768px]:overflow-x-auto max-[768px]:pb-1", children: quickActions.map((action) => (_jsxs("button", { type: "button", onClick: action.onClick, className: "flex shrink-0 items-center gap-2 rounded-[9px] border border-[var(--bdr)] bg-[var(--card)] px-[13px] py-[11px] text-[13px] font-medium whitespace-nowrap text-[var(--txt)] transition hover:-translate-y-px hover:border-[var(--acc-m)] hover:bg-[var(--acc-l)] hover:text-[var(--acc)]", children: [_jsx(Plus, { size: 14, className: "shrink-0 text-[var(--acc)]", "aria-hidden": true }), action.label] }, action.label))) }), _jsx("div", { "data-kpi-grid": "", className: kpiGridClass(5), children: reportLoading && !report
474
+ ? [0, 1, 2, 3, 4].map((index) => (_jsxs("div", { "aria-hidden": true, className: `rounded-[10px] border border-[var(--bdr)] bg-[var(--card)] p-[14px_15px_10px] shadow-[var(--shd)] ${kpiCardSpan(index, 5)}`, children: [_jsx("div", { className: "h-[14px] w-24 rounded bg-[var(--bg)]" }), _jsx("div", { className: "mt-[10px] h-[32px] w-[70%] rounded bg-[var(--bg)]" }), _jsx("div", { className: "mt-[10px] ml-auto h-[30px] w-[76px] rounded bg-[var(--bg)]" })] }, index)))
475
+ : [
476
+ ...kpis.slice(0, 3),
477
+ {
478
+ key: 'conv',
479
+ label: 'Conversion rate',
480
+ icon: Target,
481
+ value: convCur !== null ? convCur.toFixed(2) : '—',
482
+ unit: convCur !== null ? '%' : undefined,
483
+ cur: convCur,
484
+ prev: convPrev,
485
+ prevLabel: convPrev !== null ? `${convPrev.toFixed(2)}%` : '',
486
+ series: null,
487
+ compareSeries: null,
488
+ selectable: false,
489
+ unavailable: !analyticsConnected,
490
+ },
491
+ kpis[3],
492
+ ].map((kpi, index) => (_jsx(KpiCard, { label: kpi.label, icon: kpi.icon, value: kpi.value, unit: 'unit' in kpi ? kpi.unit : undefined, cur: kpi.cur, prev: kpi.prev, prevLabel: kpi.prevLabel, compare: comparing, series: kpi.series, compareSeries: kpi.compareSeries, selected: kpi.key === effectiveMetric, selectable: kpi.selectable, unavailable: kpi.unavailable, onSelect: () => {
493
+ if (kpi.key !== 'conv')
494
+ setMetric(kpi.key);
495
+ }, onConnect: () => nav('/settings'), spanClass: kpiCardSpan(index, 5) }, kpi.key))) }), _jsx(DashboardCard, { title: `${metricMeta.label} over time`, subtitle: `${report?.range.days ?? inclusiveDays(range.start, range.end)} days · ${rangeLabel(range.start, range.end)}${comparing && comparisonRange
496
+ ? ` vs ${rangeLabel(comparisonRange[0], comparisonRange[1])}`
497
+ : ''}`, action: _jsxs("div", { className: "flex flex-wrap items-center gap-[14px]", children: [_jsxs("span", { className: "flex items-center gap-[6px] text-[11.5px] text-[var(--sub)]", children: [_jsx("i", { className: "block h-[3px] w-[14px] rounded-[2px] bg-[var(--acc)]", "aria-hidden": true }), "This period", ' ', _jsx("b", { className: "ml-[2px] text-[var(--txt)]", children: number.format(chartCurTotal) })] }), comparing ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex items-center gap-[6px] text-[11.5px] text-[var(--sub)]", children: [_jsx("i", { className: "block h-[2px] w-[14px] rounded-[2px] bg-[repeating-linear-gradient(90deg,var(--muted)_0_4px,transparent_4px_7px)]", "aria-hidden": true }), "Comparison", ' ', _jsx("b", { className: "ml-[2px] text-[var(--sub)]", children: number.format(chartPrevTotal ?? 0) })] }), chartPrevTotal !== null ? (_jsx(Delta, { cur: chartCurTotal, prev: chartPrevTotal })) : null] })) : null] }), children: reportLoading && !report ? (_jsx("div", { className: "relative px-2 pt-[14px] pb-1", "aria-hidden": true, children: _jsx("div", { className: "flex h-[244px] flex-col justify-between py-3", children: [0, 1, 2, 3, 4].map((line) => (_jsx("div", { className: "h-px bg-[var(--bdr)]" }, line))) }) })) : (_jsx(TrendChart, { cur: chartSeries, prev: comparing ? chartCompare : null, format: (value) => number.format(Math.round(value)), ariaLabel: chartAria })) }), showOnboarding ? (_jsx(OnboardingBlock, { signals: onboardingSignals, onNavigate: onNavigate })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "grid gap-[14px] min-[1181px]:grid-cols-[1.45fr_1fr]", children: [_jsx(DashboardCard, { title: "Top landing pages", subtitle: "Sessions and entries, measured against the comparison period", children: !analyticsConnected ? (_jsx(EmptyState, { icon: Globe, title: "Analytics isn't connected", subtitle: "Connect analytics to see sessions and entries by landing page.", action: _jsx("button", { type: "button", onClick: () => nav('/settings'), className: "text-[12.5px] font-semibold text-[var(--acc)] hover:underline", children: "Connect analytics" }) })) : report?.topPages.length ? (_jsx("div", { className: "overflow-x-auto", tabIndex: 0, role: "region", "aria-label": "Top landing pages table", children: _jsxs("table", { className: "w-full min-w-[560px] border-collapse", "aria-label": "Top landing pages", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "sticky left-0 bg-[var(--bg)] px-[14px] py-2 text-left text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Page" }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Sessions" }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Entries" }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Conv." }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Change" })] }) }), _jsx("tbody", { children: report.topPages.map((page) => {
498
+ const col = page.collection
499
+ ? collections.find((item) => item.slug === page.collection)
500
+ : undefined;
501
+ const pageCell = (_jsxs(_Fragment, { children: [_jsx("span", { className: "block max-w-[280px] truncate text-[12.5px] font-medium text-[var(--txt)]", children: page.title }), _jsx("span", { className: "mt-[1px] block font-mono text-[11px] text-[var(--sub)]", children: page.path })] }));
502
+ return (_jsxs("tr", { className: "group hover:bg-[var(--bg)]", children: [_jsx("td", { className: "sticky left-0 bg-[var(--card)] px-[14px] py-[10px] group-hover:bg-[var(--bg)]", children: page.docId ? (_jsx("button", { type: "button", className: "block text-left", onClick: () => nav(editPathForDoc(col, page.collection ?? '', page.docId)), children: pageCell })) : (pageCell) }), _jsxs("td", { className: "px-[14px] py-[10px] text-right align-middle tabular-nums", children: [_jsx("span", { className: "text-[13.5px] font-[650] text-[var(--txt)]", children: number.format(page.sessions) }), comparing && page.sessionsPrev !== null ? (_jsxs("div", { className: "text-[11px] text-[var(--sub)]", children: ["was ", number.format(page.sessionsPrev)] })) : null] }), _jsxs("td", { className: "px-[14px] py-[10px] text-right align-middle tabular-nums", children: [_jsx("span", { className: "text-[13.5px] font-[650] text-[var(--txt)]", children: number.format(page.entries) }), comparing && page.entriesPrev !== null ? (_jsxs("div", { className: "text-[11px] text-[var(--sub)]", children: ["was ", number.format(page.entriesPrev)] })) : null] }), _jsxs("td", { className: "px-[14px] py-[10px] text-right text-[13.5px] font-[650] text-[var(--txt)] tabular-nums", children: [page.sessions
503
+ ? ((page.entries / page.sessions) * 100).toFixed(2)
504
+ : '0.00', "%"] }), _jsx("td", { className: "px-[14px] py-[10px] text-right", children: comparing && page.sessionsPrev !== null ? (_jsx(Delta, { cur: page.sessions, prev: page.sessionsPrev })) : (_jsx("span", { className: "text-[11px] text-[var(--sub)]", children: "\u2014" })) })] }, page.path));
505
+ }) })] }) })) : (_jsx(EmptyState, { icon: Search, title: "No landing pages yet", subtitle: "Pages with sessions in this period will appear here." })) }), _jsx(DashboardCard, { title: "Entries by form", subtitle: "Solid bar this period, grey bar comparison", children: _jsxs("div", { className: "flex flex-col gap-[13px] px-4 pt-3 pb-[14px]", children: [(report?.entriesByForm ?? []).map((form) => {
506
+ const max = Math.max(...(report?.entriesByForm.map((item) => Math.max(item.cur, item.prev ?? 0)) ?? [1]), 1);
507
+ return (_jsxs("button", { type: "button", onClick: () => nav(`/forms/entries?form=${encodeURIComponent(form.slug)}`), className: "block w-full text-left", children: [_jsxs("div", { className: "flex items-baseline gap-2 text-[12.5px]", children: [_jsx("b", { className: "font-[550] text-[var(--txt)]", children: form.name }), comparing && form.prev !== null ? (_jsx(Delta, { cur: form.cur, prev: form.prev })) : null, _jsx("span", { className: "ml-auto text-[13px] font-bold text-[var(--txt)] tabular-nums", children: number.format(form.cur) })] }), _jsxs("div", { className: "relative mt-[6px] h-4", children: [comparing && form.prev !== null ? (_jsx("div", { className: "absolute top-0 left-0 h-[6px] rounded-full bg-[var(--bdr)]", style: { width: `${(form.prev / max) * 100}%` }, "aria-hidden": true })) : null, _jsx("div", { className: "absolute left-0 h-2 rounded-full bg-[var(--acc)] transition-[width] duration-300", style: {
508
+ width: `${(form.cur / max) * 100}%`,
509
+ top: comparing ? 8 : 4,
510
+ }, "aria-hidden": true })] })] }, form.slug || form.name));
511
+ }), (report?.entriesByForm.length ?? 0) === 0 ? (_jsx("p", { className: "py-4 text-center text-[12.5px] text-[var(--sub)]", children: "No forms yet. Entries will be grouped here once a form exists." })) : null] }) })] }), _jsxs("div", { className: "grid gap-[14px] min-[1181px]:grid-cols-[1.45fr_1fr]", children: [_jsx(DashboardCard, { title: "Recent activity", subtitle: "Across all content types", action: _jsx("button", { type: "button", className: "text-[12.5px] text-[var(--acc)] hover:underline", onClick: () => nav('/posts'), children: "View all" }), children: activity.length === 0 ? (_jsx(EmptyState, { icon: Activity, title: "No activity yet", subtitle: "Content changes will appear here as your team works." })) : (_jsx("ul", { role: "list", children: activity.map((item) => (_jsx("li", { className: "border-b border-[var(--bdr)] last:border-b-0", children: _jsxs("button", { type: "button", onClick: () => nav(item.editPath), className: "flex w-full items-start gap-[11px] px-4 py-[10px] text-left transition hover:bg-[var(--bg)]", children: [_jsx(AuthorAvatar, { name: item.author, size: 28, className: "shrink-0" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate text-[13px] font-medium text-[var(--txt)]", children: item.title || 'Untitled' }), _jsxs("span", { className: "mt-[2px] block text-[11.5px] text-[var(--sub)]", children: [item.typeLabel, " ", item.verb, " by ", item.author] })] }), _jsxs("span", { className: "flex shrink-0 flex-col items-end gap-1", children: [_jsx("span", { className: `inline-flex rounded-[4px] px-[6px] py-[1.5px] text-[10px] font-bold tracking-[0.2px] ${item.statusInfo.cls}`, children: item.statusInfo.label }), _jsx("span", { className: "text-[11px] text-[var(--sub)]", children: item.relTime === 'Yesterday' ||
512
+ item.relTime === 'just now' ||
513
+ item.relTime.endsWith(' ago') ||
514
+ item.relTime.includes('/')
515
+ ? item.relTime
516
+ : `${item.relTime} ago` })] })] }) }, item.id))) })) }), _jsx(DashboardCard, { title: "Period summary", subtitle: rangeLabel(range.start, range.end), children: _jsx("div", { className: "overflow-x-auto", tabIndex: 0, role: "region", "aria-label": "Period summary table", children: _jsxs("table", { className: "w-full min-w-[420px] border-collapse", "aria-label": "Period summary", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-left text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Measure" }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "This period" }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "Comparison" }), _jsx("th", { className: "bg-[var(--bg)] px-[14px] py-2 text-right text-[10px] font-bold tracking-[0.6px] text-[var(--sub)] uppercase", children: "\u0394" })] }) }), _jsx("tbody", { children: [
517
+ {
518
+ label: 'Form entries',
519
+ cur: entriesCur,
520
+ prev: entriesPrev,
521
+ fmt: (value) => number.format(Math.round(value)),
522
+ },
523
+ {
524
+ label: 'Organic sessions',
525
+ cur: sessionsCur,
526
+ prev: sessionsPrev,
527
+ fmt: (value) => number.format(Math.round(value)),
528
+ },
529
+ {
530
+ label: 'Pageviews',
531
+ cur: viewsCur,
532
+ prev: viewsPrev,
533
+ fmt: (value) => number.format(Math.round(value)),
534
+ },
535
+ {
536
+ label: 'Entries / day',
537
+ cur: entriesCur /
538
+ (report?.range.days ?? inclusiveDays(range.start, range.end)),
539
+ prev: entriesPrev !== null
540
+ ? entriesPrev /
541
+ (report?.range.days ?? inclusiveDays(range.start, range.end))
542
+ : null,
543
+ fmt: (value) => value.toFixed(1),
544
+ },
545
+ {
546
+ label: 'Conversion rate',
547
+ cur: convCur,
548
+ prev: convPrev,
549
+ fmt: (value) => `${value.toFixed(2)}%`,
550
+ },
551
+ ].map((row) => (_jsxs("tr", { className: "hover:bg-[var(--bg)]", children: [_jsx("td", { className: "px-[14px] py-[10px] text-[13px] text-[var(--sub)]", children: row.label }), _jsx("td", { className: "px-[14px] py-[10px] text-right text-[13.5px] font-[650] text-[var(--txt)] tabular-nums", children: row.cur !== null ? row.fmt(row.cur) : '—' }), _jsx("td", { className: "px-[14px] py-[10px] text-right text-[11px] text-[var(--sub)] tabular-nums", children: comparing && row.prev !== null ? row.fmt(row.prev) : '—' }), _jsx("td", { className: "px-[14px] py-[10px] text-right", children: comparing && row.cur !== null && row.prev !== null ? (_jsx(Delta, { cur: row.cur, prev: row.prev })) : (_jsx("span", { className: "text-[11px] text-[var(--sub)]", children: "\u2014" })) })] }, row.label))) })] }) }) })] }), _jsxs("div", { className: "grid gap-[14px] min-[821px]:max-[1180px]:grid-cols-2 min-[1181px]:grid-cols-3", children: [_jsxs(DashboardCard, { title: "Content health", subtitle: "SEO & quality issues", action: _jsx("button", { type: "button", className: "text-[12.5px] text-[var(--acc)] hover:underline", onClick: () => nav('/seo'), children: "Open SEO" }), children: [_jsxs("div", { className: "flex items-center gap-[14px] border-b border-[var(--bdr)] px-4 py-[15px]", children: [_jsx(HealthRing, { score: contentHealth.score }), _jsxs("div", { children: [_jsxs("div", { className: "text-[13.5px] font-semibold text-[var(--txt)]", children: [contentHealth.score, "/100 \u00B7 ", contentHealth.label] }), _jsxs("div", { className: "mt-[3px] text-[11.5px] leading-[1.5] text-[var(--sub)]", children: [contentHealth.total, " issues across ", contentHealth.issues.length, " categories"] })] })] }), contentHealth.loading && !contentHealth.hasData ? (_jsx("div", { className: "flex flex-col gap-2 px-4 py-3", "aria-hidden": true, children: [0, 1, 2].map((row) => (_jsx("div", { className: "h-[18px] rounded bg-[var(--bg)]" }, row))) })) : contentHealth.issues.length === 0 ? (_jsx("p", { className: "px-4 py-4 text-[12.5px] text-[var(--sub)]", children: "No outstanding issues. Nice work." })) : (contentHealth.issues.map((issue) => (_jsxs("button", { type: "button", onClick: () => nav('/seo'), className: "flex w-full items-center gap-[9px] border-b border-[var(--bdr)] px-4 py-[9px] text-left text-[12.5px] text-[var(--sub)] transition last:border-b-0 hover:bg-[var(--bg)]", children: [_jsx("span", { className: "h-[7px] w-[7px] shrink-0 rounded-full", style: { background: issue.dot }, "aria-hidden": true }), issue.label, _jsx("b", { className: "ml-auto font-bold text-[var(--txt)] tabular-nums", children: issue.count })] }, issue.kind))))] }), _jsx(DashboardCard, { title: "Delivery API", subtitle: "Headless content delivery \u00B7 last 24 hours", action: _jsx("button", { type: "button", className: "text-[12.5px] text-[var(--acc)] hover:underline", onClick: () => nav('/settings?tab=api-keys'), children: "API docs" }), children: _jsx(DeliveryGrid, { delivery: delivery, loading: deliveryLoading }) }), _jsx("div", { className: "min-[821px]:max-[1180px]:col-span-full", children: _jsx(DashboardCard, { title: "Publishing queue", subtitle: `${scheduled?.total ?? 0} items scheduled`, action: _jsx("button", { type: "button", className: "text-[12.5px] text-[var(--acc)] hover:underline", onClick: () => nav('/posts?status=scheduled'), children: "Manage" }), children: (scheduled?.items.length ?? 0) === 0 ? (_jsx(EmptyState, { icon: Clock, title: "No scheduled content", subtitle: "Scheduled posts and pages appear here.", compact: true })) : (_jsx("ul", { role: "list", children: scheduled.items.map((item) => {
552
+ const col = collections.find((entry) => entry.slug === item.collection);
553
+ const date = new Date(item.scheduledFor);
554
+ return (_jsx("li", { className: "border-b border-[var(--bdr)] last:border-b-0", children: _jsxs("button", { type: "button", onClick: () => nav(editPathForDoc(col, item.collection, item.id)), className: "flex w-full items-center gap-[11px] px-4 py-[11px] text-left transition hover:bg-[var(--bg)]", children: [_jsxs("span", { className: "w-[42px] shrink-0 rounded-[8px] bg-[var(--acc-l)] px-0 py-[5px] text-center leading-[1.1]", children: [_jsx("b", { className: "block text-[15px] font-bold text-[var(--acc)]", children: date.getDate() }), _jsx("span", { className: "block text-[9.5px] font-bold tracking-[0.5px] text-[var(--acc)] uppercase opacity-75", children: date.toLocaleDateString('en-US', { month: 'short' }) })] }), _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-[13px] font-medium text-[var(--txt)]", children: item.title }), _jsxs("span", { className: "mt-[2px] block truncate text-[11.5px] text-[var(--sub)]", children: [col ? collectionLabel(col, false) : item.collection, " \u00B7", ' ', item.author] })] })] }) }, item.id));
555
+ }) })) }) })] })] }))] }) }));
556
+ }
557
+ function DashboardCard({ title, subtitle, action, children, }) {
558
+ return (_jsxs("section", { className: "overflow-hidden rounded-[10px] border border-[var(--bdr)] bg-[var(--card)] shadow-[var(--shd)]", children: [_jsxs("header", { className: "flex items-center gap-[10px] border-b border-[var(--bdr)] px-4 py-[13px]", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h2", { className: "text-[14px] font-semibold text-[var(--txt)]", children: title }), subtitle ? _jsx("p", { className: "mt-[2px] text-[11.5px] text-[var(--sub)]", children: subtitle }) : null] }), action ? _jsx("div", { className: "ml-auto", children: action }) : null] }), children] }));
559
+ }
560
+ function HealthRing({ score }) {
561
+ const radius = 26;
562
+ const circumference = 2 * Math.PI * radius;
563
+ const color = score >= 70 ? 'var(--suc)' : score >= 40 ? 'var(--warn)' : 'var(--err)';
564
+ return (_jsxs("div", { className: "relative h-16 w-16 shrink-0", "aria-hidden": true, children: [_jsxs("svg", { width: "64", height: "64", children: [_jsx("circle", { cx: "32", cy: "32", r: radius, fill: "none", stroke: "var(--bdr)", strokeWidth: "6" }), _jsx("circle", { cx: "32", cy: "32", r: radius, fill: "none", stroke: color, strokeWidth: "6", strokeLinecap: "round", strokeDasharray: circumference, strokeDashoffset: circumference * (1 - Math.max(0, Math.min(100, score)) / 100), transform: "rotate(-90 32 32)" })] }), _jsx("div", { className: "absolute inset-0 flex items-center justify-center text-[20px] font-bold tracking-[-0.5px]", style: { color }, children: score })] }));
565
+ }
566
+ function EmptyState({ icon: Icon, title, subtitle, compact = false, action, }) {
567
+ return (_jsxs("div", { className: `flex flex-col items-center justify-center gap-1.5 text-center ${compact ? 'px-4 py-6' : 'px-6 py-10'}`, children: [_jsx(Icon, { className: "mb-1 h-7 w-7 text-[var(--muted)]", "aria-hidden": true }), _jsx("p", { className: "text-sm font-medium text-[var(--txt)]", children: title }), _jsx("p", { className: "max-w-xs text-xs text-[var(--sub)]", children: subtitle }), action] }));
442
568
  }
443
- // ─── Delivery API grid ──────────────────────────────────────────────────────
444
569
  function DeliveryGrid({ delivery, loading }) {
445
570
  if (loading && !delivery) {
446
- return (_jsx("div", { className: "divide-border grid grid-cols-2 divide-x divide-y lg:grid-cols-4 lg:divide-y-0", "aria-busy": true, children: [0, 1, 2, 3].map((i) => (_jsxs("div", { className: "px-6 py-4", children: [_jsx("div", { className: "bg-muted mb-2 h-3 w-24 rounded" }), _jsx("div", { className: "bg-muted mb-1.5 h-7 w-20 rounded" }), _jsx("div", { className: "bg-muted h-3 w-28 rounded" })] }, i))) }));
571
+ return (_jsx("div", { className: "grid grid-cols-2 gap-px bg-[var(--bdr)]", "aria-busy": true, children: [0, 1, 2, 3].map((tile) => (_jsxs("div", { className: "bg-[var(--card)] p-[13px_16px]", children: [_jsx("div", { className: "mb-2 h-3 w-24 rounded bg-[var(--bg)]" }), _jsx("div", { className: "mb-1.5 h-6 w-20 rounded bg-[var(--bg)]" }), _jsx("div", { className: "h-3 w-28 rounded bg-[var(--bg)]" })] }, tile))) }));
447
572
  }
448
573
  const hasData = delivery?.hasData ?? false;
449
574
  const requests = delivery?.requests24h ?? 0;
@@ -453,29 +578,47 @@ function DeliveryGrid({ delivery, loading }) {
453
578
  const p95Latency = delivery?.p95LatencyMs ?? 0;
454
579
  const webhookTotal = delivery?.webhookCount ?? 0;
455
580
  const webhookActive = delivery?.webhookActiveCount ?? 0;
456
- // Pretty-print large numbers (14_823 → "14.8K") so the tile stays
457
- // readable at the dashboard's compact density.
458
- const requestsLabel = formatLargeNumber(requests);
459
- const errorRatePct = (errorRate * 100).toFixed(2);
460
- return (_jsxs("div", { className: "divide-border grid grid-cols-2 divide-x divide-y lg:grid-cols-4 lg:divide-y-0", children: [_jsx(DeliveryTile, { icon: Activity, label: "API Requests (24h)", value: hasData ? requestsLabel : '—', sub: !hasData
461
- ? 'no traffic recorded yet'
462
- : delta === null
463
- ? 'no prior baseline'
464
- : `${delta >= 0 ? '+' : ''}${delta.toFixed(1)}% vs yesterday`, subIcon: hasData && typeof delta === 'number'
465
- ? delta >= 0
466
- ? TrendingUp
467
- : TrendingDown
468
- : undefined, tone: hasData ? (delta && delta >= 0 ? 'ok' : 'muted') : 'muted' }), _jsx(DeliveryTile, { icon: AlertCircle, label: "Error Rate", value: hasData ? `${errorRatePct}%` : '—', sub: !hasData
469
- ? 'no traffic recorded yet'
470
- : errorRate < 0.005
471
- ? 'healthy'
472
- : errorRate < 0.05
473
- ? 'elevated'
474
- : 'investigate', tone: !hasData ? 'muted' : errorRate < 0.005 ? 'ok' : errorRate < 0.05 ? 'warn' : 'err' }), _jsx(DeliveryTile, { icon: Gauge, label: "Avg Response Time", value: hasData ? `${Math.round(avgLatency)}ms` : '—', sub: hasData ? `p95: ${p95Latency}ms` : 'no traffic recorded yet', tone: !hasData ? 'muted' : avgLatency < 200 ? 'ok' : avgLatency < 600 ? 'warn' : 'err' }), _jsx(DeliveryTile, { icon: Zap, label: "Active Webhooks", value: `${webhookActive} / ${webhookTotal}`, sub: webhookTotal === 0
475
- ? 'none configured'
476
- : webhookActive === webhookTotal
477
- ? 'All active'
478
- : `${webhookTotal - webhookActive} paused`, tone: webhookTotal === 0 ? 'muted' : webhookActive === webhookTotal ? 'ok' : 'warn' })] }));
581
+ const tiles = [
582
+ {
583
+ icon: Activity,
584
+ label: 'Requests (24h)',
585
+ value: hasData ? formatLargeNumber(requests) : '—',
586
+ sub: !hasData
587
+ ? 'no traffic recorded yet'
588
+ : delta === null
589
+ ? 'no prior baseline'
590
+ : `${delta >= 0 ? '+' : ''}${delta.toFixed(1)}% vs yesterday`,
591
+ },
592
+ {
593
+ icon: AlertCircle,
594
+ label: 'Error rate',
595
+ value: hasData ? `${(errorRate * 100).toFixed(2)}%` : '—',
596
+ sub: !hasData
597
+ ? 'no traffic recorded yet'
598
+ : errorRate < 0.005
599
+ ? 'healthy'
600
+ : errorRate < 0.05
601
+ ? 'elevated'
602
+ : 'investigate',
603
+ },
604
+ {
605
+ icon: Gauge,
606
+ label: 'Avg response',
607
+ value: hasData ? `${Math.round(avgLatency)}ms` : '—',
608
+ sub: hasData ? `p95 · ${p95Latency}ms` : 'no traffic recorded yet',
609
+ },
610
+ {
611
+ icon: Zap,
612
+ label: 'Webhooks',
613
+ value: `${webhookActive} / ${webhookTotal}`,
614
+ sub: webhookTotal === 0
615
+ ? 'none configured'
616
+ : webhookActive === webhookTotal
617
+ ? 'All active'
618
+ : `${webhookTotal - webhookActive} paused`,
619
+ },
620
+ ];
621
+ return (_jsx("div", { className: "grid grid-cols-2 gap-px bg-[var(--bdr)]", children: tiles.map((tile) => (_jsxs("div", { className: "bg-[var(--card)] p-[13px_16px]", children: [_jsxs("div", { className: "flex items-center gap-[6px] text-[10.5px] font-bold tracking-[0.5px] text-[var(--sub)] uppercase", children: [_jsx(tile.icon, { size: 13, "aria-hidden": true }), tile.label] }), _jsx("p", { className: "mt-[5px] text-[20px] leading-tight font-bold tracking-[-0.5px] text-[var(--txt)] tabular-nums", children: tile.value }), _jsx("p", { className: "mt-[2px] text-[11px] text-[var(--sub)]", children: tile.sub })] }, tile.label))) }));
479
622
  }
480
623
  function formatLargeNumber(n) {
481
624
  if (n < 1000)
@@ -486,18 +629,4 @@ function formatLargeNumber(n) {
486
629
  return `${(n / 1000).toFixed(0)}K`;
487
630
  return `${(n / 1_000_000).toFixed(1)}M`;
488
631
  }
489
- // ─── Sub-components (kept in-file: smaller bundle, no extra module hops) ────
490
- function EmptyState({ icon: Icon, title, subtitle, compact = false, }) {
491
- return (_jsxs("div", { className: `flex flex-col items-center justify-center gap-1.5 text-center ${compact ? 'px-4 py-6' : 'px-6 py-10'}`, children: [_jsx(Icon, { className: "text-muted-foreground/50 mb-1 h-7 w-7", "aria-hidden": true }), _jsx("p", { className: "text-foreground text-sm font-medium", children: title }), _jsx("p", { className: "text-muted-foreground max-w-xs text-xs", children: subtitle })] }));
492
- }
493
- function DeliveryTile({ icon: Icon, label, value, sub, subIcon: SubIcon, tone = 'muted', }) {
494
- const subTone = tone === 'ok'
495
- ? 'text-success'
496
- : tone === 'warn'
497
- ? 'text-warning'
498
- : tone === 'err'
499
- ? 'text-destructive dark:text-red-400'
500
- : 'text-muted-foreground';
501
- return (_jsxs("div", { className: "px-6 py-4", children: [_jsxs("div", { className: "text-muted-foreground mb-1 flex items-center gap-1.5", children: [_jsx(Icon, { className: "h-3.5 w-3.5", "aria-hidden": true }), _jsx("span", { className: "text-[11px] font-medium", children: label })] }), _jsx("p", { className: "text-foreground text-xl leading-tight font-medium tracking-tight", children: value }), sub && (_jsxs("p", { className: `mt-0.5 inline-flex items-center gap-1 text-[11px] ${subTone}`, children: [SubIcon && _jsx(SubIcon, { className: "h-3 w-3 shrink-0", "aria-hidden": true }), sub] }))] }));
502
- }
503
632
  //# sourceMappingURL=Dashboard.js.map