@processfocus/runtime-local 0.1.0-next.1 → 0.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/README.md +48 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/{chunk-fn7b5pxw.js → chunk-04r0t2mb.js} +19364 -34104
  4. package/dist/chunk-727y6qkb.js +156 -0
  5. package/dist/chunk-bg5r4wpv.js +4755 -0
  6. package/dist/chunk-cbd36jq1.js +512 -0
  7. package/dist/chunk-d4ctj079.js +241 -0
  8. package/dist/{chunk-cq9xscgb.js → chunk-r5s2v669.js} +49079 -33564
  9. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
  10. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
  11. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
  12. package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
  13. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
  14. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
  15. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
  16. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
  17. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
  18. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
  19. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
  20. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
  21. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
  22. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
  23. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
  24. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
  25. package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
  26. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
  27. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
  28. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
  29. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +153 -16
  30. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +10 -2
  31. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +29 -13
  32. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
  33. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
  34. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
  35. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
  36. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
  37. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
  38. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
  39. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
  40. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
  41. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
  42. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
  43. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
  44. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
  45. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
  46. package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
  47. package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
  48. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
  49. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
  50. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
  51. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
  52. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
  53. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
  54. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
  55. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
  56. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
  57. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
  58. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
  59. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
  60. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
  61. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
  62. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
  63. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
  64. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
  65. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
  66. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
  67. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
  68. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
  69. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
  70. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
  71. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
  72. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
  73. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
  74. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
  75. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
  76. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
  77. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
  78. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
  79. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
  80. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
  81. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
  82. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
  83. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
  84. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
  85. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
  86. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
  87. package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
  88. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
  89. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
  90. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
  91. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
  92. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
  93. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
  94. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
  95. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
  96. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
  97. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
  98. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
  99. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
  100. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
  101. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
  102. package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
  103. package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
  104. package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
  105. package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
  106. package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
  107. package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
  108. package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
  109. package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
  110. package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
  111. package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
  112. package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
  113. package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
  114. package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
  115. package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +11 -4
  116. package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
  117. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
  118. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
  119. package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
  120. package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
  121. package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
  122. package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +47 -0
  123. package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
  124. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
  125. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
  126. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
  127. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
  128. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
  129. package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
  130. package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
  131. package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
  132. package/dist/dashboard-source/apps/frontend/components/Header.tsx +4 -8
  133. package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
  134. package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
  135. package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
  136. package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
  137. package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
  138. package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
  139. package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
  140. package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
  141. package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
  142. package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
  143. package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
  144. package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
  145. package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
  146. package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
  147. package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
  148. package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
  149. package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
  150. package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
  151. package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
  152. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
  153. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
  154. package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
  155. package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
  156. package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
  157. package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
  158. package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
  159. package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
  160. package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
  161. package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
  162. package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
  163. package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
  164. package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
  165. package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
  166. package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
  167. package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
  168. package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +112 -21
  169. package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
  170. package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
  171. package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
  172. package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
  173. package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
  174. package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
  175. package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
  176. package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
  177. package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
  178. package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
  179. package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
  180. package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
  181. package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
  182. package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
  183. package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
  184. package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
  185. package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
  186. package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
  187. package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
  188. package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
  189. package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
  190. package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
  191. package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +169 -30
  192. package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
  193. package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
  194. package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
  195. package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +38 -29
  196. package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
  197. package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
  198. package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
  199. package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
  200. package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
  201. package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
  202. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
  203. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
  204. package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
  205. package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
  206. package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
  207. package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
  208. package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +900 -0
  209. package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +42 -0
  210. package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
  211. package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
  212. package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
  213. package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
  214. package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +193 -0
  215. package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +237 -0
  216. package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
  217. package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
  218. package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
  219. package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
  220. package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
  221. package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
  222. package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
  223. package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
  224. package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
  225. package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
  226. package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
  227. package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
  228. package/dist/dashboard-source/apps/frontend/package.json +48 -47
  229. package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
  230. package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
  231. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
  232. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
  233. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
  234. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
  235. package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
  236. package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
  237. package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
  238. package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
  239. package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
  240. package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
  241. package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
  242. package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
  243. package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
  244. package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
  245. package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
  246. package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
  247. package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
  248. package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
  249. package/dist/dashboard-source/modules/form/src/index.ts +1 -10
  250. package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
  251. package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
  252. package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
  253. package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
  254. package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
  255. package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
  256. package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
  257. package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
  258. package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
  259. package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
  260. package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
  261. package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
  262. package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
  263. package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
  264. package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
  265. package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
  266. package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
  267. package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
  268. package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
  269. package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
  270. package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
  271. package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
  272. package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
  273. package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
  274. package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
  275. package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
  276. package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
  277. package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
  278. package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
  279. package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
  280. package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
  281. package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
  282. package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
  283. package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
  284. package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
  285. package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
  286. package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
  287. package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
  288. package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
  289. package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
  290. package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
  291. package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
  292. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
  293. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
  294. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +272 -0
  295. package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
  296. package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
  297. package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
  298. package/dist/dashboard-source.json +48 -47
  299. package/dist/graphql-server.mjs +245 -200
  300. package/dist/job-worker-supervisor.mjs +262 -0
  301. package/dist/job-worker.mjs +234 -133
  302. package/dist/main.mjs +23 -4
  303. package/dist/prepare-dashboard.mjs +8 -8
  304. package/dist/resources/cedar/policies.cedar +80 -38
  305. package/dist/resources/cedar/schema.cedarschema +39 -21
  306. package/dist/resources/graphql-schema/rxdb.graphql +2 -0
  307. package/dist/resources/graphql-schema/system.graphql +204 -51
  308. package/package.json +64 -62
  309. package/dist/chunk-6b6t8tyq.js +0 -85
  310. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
  311. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
  312. package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
  313. package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
  314. package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
  315. package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
  316. package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
  317. package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
  318. package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
  319. package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
  320. package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
  321. package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
  322. package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
  323. package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
  324. package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
  325. package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
  326. package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
@@ -1,1317 +1,6 @@
1
- "use client"
1
+ import ToDosPage from "./to-dos-client.tsx"
2
2
 
3
- import type { Collection } from "@tanstack/db"
4
- import { useLiveQuery } from "@tanstack/react-db"
5
- import DOMPurify from "dompurify"
6
- import Link from "next/link"
7
- import {
8
- type ReactNode,
9
- Suspense,
10
- use,
11
- useEffect,
12
- useMemo,
13
- useState,
14
- } from "react"
15
- import type { TaskPriority } from "../../../../../modules/rxdb-collections/src/index.ts"
16
- import { Button } from "../../../../../modules/shadcn-components/src/index.ts"
17
- import {
18
- type MobileTodoListItem,
19
- createMobileTodoList,
20
- } from "./lib/mobile-todo-list.ts"
21
- import { useMocks } from "@/components/mocks-provider"
22
- import {
23
- TodoCollectionProvider,
24
- type TodoDocType,
25
- useTodoCollection,
26
- } from "@/lib/collections/todo-collection-provider"
27
- import { type Task, tasks } from "@/lib/mock-data"
28
- import {
29
- type SavedView,
30
- type TaskStatus,
31
- taskSavedViews,
32
- todoStatusSortOrder,
33
- } from "@/lib/todo-types"
34
- import {
35
- assignedAtRefreshDelay,
36
- computeTodoStatus,
37
- formatAssignedAtExact,
38
- formatAssignedAtLabel,
39
- formatDueStatus,
40
- isDueWithin24Hours,
41
- useOverdueRefresh,
42
- } from "@/lib/todo-utils"
43
- import { toUrlPath } from "@/lib/utils"
3
+ // The authenticated layout can omit this page while checking the session.
4
+ export const instant = false
44
5
 
45
- // Completed Todos can appear in local data, but this page's filters focus on
46
- // actionable work queues rather than historical completion state.
47
- const statusOptions: TaskStatus[] = [
48
- "Active",
49
- "Correction Required",
50
- "Upcoming",
51
- "Draft",
52
- "Overdue",
53
- ]
54
-
55
- const priorityOptions: TaskPriority[] = ["High", "Medium", "Low"]
56
-
57
- const sortOptions = [
58
- "Due date",
59
- "Priority",
60
- "Date created",
61
- "Alphabetical",
62
- ] as const
63
-
64
- type TaskSortKey = (typeof sortOptions)[number]
65
-
66
- function cn(...values: Array<string | false | null | undefined>): string {
67
- return values.filter(Boolean).join(" ")
68
- }
69
-
70
- const statusTheme: Record<TaskStatus, { badge: string; card: string }> = {
71
- Active: {
72
- badge:
73
- "bg-emerald-100 text-emerald-700 border border-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-300 dark:border-emerald-500/30",
74
- card: "border-emerald-100 dark:border-emerald-500/20",
75
- },
76
- Upcoming: {
77
- badge:
78
- "bg-slate-100 text-slate-600 border border-slate-200 dark:bg-slate-700/40 dark:text-slate-300 dark:border-slate-600/60",
79
- card: "border-dashed border-slate-200 dark:border-slate-700",
80
- },
81
- Draft: {
82
- badge:
83
- "bg-indigo-100 text-indigo-700 border border-indigo-200 dark:bg-indigo-500/10 dark:text-indigo-300 dark:border-indigo-500/30",
84
- card: "border-indigo-100 dark:border-indigo-500/20",
85
- },
86
- Overdue: {
87
- badge:
88
- "bg-rose-100 text-rose-700 border border-rose-200 dark:bg-rose-500/10 dark:text-rose-300 dark:border-rose-500/30",
89
- card: "border-rose-200 dark:border-rose-500/30 bg-rose-50/70 dark:bg-rose-900/20",
90
- },
91
- "Correction Required": {
92
- badge:
93
- "bg-amber-100 text-amber-800 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-300 dark:border-amber-500/30",
94
- card: "border-amber-200 dark:border-amber-500/30 bg-amber-50/70 dark:bg-amber-900/20",
95
- },
96
- Completed: {
97
- badge:
98
- "bg-slate-100 text-slate-600 border border-slate-200 dark:bg-slate-700/40 dark:text-slate-300 dark:border-slate-600/60",
99
- card: "border-slate-200 dark:border-slate-700 opacity-80",
100
- },
101
- }
102
-
103
- const priorityTheme: Record<TaskPriority, string> = {
104
- High: "bg-rose-500",
105
- Medium: "bg-amber-400",
106
- Low: "bg-slate-400",
107
- }
108
-
109
- const correctionHelp = "Correct the recipient email and send a new invitation."
110
-
111
- function ToDosPageContent() {
112
- const { showMocks } = useMocks()
113
-
114
- return (
115
- <div className="flex-1 overflow-y-auto">
116
- {/* Real todos from RxDB collection */}
117
- <RealTodosSection />
118
-
119
- {/* Mock data section below for reference */}
120
- {showMocks && <MockTodosSection />}
121
- </div>
122
- )
123
- }
124
-
125
- export default function ToDosPage() {
126
- return (
127
- <TodoCollectionProvider>
128
- <ToDosPageContent />
129
- </TodoCollectionProvider>
130
- )
131
- }
132
-
133
- /**
134
- * @deprecated This component displays mock data for design reference.
135
- * Will be removed once RealTodosSection is fully styled.
136
- */
137
- function MockTodosSection() {
138
- const [density, setDensity] = useState<"comfortable" | "compact">(
139
- "comfortable",
140
- )
141
- const [selectedView, setSelectedView] = useState<SavedView["id"]>(
142
- taskSavedViews[0]?.id ?? "all",
143
- )
144
- const [statusFilter, setStatusFilter] = useState<TaskStatus[]>(
145
- taskSavedViews[0]?.statuses ?? [],
146
- )
147
- const [priorityFilter, setPriorityFilter] = useState<TaskPriority[]>(
148
- taskSavedViews[0]?.priorities ?? [],
149
- )
150
- const [sortKey, setSortKey] = useState<TaskSortKey>("Due date")
151
-
152
- const filteredTasks = useMemo(() => {
153
- return tasks.filter((task) => {
154
- const statusMatch =
155
- statusFilter.length === 0 || statusFilter.includes(task.status)
156
- const priorityMatch =
157
- priorityFilter.length === 0 || priorityFilter.includes(task.priority)
158
- return statusMatch && priorityMatch
159
- })
160
- }, [priorityFilter, statusFilter])
161
-
162
- const sortedTasks = useMemo(() => {
163
- const list = [...filteredTasks]
164
- if (sortKey === "Priority") {
165
- const rank: Record<TaskPriority, number> = { High: 0, Medium: 1, Low: 2 }
166
- list.sort((a, b) => rank[a.priority] - rank[b.priority])
167
- } else if (sortKey === "Alphabetical") {
168
- list.sort((a, b) => a.stepName.localeCompare(b.stepName))
169
- } else if (sortKey === "Due date") {
170
- list.sort(
171
- (a, b) => todoStatusSortOrder[a.status] - todoStatusSortOrder[b.status],
172
- )
173
- }
174
- return list
175
- }, [filteredTasks, sortKey])
176
-
177
- function handleSelectView(viewId: SavedView["id"]) {
178
- setSelectedView(viewId)
179
- const view = taskSavedViews.find((item) => item.id === viewId)
180
- if (view) {
181
- setStatusFilter(view.statuses)
182
- setPriorityFilter(view.priorities)
183
- }
184
- }
185
-
186
- function toggleStatusFilter(status: TaskStatus) {
187
- setStatusFilter((previous) =>
188
- previous.includes(status)
189
- ? previous.filter((item) => item !== status)
190
- : [...previous, status],
191
- )
192
- setSelectedView("custom")
193
- }
194
-
195
- function togglePriorityFilter(priority: TaskPriority) {
196
- setPriorityFilter((previous) =>
197
- previous.includes(priority)
198
- ? previous.filter((item) => item !== priority)
199
- : [...previous, priority],
200
- )
201
- setSelectedView("custom")
202
- }
203
-
204
- function clearStatusOnly() {
205
- setStatusFilter([])
206
- setSelectedView("custom")
207
- }
208
-
209
- function clearPriorityOnly() {
210
- setPriorityFilter([])
211
- setSelectedView("custom")
212
- }
213
-
214
- function clearTaskFilters() {
215
- clearStatusOnly()
216
- clearPriorityOnly()
217
- }
218
-
219
- const overdueCount = tasks.filter((task) => task.status === "Overdue").length
220
- const draftCount = tasks.filter((task) => task.status === "Draft").length
221
- const upcomingCount = tasks.filter(
222
- (task) => task.status === "Upcoming",
223
- ).length
224
-
225
- return (
226
- <section className="mt-8 space-y-6">
227
- <div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
228
- <OverviewCard
229
- title="Active tasks"
230
- value={tasks
231
- .filter((task) => task.status === "Active")
232
- .length.toString()}
233
- subtext="Due within 24 hours: 2"
234
- accent="bg-sky-500"
235
- />
236
- <OverviewCard
237
- title="Overdue"
238
- value={overdueCount.toString()}
239
- subtext="Escalations triggered today"
240
- accent="bg-rose-500"
241
- />
242
- <OverviewCard
243
- title="Drafts"
244
- value={draftCount.toString()}
245
- subtext="Autosave enabled every 30s"
246
- accent="bg-indigo-500"
247
- />
248
- <OverviewCard
249
- title="Upcoming"
250
- value={upcomingCount.toString()}
251
- subtext="Forecast across next 7 days"
252
- accent="bg-amber-500"
253
- />
254
- </div>
255
- <div className="flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/60">
256
- <div className="flex flex-wrap gap-2">
257
- {taskSavedViews.map((view) => {
258
- const isActive = selectedView === view.id
259
- return (
260
- <button
261
- key={view.id}
262
- type="button"
263
- onClick={() => handleSelectView(view.id)}
264
- className={cn(
265
- "rounded-full border px-4 py-1.5 text-sm font-medium transition",
266
- isActive
267
- ? "border-blue-500 bg-blue-500 text-white shadow-sm"
268
- : "border-slate-200 text-slate-600 hover:border-slate-300 hover:bg-slate-100 dark:border-slate-700 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:bg-slate-800",
269
- )}
270
- >
271
- {view.name}
272
- </button>
273
- )
274
- })}
275
- {selectedView === "custom" && (
276
- <span className="rounded-full border border-dashed border-blue-300 px-4 py-1.5 text-sm font-medium text-blue-500">
277
- Custom view
278
- </span>
279
- )}
280
- </div>
281
- <div className="flex items-center gap-2">
282
- <button
283
- type="button"
284
- onClick={() => setDensity("comfortable")}
285
- className={cn(
286
- "rounded-full border px-3 py-1.5 text-sm",
287
- density === "comfortable"
288
- ? "border-blue-500 text-blue-600 dark:text-blue-300"
289
- : "border-slate-200 text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200",
290
- )}
291
- >
292
- Comfortable
293
- </button>
294
- <button
295
- type="button"
296
- onClick={() => setDensity("compact")}
297
- className={cn(
298
- "rounded-full border px-3 py-1.5 text-sm",
299
- density === "compact"
300
- ? "border-blue-500 text-blue-600 dark:text-blue-300"
301
- : "border-slate-200 text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200",
302
- )}
303
- >
304
- Compact
305
- </button>
306
- </div>
307
- </div>
308
- <div className="flex flex-col gap-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/60">
309
- <div className="flex flex-wrap gap-3">
310
- <FilterGroup
311
- label="Status"
312
- onClear={statusFilter.length > 0 ? clearStatusOnly : undefined}
313
- >
314
- {statusOptions.map((status) => (
315
- <Chip
316
- key={status}
317
- label={status}
318
- active={statusFilter.includes(status)}
319
- onClick={() => toggleStatusFilter(status)}
320
- />
321
- ))}
322
- </FilterGroup>
323
- <FilterGroup
324
- label="Priority"
325
- onClear={priorityFilter.length > 0 ? clearPriorityOnly : undefined}
326
- >
327
- {priorityOptions.map((priority) => (
328
- <Chip
329
- key={priority}
330
- label={priority}
331
- active={priorityFilter.includes(priority)}
332
- icon={
333
- <span
334
- className={cn(
335
- "h-2.5 w-2.5 rounded-full",
336
- priorityTheme[priority],
337
- )}
338
- />
339
- }
340
- onClick={() => togglePriorityFilter(priority)}
341
- />
342
- ))}
343
- </FilterGroup>
344
- <div className="ml-auto flex flex-wrap items-center gap-3">
345
- <div className="flex items-center gap-2 rounded-full border border-slate-200 bg-white px-3 py-1.5 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900">
346
- <label
347
- htmlFor="mock-sort-select"
348
- className="text-xs tracking-wide text-slate-400 uppercase"
349
- >
350
- Sort
351
- </label>
352
- <select
353
- id="mock-sort-select"
354
- value={sortKey}
355
- onChange={(event) =>
356
- setSortKey(event.target.value as TaskSortKey)
357
- }
358
- className="bg-transparent text-sm font-medium text-slate-700 outline-none dark:text-slate-200"
359
- >
360
- {sortOptions.map((option) => (
361
- <option key={option} value={option}>
362
- {option}
363
- </option>
364
- ))}
365
- </select>
366
- </div>
367
- {(statusFilter.length > 0 || priorityFilter.length > 0) && (
368
- <button
369
- type="button"
370
- onClick={clearTaskFilters}
371
- className="rounded-full border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200"
372
- >
373
- Clear filters
374
- </button>
375
- )}
376
- </div>
377
- </div>
378
- <div
379
- className={cn(
380
- "grid gap-4",
381
- density === "compact"
382
- ? "md:grid-cols-2 xl:grid-cols-3"
383
- : "md:grid-cols-2 xl:grid-cols-2",
384
- )}
385
- >
386
- {sortedTasks.length === 0 ? (
387
- <EmptyState
388
- title="No tasks match these filters"
389
- description="Try expanding your filters or check the Processes catalog to kick off new work."
390
- />
391
- ) : (
392
- sortedTasks.map((task) => (
393
- <MockTodoCard key={task.id} task={task} density={density} />
394
- ))
395
- )}
396
- </div>
397
- </div>
398
- </section>
399
- )
400
- }
401
-
402
- function OverviewCard({
403
- title,
404
- value,
405
- subtext,
406
- accent,
407
- }: {
408
- title: string
409
- value: string
410
- subtext: string
411
- accent: string
412
- }) {
413
- return (
414
- <div className="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm transition hover:shadow-md dark:border-slate-800 dark:bg-slate-900/70">
415
- <div className="flex items-center justify-between px-5 pt-5">
416
- <p className="text-sm font-semibold text-slate-500 dark:text-slate-400">
417
- {title}
418
- </p>
419
- <span className={cn("h-2 w-12 rounded-full", accent)} />
420
- </div>
421
- <div className="px-5 pb-5">
422
- <p className="text-3xl font-semibold text-slate-900 dark:text-slate-50">
423
- {value}
424
- </p>
425
- <p className="text-sm text-slate-500 dark:text-slate-400">{subtext}</p>
426
- </div>
427
- </div>
428
- )
429
- }
430
-
431
- function FilterGroup({
432
- label,
433
- children,
434
- onClear,
435
- }: {
436
- label: string
437
- children: ReactNode
438
- onClear?: (() => void) | undefined
439
- }) {
440
- return (
441
- <div className="flex flex-wrap items-center gap-2 rounded-full border border-slate-200 bg-white px-3 py-1.5 text-sm text-slate-500 shadow-sm dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400">
442
- <span className="text-xs tracking-wide text-slate-400 uppercase dark:text-slate-500">
443
- {label}
444
- </span>
445
- {children}
446
- {onClear && (
447
- <button
448
- type="button"
449
- onClick={onClear}
450
- className="text-xs font-semibold text-blue-500 hover:text-blue-600"
451
- >
452
- Clear
453
- </button>
454
- )}
455
- </div>
456
- )
457
- }
458
-
459
- function Chip({
460
- label,
461
- active,
462
- onClick,
463
- icon,
464
- }: {
465
- label: string
466
- active: boolean
467
- onClick: () => void
468
- icon?: ReactNode
469
- }) {
470
- return (
471
- <button
472
- type="button"
473
- onClick={onClick}
474
- className={cn(
475
- "inline-flex items-center gap-2 rounded-full border px-3 py-1 text-sm transition",
476
- active
477
- ? "border-blue-500 bg-blue-500/10 text-blue-600 dark:border-blue-400 dark:bg-blue-500/10 dark:text-blue-200"
478
- : "border-transparent text-slate-600 hover:border-slate-200 hover:bg-slate-100 dark:text-slate-300 dark:hover:border-slate-700 dark:hover:bg-slate-800",
479
- )}
480
- >
481
- {icon}
482
- {label}
483
- </button>
484
- )
485
- }
486
-
487
- /**
488
- * @deprecated This component will be deleted in the near future.
489
- * Use RealTodoCard instead.
490
- */
491
- function MockTodoCard({
492
- task,
493
- density,
494
- }: {
495
- task: Task
496
- density: "comfortable" | "compact"
497
- }) {
498
- return (
499
- <article
500
- className={cn(
501
- "flex flex-col gap-3 rounded-2xl border bg-white p-4 shadow-sm transition hover:-translate-y-0.5 hover:shadow-md dark:bg-slate-900/70",
502
- statusTheme[task.status].card,
503
- density === "compact" ? "sm:p-3" : "sm:p-5",
504
- )}
505
- >
506
- <header className="flex items-start justify-between gap-3">
507
- <div className="space-y-1">
508
- <div className="inline-flex items-center gap-2">
509
- <span className="text-xs font-semibold tracking-wide text-slate-400 uppercase dark:text-slate-500">
510
- {task.processName}
511
- </span>
512
- <span
513
- className={cn(
514
- "inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",
515
- statusTheme[task.status].badge,
516
- )}
517
- >
518
- {task.status}
519
- </span>
520
- <span className="inline-flex items-center gap-1 rounded-full border border-slate-200 px-2 py-0.5 text-xs font-semibold text-slate-500 dark:border-slate-700 dark:text-slate-300">
521
- <span
522
- className={cn(
523
- "h-2 w-2 rounded-full",
524
- priorityTheme[task.priority],
525
- )}
526
- />
527
- {task.priority}
528
- </span>
529
- <span className="inline-flex items-center gap-1 rounded-full bg-slate-100 px-2 py-0.5 text-xs font-semibold text-slate-600 dark:bg-slate-700/60 dark:text-slate-300">
530
- {task.role}
531
- </span>
532
- </div>
533
- <h3 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
534
- {task.stepName}
535
- </h3>
536
- <p className="text-sm text-slate-500 dark:text-slate-400">
537
- {task.description}
538
- </p>
539
- </div>
540
- <button
541
- type="button"
542
- className="rounded-full border border-slate-200 px-3 py-1 text-xs font-semibold text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200"
543
- >
544
- View details
545
- </button>
546
- </header>
547
- <div className="flex flex-wrap items-center gap-2 text-xs text-slate-500 dark:text-slate-400">
548
- {task.dueDate && (
549
- <span className="inline-flex items-center gap-1 rounded-full bg-slate-100 px-2 py-1 dark:bg-slate-800">
550
- ⏰ {task.dueDate}
551
- </span>
552
- )}
553
- {task.upcomingIn && (
554
- <span className="inline-flex items-center gap-1 rounded-full border border-dashed border-slate-200 px-2 py-1 text-slate-500 dark:border-slate-700 dark:text-slate-300">
555
- ⏳ {task.upcomingIn}
556
- </span>
557
- )}
558
- {task.overdueBy && (
559
- <span className="inline-flex items-center gap-1 rounded-full bg-rose-100 px-2 py-1 text-rose-700 dark:bg-rose-500/10 dark:text-rose-300">
560
- ⚠️ {task.overdueBy}
561
- </span>
562
- )}
563
- {task.draftSavedAt && (
564
- <span className="inline-flex items-center gap-1 rounded-full bg-indigo-100 px-2 py-1 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-300">
565
- 💾 {task.draftSavedAt}
566
- </span>
567
- )}
568
- <span className="inline-flex items-center gap-1 rounded-full border border-slate-200 px-2 py-1 text-slate-500 dark:border-slate-700 dark:text-slate-300">
569
- 🧭 Assigned {task.assignedDate}
570
- </span>
571
- <span className="inline-flex items-center gap-1 rounded-full border border-slate-200 px-2 py-1 text-slate-500 dark:border-slate-700 dark:text-slate-300">
572
- 📝 {task.formComplexity} form
573
- </span>
574
- </div>
575
- <footer className="mt-auto flex flex-wrap items-center justify-between gap-2">
576
- <div className="flex items-center gap-2">
577
- <Button className="min-w-20 rounded-full">
578
- {task.status === "Draft"
579
- ? "Continue"
580
- : task.status === "Upcoming"
581
- ? "Preview"
582
- : "Do"}
583
- </Button>
584
- <Button variant="outline" className="rounded-full">
585
- Delegate
586
- </Button>
587
- </div>
588
- <button
589
- type="button"
590
- className="text-xs font-semibold text-blue-500 hover:text-blue-600"
591
- >
592
- Open form preview →
593
- </button>
594
- </footer>
595
- </article>
596
- )
597
- }
598
-
599
- function EmptyState({
600
- title,
601
- description,
602
- action,
603
- }: {
604
- title: string
605
- description: string
606
- action?: { label: string; href: string }
607
- }) {
608
- return (
609
- <div className="col-span-full flex flex-col items-center justify-center rounded-3xl border border-dashed border-slate-300 bg-white/60 p-12 text-center dark:border-slate-700 dark:bg-slate-900/40">
610
- <h3 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
611
- {title}
612
- </h3>
613
- <p className="mt-2 max-w-md text-sm text-slate-500 dark:text-slate-400">
614
- {description}
615
- </p>
616
- {action && (
617
- <Link
618
- href={action.href}
619
- className="mt-5 rounded-full bg-blue-600 px-5 py-2 text-sm font-semibold text-white shadow hover:bg-blue-500"
620
- >
621
- {action.label}
622
- </Link>
623
- )}
624
- </div>
625
- )
626
- }
627
-
628
- // ============================================================================
629
- // Real Todos Section (using RxDB collection)
630
- // ============================================================================
631
-
632
- function RealTodosLoadingState() {
633
- return (
634
- <section className="space-y-6">
635
- <div className="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-900/60">
636
- <div className="flex items-center gap-3">
637
- <div className="h-5 w-5 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
638
- <span className="text-sm text-slate-500 dark:text-slate-400">
639
- Loading todos...
640
- </span>
641
- </div>
642
- </div>
643
- </section>
644
- )
645
- }
646
-
647
- function RealTodosSectionInner({
648
- collectionPromise,
649
- }: {
650
- collectionPromise: Promise<Collection<TodoDocType, string>>
651
- }) {
652
- "use memo"
653
-
654
- // Suspend until collection is ready
655
- const todosCollection = use(collectionPromise)
656
-
657
- // Query todos from RxDB collection
658
- const todosQuery = useLiveQuery((q) =>
659
- q.from({ todo: todosCollection }).select(({ todo }) => ({
660
- id: todo.id,
661
- updatedAt: todo.updatedAt,
662
- processExecutionId: todo.processExecutionId,
663
- flowId: todo.flowId,
664
- processName: todo.processName,
665
- stepName: todo.stepName,
666
- stepPath: todo.stepPath,
667
- role: todo.role,
668
- description: todo.description,
669
- status: todo.status,
670
- priority: todo.priority,
671
- assignedAt: todo.assignedAt,
672
- dueAt: todo.dueAt,
673
- formComplexity: todo.formComplexity,
674
- summary: todo.summary,
675
- })),
676
- )
677
-
678
- const todos = todosQuery.data ?? []
679
-
680
- // Filter state
681
- const [density, setDensity] = useState<"comfortable" | "compact">(
682
- "comfortable",
683
- )
684
- const [selectedView, setSelectedView] = useState<SavedView["id"]>(
685
- taskSavedViews[0]?.id ?? "all",
686
- )
687
- const [statusFilter, setStatusFilter] = useState<TaskStatus[]>(
688
- taskSavedViews[0]?.statuses ?? [],
689
- )
690
- const [priorityFilter, setPriorityFilter] = useState<TaskPriority[]>(
691
- taskSavedViews[0]?.priorities ?? [],
692
- )
693
- const [sortKey, setSortKey] = useState<TaskSortKey>("Due date")
694
-
695
- // Single pass: compute status counts, due-within-24h count, filter todos, and collect dueTimes
696
- const counts: Record<TaskStatus, number> = {
697
- Active: 0,
698
- Completed: 0,
699
- "Correction Required": 0,
700
- Overdue: 0,
701
- Draft: 0,
702
- Upcoming: 0,
703
- }
704
- let dueWithin24HoursCount = 0
705
- const filteredTodos: typeof todos = []
706
- const dueTimes: (string | null | undefined)[] = []
707
-
708
- for (const todo of todos) {
709
- const status = computeTodoStatus(todo.dueAt, todo.status)
710
- counts[status]++
711
- dueTimes.push(todo.dueAt)
712
-
713
- if (status === "Active" && isDueWithin24Hours(todo.dueAt)) {
714
- dueWithin24HoursCount++
715
- }
716
-
717
- const statusMatch =
718
- statusFilter.length === 0 || statusFilter.includes(status)
719
- const priorityMatch =
720
- priorityFilter.length === 0 || priorityFilter.includes(todo.priority)
721
-
722
- if (statusMatch && priorityMatch) {
723
- filteredTodos.push(todo)
724
- }
725
- }
726
-
727
- useOverdueRefresh(dueTimes)
728
-
729
- // Sort todos
730
- const sortedTodos = [...filteredTodos]
731
- if (sortKey === "Priority") {
732
- const rank: Record<TaskPriority, number> = { High: 0, Medium: 1, Low: 2 }
733
- sortedTodos.sort((a, b) => rank[a.priority] - rank[b.priority])
734
- } else if (sortKey === "Alphabetical") {
735
- sortedTodos.sort((a, b) => a.stepName.localeCompare(b.stepName))
736
- } else if (sortKey === "Due date") {
737
- sortedTodos.sort(
738
- (a, b) =>
739
- todoStatusSortOrder[computeTodoStatus(a.dueAt, a.status)] -
740
- todoStatusSortOrder[computeTodoStatus(b.dueAt, b.status)],
741
- )
742
- }
743
-
744
- // Mobile intentionally skips the desktop control bars in this first pass.
745
- // Known gap: mobile also ignores the desktop saved-view/filter/sort state.
746
- const mobileTodoList = createMobileTodoList(todos)
747
-
748
- function handleSelectView(viewId: SavedView["id"]) {
749
- setSelectedView(viewId)
750
- const view = taskSavedViews.find((item) => item.id === viewId)
751
- if (view) {
752
- setStatusFilter(view.statuses)
753
- setPriorityFilter(view.priorities)
754
- }
755
- }
756
-
757
- function toggleStatusFilter(status: TaskStatus) {
758
- setStatusFilter((previous) =>
759
- previous.includes(status)
760
- ? previous.filter((item) => item !== status)
761
- : [...previous, status],
762
- )
763
- setSelectedView("custom")
764
- }
765
-
766
- function togglePriorityFilter(priority: TaskPriority) {
767
- setPriorityFilter((previous) =>
768
- previous.includes(priority)
769
- ? previous.filter((item) => item !== priority)
770
- : [...previous, priority],
771
- )
772
- setSelectedView("custom")
773
- }
774
-
775
- function clearStatusOnly() {
776
- setStatusFilter([])
777
- setSelectedView("custom")
778
- }
779
-
780
- function clearPriorityOnly() {
781
- setPriorityFilter([])
782
- setSelectedView("custom")
783
- }
784
-
785
- function clearAllFilters() {
786
- clearStatusOnly()
787
- clearPriorityOnly()
788
- }
789
-
790
- if (!todosQuery.isReady) {
791
- return <RealTodosLoadingState />
792
- }
793
-
794
- const {
795
- Active: activeCount,
796
- "Correction Required": correctionRequiredCount,
797
- Overdue: overdueCount,
798
- Draft: draftCount,
799
- Upcoming: upcomingCount,
800
- } = counts
801
-
802
- return (
803
- <section className="space-y-6">
804
- {/* Overview cards */}
805
- <div className="hidden gap-4 md:grid md:grid-cols-2 xl:grid-cols-5">
806
- <OverviewCard
807
- title="Active tasks"
808
- value={activeCount.toString()}
809
- subtext={`Due within 24 hours: ${dueWithin24HoursCount}`}
810
- accent="bg-sky-500"
811
- />
812
- <OverviewCard
813
- title="Corrections"
814
- value={correctionRequiredCount.toString()}
815
- subtext="Recipient update needed"
816
- accent="bg-amber-500"
817
- />
818
- <OverviewCard
819
- title="Overdue"
820
- value={overdueCount.toString()}
821
- subtext="Requires attention"
822
- accent="bg-rose-500"
823
- />
824
- <OverviewCard
825
- title="Drafts"
826
- value={draftCount.toString()}
827
- subtext="In progress"
828
- accent="bg-indigo-500"
829
- />
830
- <OverviewCard
831
- title="Upcoming"
832
- value={upcomingCount.toString()}
833
- subtext="Scheduled tasks"
834
- accent="bg-amber-500"
835
- />
836
- </div>
837
-
838
- {/* Filter bar with saved views and density toggle */}
839
- <div className="hidden flex-wrap items-center justify-between gap-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/60 md:flex">
840
- <div className="flex flex-wrap gap-2">
841
- {taskSavedViews.map((view) => {
842
- const isActive = selectedView === view.id
843
- return (
844
- <button
845
- key={view.id}
846
- type="button"
847
- onClick={() => handleSelectView(view.id)}
848
- className={cn(
849
- "rounded-full border px-4 py-1.5 text-sm font-medium transition",
850
- isActive
851
- ? "border-blue-500 bg-blue-500 text-white shadow-sm"
852
- : "border-slate-200 text-slate-600 hover:border-slate-300 hover:bg-slate-100 dark:border-slate-700 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:bg-slate-800",
853
- )}
854
- >
855
- {view.name}
856
- </button>
857
- )
858
- })}
859
- {selectedView === "custom" && (
860
- <span className="rounded-full border border-dashed border-blue-300 px-4 py-1.5 text-sm font-medium text-blue-500">
861
- Custom view
862
- </span>
863
- )}
864
- </div>
865
- <div className="flex items-center gap-2">
866
- <button
867
- type="button"
868
- onClick={() => setDensity("comfortable")}
869
- className={cn(
870
- "rounded-full border px-3 py-1.5 text-sm",
871
- density === "comfortable"
872
- ? "border-blue-500 text-blue-600 dark:text-blue-300"
873
- : "border-slate-200 text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200",
874
- )}
875
- >
876
- Comfortable
877
- </button>
878
- <button
879
- type="button"
880
- onClick={() => setDensity("compact")}
881
- className={cn(
882
- "rounded-full border px-3 py-1.5 text-sm",
883
- density === "compact"
884
- ? "border-blue-500 text-blue-600 dark:text-blue-300"
885
- : "border-slate-200 text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200",
886
- )}
887
- >
888
- Compact
889
- </button>
890
- </div>
891
- </div>
892
-
893
- <div className="space-y-4 md:hidden">
894
- {mobileTodoList.length === 0 ? (
895
- <EmptyState
896
- title="No to-dos yet"
897
- description="Check back here when new work reaches your queue."
898
- action={{ label: "Browse processes", href: "/processes" }}
899
- />
900
- ) : (
901
- mobileTodoList.map((todo) => (
902
- <MobileTodoRow key={todo.id} todo={todo} />
903
- ))
904
- )}
905
- </div>
906
-
907
- {/* Filter row and todo cards */}
908
- <div className="hidden flex-col gap-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900/60 md:flex">
909
- <div className="flex flex-wrap gap-3">
910
- <FilterGroup
911
- label="Status"
912
- onClear={statusFilter.length > 0 ? clearStatusOnly : undefined}
913
- >
914
- {statusOptions.map((status) => (
915
- <Chip
916
- key={status}
917
- label={status}
918
- active={statusFilter.includes(status)}
919
- onClick={() => toggleStatusFilter(status)}
920
- />
921
- ))}
922
- </FilterGroup>
923
- <FilterGroup
924
- label="Priority"
925
- onClear={priorityFilter.length > 0 ? clearPriorityOnly : undefined}
926
- >
927
- {priorityOptions.map((priority) => (
928
- <Chip
929
- key={priority}
930
- label={priority}
931
- active={priorityFilter.includes(priority)}
932
- icon={
933
- <span
934
- className={cn(
935
- "h-2.5 w-2.5 rounded-full",
936
- priorityTheme[priority],
937
- )}
938
- />
939
- }
940
- onClick={() => togglePriorityFilter(priority)}
941
- />
942
- ))}
943
- </FilterGroup>
944
- <div className="ml-auto flex flex-wrap items-center gap-3">
945
- <div className="flex items-center gap-2 rounded-full border border-slate-200 bg-white px-3 py-1.5 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900">
946
- <label
947
- htmlFor="real-sort-select"
948
- className="text-xs tracking-wide text-slate-400 uppercase"
949
- >
950
- Sort
951
- </label>
952
- <select
953
- id="real-sort-select"
954
- value={sortKey}
955
- onChange={(event) =>
956
- setSortKey(event.target.value as TaskSortKey)
957
- }
958
- className="bg-transparent text-sm font-medium text-slate-700 outline-none dark:text-slate-200"
959
- >
960
- {sortOptions.map((option) => (
961
- <option key={option} value={option}>
962
- {option}
963
- </option>
964
- ))}
965
- </select>
966
- </div>
967
- {(statusFilter.length > 0 || priorityFilter.length > 0) && (
968
- <button
969
- type="button"
970
- onClick={clearAllFilters}
971
- className="rounded-full border border-slate-200 px-3 py-1.5 text-sm text-slate-500 hover:border-slate-300 hover:text-slate-700 dark:border-slate-700 dark:text-slate-400 dark:hover:border-slate-600 dark:hover:text-slate-200"
972
- >
973
- Clear filters
974
- </button>
975
- )}
976
- </div>
977
- </div>
978
-
979
- {/* Todo cards grid */}
980
- <div
981
- className={cn(
982
- "grid gap-4",
983
- density === "compact"
984
- ? "md:grid-cols-2 xl:grid-cols-3"
985
- : "md:grid-cols-2 xl:grid-cols-2",
986
- )}
987
- >
988
- {sortedTodos.length === 0 ? (
989
- <EmptyState
990
- title="No todos match these filters"
991
- description="Try expanding your filters or check the Processes catalog to kick off new work."
992
- />
993
- ) : (
994
- sortedTodos.map((todo) => (
995
- <TodoCard key={todo.id} todo={todo} density={density} />
996
- ))
997
- )}
998
- </div>
999
- </div>
1000
- </section>
1001
- )
1002
- }
1003
-
1004
- function RealTodosSection() {
1005
- const { collectionPromise } = useTodoCollection()
1006
-
1007
- return (
1008
- <Suspense fallback={<RealTodosLoadingState />}>
1009
- <RealTodosSectionInner collectionPromise={collectionPromise} />
1010
- </Suspense>
1011
- )
1012
- }
1013
-
1014
- function useAssignedAtToggle(assignedAt: string) {
1015
- const [showExact, setShowExact] = useState(false)
1016
- // Increment only to re-render when the relative assigned label crosses a boundary.
1017
- const [, refreshAssignedAtLabel] = useState(0)
1018
- const exactLabel = formatAssignedAtExact(assignedAt)
1019
- const label = showExact ? exactLabel : formatAssignedAtLabel(assignedAt)
1020
-
1021
- useEffect(() => {
1022
- let timeoutId: number | undefined
1023
- const scheduleRefresh = () => {
1024
- const delay = assignedAtRefreshDelay(assignedAt)
1025
- if (delay === null) return
1026
-
1027
- timeoutId = window.setTimeout(() => {
1028
- refreshAssignedAtLabel((tick) => tick + 1)
1029
- scheduleRefresh()
1030
- }, delay)
1031
- }
1032
-
1033
- scheduleRefresh()
1034
- return () => {
1035
- if (timeoutId !== undefined) window.clearTimeout(timeoutId)
1036
- }
1037
- }, [assignedAt])
1038
-
1039
- return {
1040
- exactLabel,
1041
- label,
1042
- showExact,
1043
- toggle: () => setShowExact((show) => !show),
1044
- }
1045
- }
1046
-
1047
- function MobileTodoRow({ todo }: { todo: MobileTodoListItem }) {
1048
- const assignedAt = useAssignedAtToggle(todo.assignedAt)
1049
-
1050
- return (
1051
- <article
1052
- className={cn(
1053
- "relative overflow-hidden rounded-2xl border bg-white p-4 shadow-sm dark:bg-slate-900/70",
1054
- statusTheme[todo.status]?.card ??
1055
- "border-slate-200 dark:border-slate-700",
1056
- )}
1057
- >
1058
- {todo.href && (
1059
- <Link
1060
- href={todo.href}
1061
- prefetch={false}
1062
- aria-hidden="true"
1063
- tabIndex={-1}
1064
- data-testid={`mobile-todo-row-link-${todo.id}`}
1065
- className="absolute inset-0 rounded-2xl"
1066
- />
1067
- )}
1068
- <div className="relative z-10 space-y-3">
1069
- <div className="space-y-1">
1070
- <p className="text-xs font-semibold tracking-wide text-slate-400 uppercase dark:text-slate-500">
1071
- {todo.processName}
1072
- </p>
1073
- <div className="flex flex-wrap items-center gap-2">
1074
- <button
1075
- type="button"
1076
- className="inline-flex items-center rounded-full border border-slate-200 px-2 py-0.5 text-xs font-semibold text-slate-500 transition hover:border-slate-300 hover:text-slate-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:border-slate-700 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-slate-100"
1077
- title={assignedAt.exactLabel}
1078
- aria-pressed={assignedAt.showExact}
1079
- onClick={assignedAt.toggle}
1080
- >
1081
- {assignedAt.label}
1082
- </button>
1083
- {todo.dueCue && (
1084
- <span
1085
- className={cn(
1086
- "inline-flex w-fit items-center rounded-full px-2 py-0.5 text-xs font-medium",
1087
- todo.status === "Overdue"
1088
- ? "bg-rose-100 text-rose-700 dark:bg-rose-500/20 dark:text-rose-300"
1089
- : "bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300",
1090
- )}
1091
- >
1092
- {todo.dueCue}
1093
- </span>
1094
- )}
1095
- </div>
1096
- <h3 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
1097
- {todo.title}
1098
- </h3>
1099
- {!todo.dueCue && (
1100
- <p className="text-sm text-slate-500 dark:text-slate-400">
1101
- {todo.cue}
1102
- </p>
1103
- )}
1104
- </div>
1105
- {todo.summary.length > 0 && (
1106
- <div className="flex flex-wrap gap-x-3 gap-y-1 border-t border-slate-100 pt-3 text-sm dark:border-slate-800">
1107
- {todo.summary.map((item) => (
1108
- <div
1109
- key={`${item.label}-${item.value}`}
1110
- className="flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5"
1111
- >
1112
- <span className="shrink-0 text-slate-400">{item.label}:</span>
1113
- <span
1114
- className="min-w-0 break-words text-slate-700 dark:text-slate-300"
1115
- // biome-ignore lint/security/noDangerouslySetInnerHtml: sanitized with DOMPurify
1116
- dangerouslySetInnerHTML={{
1117
- __html: DOMPurify.sanitize(item.value),
1118
- }}
1119
- />
1120
- </div>
1121
- ))}
1122
- </div>
1123
- )}
1124
- <div className="flex justify-end">
1125
- {todo.href ? (
1126
- <Link
1127
- href={todo.href}
1128
- prefetch={false}
1129
- aria-label={`${todo.actionLabel} ${todo.title}`}
1130
- className="rounded-full bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-blue-500"
1131
- >
1132
- {todo.actionLabel}
1133
- </Link>
1134
- ) : (
1135
- <div className="flex flex-col items-end gap-1">
1136
- <button
1137
- type="button"
1138
- disabled
1139
- className="rounded-full bg-slate-200 px-4 py-2 text-sm font-semibold text-slate-500 dark:bg-slate-800 dark:text-slate-400"
1140
- >
1141
- {todo.actionLabel}
1142
- </button>
1143
- {todo.status === "Correction Required" && (
1144
- <p className="max-w-48 text-right text-xs text-amber-700 dark:text-amber-300">
1145
- {correctionHelp}
1146
- </p>
1147
- )}
1148
- </div>
1149
- )}
1150
- </div>
1151
- </div>
1152
- </article>
1153
- )
1154
- }
1155
-
1156
- function TodoCard({
1157
- todo,
1158
- density = "comfortable",
1159
- }: {
1160
- todo: TodoDocType
1161
- density?: "comfortable" | "compact"
1162
- }) {
1163
- const effectiveStatus = computeTodoStatus(todo.dueAt, todo.status)
1164
- const priority = todo.priority
1165
- const dueStatusText = formatDueStatus(todo.dueAt)
1166
- // Active is implicit, and Overdue is conveyed by the due badge.
1167
- const showStatusBadge =
1168
- effectiveStatus !== "Active" && effectiveStatus !== "Overdue"
1169
- const assignedAt = useAssignedAtToggle(todo.assignedAt)
1170
- const correctionHelpId = `${todo.id}-correction-pending-help`
1171
-
1172
- return (
1173
- <article
1174
- className={cn(
1175
- "flex flex-col gap-1 rounded-2xl border bg-white shadow-sm transition hover:-translate-y-0.5 hover:shadow-md dark:bg-slate-900/70",
1176
- statusTheme[effectiveStatus]?.card ??
1177
- "border-slate-200 dark:border-slate-700",
1178
- density === "compact" ? "p-3 sm:p-3" : "p-5 sm:p-5",
1179
- )}
1180
- >
1181
- <header className="flex items-start justify-between gap-3">
1182
- <div className="space-y-2">
1183
- <p className="text-xs font-semibold tracking-wide text-slate-400 uppercase dark:text-slate-500">
1184
- {todo.processName}
1185
- </p>
1186
- <div className="flex flex-wrap items-center gap-2">
1187
- <span className="inline-flex items-center gap-1 rounded-full border border-slate-200 px-2 py-0.5 text-xs font-semibold text-slate-500 dark:border-slate-700 dark:text-slate-300">
1188
- <span
1189
- className={cn(
1190
- "h-2 w-2 rounded-full",
1191
- priorityTheme[priority] ?? "bg-slate-400",
1192
- )}
1193
- />
1194
- {todo.priority}
1195
- </span>
1196
- <button
1197
- type="button"
1198
- className="inline-flex items-center rounded-full border border-slate-200 px-2 py-0.5 text-xs font-semibold text-slate-500 transition hover:border-slate-300 hover:text-slate-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:border-slate-700 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-slate-100"
1199
- title={assignedAt.exactLabel}
1200
- aria-pressed={assignedAt.showExact}
1201
- onClick={assignedAt.toggle}
1202
- >
1203
- {assignedAt.label}
1204
- </button>
1205
- {dueStatusText && (
1206
- <span
1207
- className={cn(
1208
- "inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",
1209
- effectiveStatus === "Overdue"
1210
- ? "bg-rose-100 text-rose-700 dark:bg-rose-500/20 dark:text-rose-300"
1211
- : "bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300",
1212
- )}
1213
- >
1214
- {dueStatusText}
1215
- </span>
1216
- )}
1217
- {showStatusBadge && (
1218
- <span
1219
- className={cn(
1220
- "inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",
1221
- statusTheme[effectiveStatus]?.badge ??
1222
- "bg-slate-100 text-slate-600",
1223
- )}
1224
- >
1225
- {effectiveStatus}
1226
- </span>
1227
- )}
1228
- </div>
1229
- <div className="space-y-1">
1230
- <h3 className="text-lg font-semibold text-slate-900 dark:text-slate-100">
1231
- {todo.stepName}
1232
- </h3>
1233
- <p className="text-sm text-slate-500 dark:text-slate-400">
1234
- {todo.description}
1235
- </p>
1236
- </div>
1237
- </div>
1238
- <span className="shrink-0 rounded-full bg-slate-100 px-3 py-1 text-xs font-semibold text-slate-600 dark:bg-slate-700/60 dark:text-slate-300">
1239
- {todo.role}
1240
- </span>
1241
- </header>
1242
-
1243
- {todo.summary && todo.summary.length > 0 && (
1244
- <div className="flex flex-wrap gap-x-4 gap-y-1 border-t border-slate-100 pt-2 text-sm dark:border-slate-800">
1245
- {todo.summary.map((item) => (
1246
- <div
1247
- key={`${item.label}-${item.value}`}
1248
- className="flex items-center gap-1.5"
1249
- >
1250
- <span className="text-slate-400">{item.label}:</span>
1251
- <span
1252
- className="text-slate-700 dark:text-slate-300"
1253
- // biome-ignore lint/security/noDangerouslySetInnerHtml: sanitized with DOMPurify
1254
- dangerouslySetInnerHTML={{
1255
- __html: DOMPurify.sanitize(item.value),
1256
- }}
1257
- />
1258
- </div>
1259
- ))}
1260
- </div>
1261
- )}
1262
-
1263
- <footer className="mt-auto flex flex-wrap items-center justify-between gap-2 pt-4">
1264
- <div className="flex items-center gap-2">
1265
- {effectiveStatus === "Completed" ? (
1266
- <Button className="min-w-20 rounded-full" disabled>
1267
- Done
1268
- </Button>
1269
- ) : effectiveStatus === "Correction Required" ? (
1270
- <Button
1271
- asChild
1272
- className="min-w-20 rounded-full"
1273
- aria-describedby={correctionHelpId}
1274
- >
1275
- <Link
1276
- href={`/to-dos/correct/${toUrlPath(todo.stepPath)}?todoId=${encodeURIComponent(todo.id)}`}
1277
- prefetch={false}
1278
- >
1279
- Correct email
1280
- </Link>
1281
- </Button>
1282
- ) : (
1283
- <Button asChild className="min-w-20 rounded-full">
1284
- <Link
1285
- href={`/to-dos/complete/${toUrlPath(todo.stepPath)}?todoId=${encodeURIComponent(todo.id)}`}
1286
- prefetch={false}
1287
- >
1288
- {effectiveStatus === "Draft"
1289
- ? "Continue"
1290
- : effectiveStatus === "Upcoming"
1291
- ? "Preview"
1292
- : "Do"}
1293
- </Link>
1294
- </Button>
1295
- )}
1296
- <Button variant="outline" className="rounded-full" disabled>
1297
- Delegate
1298
- </Button>
1299
- </div>
1300
- {effectiveStatus === "Correction Required" && (
1301
- <p
1302
- id={correctionHelpId}
1303
- className="basis-full text-xs text-amber-700 dark:text-amber-300"
1304
- >
1305
- {correctionHelp}
1306
- </p>
1307
- )}
1308
- <button
1309
- type="button"
1310
- className="text-xs font-semibold text-blue-500 hover:text-blue-600"
1311
- >
1312
- Open form preview
1313
- </button>
1314
- </footer>
1315
- </article>
1316
- )
1317
- }
6
+ export default ToDosPage