@raybase/create 0.0.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/assets/apple-touch-icons/0.png +0 -0
- package/assets/apple-touch-icons/1.png +0 -0
- package/assets/apple-touch-icons/2.png +0 -0
- package/assets/apple-touch-icons/3.png +0 -0
- package/assets/apple-touch-icons/4.png +0 -0
- package/assets/apple-touch-icons/5.png +0 -0
- package/assets/apple-touch-icons/6.png +0 -0
- package/assets/apple-touch-icons/7.png +0 -0
- package/assets/apple-touch-icons/8.png +0 -0
- package/assets/apple-touch-icons/9.png +0 -0
- package/assets/apple-touch-icons/A.png +0 -0
- package/assets/apple-touch-icons/B.png +0 -0
- package/assets/apple-touch-icons/C.png +0 -0
- package/assets/apple-touch-icons/D.png +0 -0
- package/assets/apple-touch-icons/E.png +0 -0
- package/assets/apple-touch-icons/F.png +0 -0
- package/assets/apple-touch-icons/G.png +0 -0
- package/assets/apple-touch-icons/H.png +0 -0
- package/assets/apple-touch-icons/I.png +0 -0
- package/assets/apple-touch-icons/J.png +0 -0
- package/assets/apple-touch-icons/K.png +0 -0
- package/assets/apple-touch-icons/L.png +0 -0
- package/assets/apple-touch-icons/M.png +0 -0
- package/assets/apple-touch-icons/N.png +0 -0
- package/assets/apple-touch-icons/O.png +0 -0
- package/assets/apple-touch-icons/P.png +0 -0
- package/assets/apple-touch-icons/Q.png +0 -0
- package/assets/apple-touch-icons/R.png +0 -0
- package/assets/apple-touch-icons/S.png +0 -0
- package/assets/apple-touch-icons/T.png +0 -0
- package/assets/apple-touch-icons/U.png +0 -0
- package/assets/apple-touch-icons/V.png +0 -0
- package/assets/apple-touch-icons/W.png +0 -0
- package/assets/apple-touch-icons/X.png +0 -0
- package/assets/apple-touch-icons/Y.png +0 -0
- package/assets/apple-touch-icons/Z.png +0 -0
- package/assets/apple-touch-icons/default.png +0 -0
- package/dist/.source-hash +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2353 -0
- package/dist/index.js.map +1 -0
- package/dist/raybase-package-ranges.d.ts +11 -0
- package/dist/raybase-package-ranges.d.ts.map +1 -0
- package/dist/raybase-package-ranges.js +11 -0
- package/dist/raybase-package-ranges.js.map +1 -0
- package/dist/source-fetch.d.ts +91 -0
- package/dist/source-fetch.d.ts.map +1 -0
- package/dist/source-fetch.js +325 -0
- package/dist/source-fetch.js.map +1 -0
- package/dist/source-hash.d.ts +2 -0
- package/dist/source-hash.d.ts.map +1 -0
- package/dist/source-hash.js +23 -0
- package/dist/source-hash.js.map +1 -0
- package/dist/starter-description.d.ts +44 -0
- package/dist/starter-description.d.ts.map +1 -0
- package/dist/starter-description.js +273 -0
- package/dist/starter-description.js.map +1 -0
- package/dist/starter-source.d.ts +43 -0
- package/dist/starter-source.d.ts.map +1 -0
- package/dist/starter-source.js +156 -0
- package/dist/starter-source.js.map +1 -0
- package/dist/store-app-apply.d.ts +27 -0
- package/dist/store-app-apply.d.ts.map +1 -0
- package/dist/store-app-apply.js +100 -0
- package/dist/store-app-apply.js.map +1 -0
- package/dist/store-app-manifest.d.ts +86 -0
- package/dist/store-app-manifest.d.ts.map +1 -0
- package/dist/store-app-manifest.js +110 -0
- package/dist/store-app-manifest.js.map +1 -0
- package/dist/store-app-registry.d.ts +30 -0
- package/dist/store-app-registry.d.ts.map +1 -0
- package/dist/store-app-registry.js +232 -0
- package/dist/store-app-registry.js.map +1 -0
- package/models/recommended.json +42 -0
- package/modules/api/templates/react-router/app/api/operations.ts +8 -0
- package/modules/api/templates/tanstack-start/src/api/operations.ts +15 -0
- package/modules/docs/templates/astro-emdash/content/docs/getting-started.mdx +13 -0
- package/modules/docs/templates/astro-emdash/content/docs/index.mdx +13 -0
- package/modules/docs/templates/astro-emdash/content/docs/mcp.mdx +11 -0
- package/modules/docs/templates/astro-emdash/content/docs/meta.json +4 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/getting-started.mdx +12 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/index.mdx +12 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/mcp.mdx +10 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/meta.json +4 -0
- package/modules/docs/templates/astro-emdash/site/source.config.ts +10 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-assets.ts +1 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-client.tsx +22 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-data.ts +24 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-handler.tsx +105 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-layout.tsx +56 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-mdx.tsx +79 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-page-actions.tsx +146 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-page.tsx +70 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/llm-text.ts +61 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/source.ts +7 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/docs/[...slug].ts +6 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/docs/api/markdown.ts +4 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/docs/api/search.ts +4 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/llms.txt.ts +8 -0
- package/modules/docs/templates/astro-emdash/site/src/styles-docs.css +3 -0
- package/modules/docs/templates/astro-emdash/source.config.ts +10 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-assets.ts +1 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-client.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-data.ts +24 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-handler.tsx +105 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-layout.tsx +56 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-mdx.tsx +79 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-page-actions.tsx +146 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-page.tsx +70 -0
- package/modules/docs/templates/astro-emdash/src/docs/llm-text.ts +61 -0
- package/modules/docs/templates/astro-emdash/src/docs/source.ts +7 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs/$.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs/api/markdown.ts +12 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs/api/search.ts +12 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs.index.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/styles-docs.css +3 -0
- package/modules/docs/templates/react-router/app/components/mdx.tsx +79 -0
- package/modules/docs/templates/react-router/app/lib/layout.shared.tsx +54 -0
- package/modules/docs/templates/react-router/app/lib/source.ts +7 -0
- package/modules/docs/templates/react-router/app/routes/docs.$.tsx +49 -0
- package/modules/docs/templates/react-router/app/routes/docs.api.search.ts +10 -0
- package/modules/docs/templates/react-router/app/routes/docs.tsx +13 -0
- package/modules/docs/templates/react-router/content/docs/getting-started.mdx +8 -0
- package/modules/docs/templates/react-router/content/docs/index.mdx +8 -0
- package/modules/docs/templates/react-router/content/docs/mcp.mdx +121 -0
- package/modules/docs/templates/react-router/content/docs/meta.json +4 -0
- package/modules/docs/templates/react-router/source.config.ts +5 -0
- package/modules/docs/templates/tanstack-start/content/docs/getting-started.mdx +10 -0
- package/modules/docs/templates/tanstack-start/content/docs/index.mdx +8 -0
- package/modules/docs/templates/tanstack-start/content/docs/mcp.mdx +121 -0
- package/modules/docs/templates/tanstack-start/content/docs/meta.json +4 -0
- package/modules/docs/templates/tanstack-start/source.config.ts +10 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-assets.ts +1 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-client.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-data.ts +24 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-handler.tsx +105 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-layout.tsx +56 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-mdx.tsx +79 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-page-actions.tsx +146 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-page.tsx +70 -0
- package/modules/docs/templates/tanstack-start/src/docs/llm-text.ts +61 -0
- package/modules/docs/templates/tanstack-start/src/docs/source.ts +7 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs/$.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs/api/markdown.ts +12 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs/api/search.ts +12 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs.index.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/styles-docs.css +3 -0
- package/modules/guide/templates/astro-emdash/content/guide/capability-map.md +17 -0
- package/modules/guide/templates/astro-emdash/src/components/guide-widget.tsx +41 -0
- package/modules/guide/templates/astro-emdash/src/guide/actions.ts +8 -0
- package/modules/guide/templates/astro-emdash/src/guide/config.ts +21 -0
- package/modules/guide/templates/astro-emdash/src/guide/corpus.gen.ts +4 -0
- package/modules/guide/templates/astro-emdash/src/guide/corpus.manifest.json +72 -0
- package/modules/guide/templates/astro-emdash/src/guide/corpus.ts +4 -0
- package/modules/guide/templates/astro-emdash/src/guide/resources.json +4 -0
- package/modules/guide/templates/react-router/app/components/guide-widget.tsx +29 -0
- package/modules/guide/templates/react-router/app/guide/actions.ts +3 -0
- package/modules/guide/templates/react-router/app/guide/config.ts +21 -0
- package/modules/guide/templates/react-router/app/guide/corpus.gen.ts +4 -0
- package/modules/guide/templates/react-router/app/guide/corpus.manifest.json +22 -0
- package/modules/guide/templates/react-router/app/guide/corpus.ts +4 -0
- package/modules/guide/templates/react-router/app/guide/resources.json +4 -0
- package/modules/guide/templates/react-router/content/guide/capability-map.md +13 -0
- package/modules/guide/templates/tanstack-start/content/guide/capability-map.md +17 -0
- package/modules/guide/templates/tanstack-start/src/components/guide-widget.tsx +41 -0
- package/modules/guide/templates/tanstack-start/src/guide/actions.ts +17 -0
- package/modules/guide/templates/tanstack-start/src/guide/config.ts +21 -0
- package/modules/guide/templates/tanstack-start/src/guide/corpus.gen.ts +4 -0
- package/modules/guide/templates/tanstack-start/src/guide/corpus.manifest.json +22 -0
- package/modules/guide/templates/tanstack-start/src/guide/corpus.ts +4 -0
- package/modules/guide/templates/tanstack-start/src/guide/resources.json +4 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/SKILL.md +57 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/references/compatibility-and-testing.md +129 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/references/module-contract.md +133 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/references/structured-outputs.md +159 -0
- package/modules/openai-subscription/templates/astro-emdash/src/openai-subscription.ts +11 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/SKILL.md +57 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/references/compatibility-and-testing.md +129 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/references/module-contract.md +133 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/references/structured-outputs.md +159 -0
- package/modules/openai-subscription/templates/react-router/app/openai-subscription.ts +11 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/SKILL.md +57 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/references/compatibility-and-testing.md +129 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/references/module-contract.md +133 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/references/structured-outputs.md +159 -0
- package/modules/openai-subscription/templates/tanstack-start/src/openai-subscription.ts +11 -0
- package/package.json +34 -8
- package/skills/README.md +122 -0
- package/skills/raybase-actions/SKILL.md +223 -0
- package/skills/raybase-actions/references/action-patterns.md +190 -0
- package/skills/raybase-actions/references/adapting-actions.md +93 -0
- package/skills/raybase-actions/references/testing-actions.md +48 -0
- package/skills/raybase-agent-debugging/SKILL.md +230 -0
- package/skills/raybase-ai/SKILL.md +1310 -0
- package/skills/raybase-api/SKILL.md +45 -0
- package/skills/raybase-astro-emdash/SKILL.md +143 -0
- package/skills/raybase-astro-emdash-content-model/SKILL.md +217 -0
- package/skills/raybase-astro-emdash-content-model/references/LICENSE-emdash +9 -0
- package/skills/raybase-astro-emdash-content-model/references/emdash-collections.md +265 -0
- package/skills/raybase-astro-emdash-design/LICENSE-impeccable +60 -0
- package/skills/raybase-astro-emdash-design/SKILL.md +170 -0
- package/skills/raybase-astro-emdash-design/reference/color.md +91 -0
- package/skills/raybase-astro-emdash-design/reference/copy.md +73 -0
- package/skills/raybase-astro-emdash-design/reference/direction.md +115 -0
- package/skills/raybase-astro-emdash-design/reference/imagery.md +84 -0
- package/skills/raybase-astro-emdash-design/reference/layout.md +69 -0
- package/skills/raybase-astro-emdash-design/reference/motion.md +75 -0
- package/skills/raybase-astro-emdash-design/reference/polish.md +75 -0
- package/skills/raybase-astro-emdash-design/reference/typography.md +72 -0
- package/skills/raybase-astro-emdash-galley/SKILL.md +265 -0
- package/skills/raybase-astro-emdash-migration/SKILL.md +218 -0
- package/skills/raybase-astro-emdash-migration/references/inventory-and-conversion.md +242 -0
- package/skills/raybase-astro-emdash-security-review/SKILL.md +68 -0
- package/skills/raybase-astro-emdash-theme-selection/SKILL.md +216 -0
- package/skills/raybase-auth/SKILL.md +358 -0
- package/skills/raybase-background-jobs/SKILL.md +774 -0
- package/skills/raybase-building/SKILL.md +409 -0
- package/skills/raybase-building/references/interview-and-spec.md +87 -0
- package/skills/raybase-building/references/planning-docs.md +26 -0
- package/skills/raybase-building/references/schema-and-config.md +70 -0
- package/skills/raybase-changing-a-live-app/SKILL.md +119 -0
- package/skills/raybase-data-and-policies/SKILL.md +377 -0
- package/skills/raybase-deploy/SKILL.md +136 -0
- package/skills/raybase-docs-writing/SKILL.md +119 -0
- package/skills/raybase-guide/SKILL.md +235 -0
- package/skills/raybase-mcp/SKILL.md +309 -0
- package/skills/raybase-mcp/agents/openai.yaml +4 -0
- package/skills/raybase-notifications/SKILL.md +138 -0
- package/skills/raybase-pro-migration/SKILL.md +28 -0
- package/skills/raybase-react-router/SKILL.md +241 -0
- package/skills/raybase-react-router-design/LICENSE-impeccable +60 -0
- package/skills/raybase-react-router-design/SKILL.md +135 -0
- package/skills/raybase-react-router-design/reference/color.md +87 -0
- package/skills/raybase-react-router-design/reference/copy.md +83 -0
- package/skills/raybase-react-router-design/reference/delight.md +48 -0
- package/skills/raybase-react-router-design/reference/interaction.md +91 -0
- package/skills/raybase-react-router-design/reference/layout.md +82 -0
- package/skills/raybase-react-router-design/reference/motion.md +86 -0
- package/skills/raybase-react-router-design/reference/polish.md +79 -0
- package/skills/raybase-react-router-design/reference/typography.md +71 -0
- package/skills/raybase-react-router-security-review/LICENSE +22 -0
- package/skills/raybase-react-router-security-review/SKILL.md +190 -0
- package/skills/raybase-react-router-security-review/agents/openai.yaml +4 -0
- package/skills/raybase-react-router-security-review/references/api-security.md +519 -0
- package/skills/raybase-react-router-security-review/references/authentication.md +353 -0
- package/skills/raybase-react-router-security-review/references/authorization.md +372 -0
- package/skills/raybase-react-router-security-review/references/business-logic.md +443 -0
- package/skills/raybase-react-router-security-review/references/cryptography.md +329 -0
- package/skills/raybase-react-router-security-review/references/csrf.md +398 -0
- package/skills/raybase-react-router-security-review/references/data-protection.md +378 -0
- package/skills/raybase-react-router-security-review/references/deserialization.md +410 -0
- package/skills/raybase-react-router-security-review/references/error-handling.md +436 -0
- package/skills/raybase-react-router-security-review/references/file-security.md +457 -0
- package/skills/raybase-react-router-security-review/references/injection.md +259 -0
- package/skills/raybase-react-router-security-review/references/logging.md +433 -0
- package/skills/raybase-react-router-security-review/references/misconfiguration.md +435 -0
- package/skills/raybase-react-router-security-review/references/modern-threats.md +475 -0
- package/skills/raybase-react-router-security-review/references/raybase-react-router-security.md +235 -0
- package/skills/raybase-react-router-security-review/references/ssrf.md +413 -0
- package/skills/raybase-react-router-security-review/references/supply-chain.md +405 -0
- package/skills/raybase-react-router-security-review/references/xss.md +336 -0
- package/skills/raybase-realtime/SKILL.md +158 -0
- package/skills/raybase-realtime/agents/openai.yaml +4 -0
- package/skills/raybase-schema/SKILL.md +209 -0
- package/skills/raybase-search/SKILL.md +137 -0
- package/skills/raybase-search/agents/openai.yaml +4 -0
- package/skills/raybase-settings/SKILL.md +139 -0
- package/skills/raybase-settings/agents/openai.yaml +4 -0
- package/skills/raybase-tanstack-start/SKILL.md +166 -0
- package/skills/raybase-tanstack-start-design/LICENSE-impeccable +60 -0
- package/skills/raybase-tanstack-start-design/SKILL.md +140 -0
- package/skills/raybase-tanstack-start-design/reference/color.md +80 -0
- package/skills/raybase-tanstack-start-design/reference/copy.md +83 -0
- package/skills/raybase-tanstack-start-design/reference/delight.md +48 -0
- package/skills/raybase-tanstack-start-design/reference/interaction.md +91 -0
- package/skills/raybase-tanstack-start-design/reference/layout.md +82 -0
- package/skills/raybase-tanstack-start-design/reference/motion.md +86 -0
- package/skills/raybase-tanstack-start-design/reference/polish.md +79 -0
- package/skills/raybase-tanstack-start-design/reference/typography.md +71 -0
- package/skills/raybase-tanstack-start-security-review/LICENSE +22 -0
- package/skills/raybase-tanstack-start-security-review/SKILL.md +194 -0
- package/skills/raybase-tanstack-start-security-review/agents/openai.yaml +4 -0
- package/skills/raybase-tanstack-start-security-review/references/api-security.md +519 -0
- package/skills/raybase-tanstack-start-security-review/references/authentication.md +353 -0
- package/skills/raybase-tanstack-start-security-review/references/authorization.md +372 -0
- package/skills/raybase-tanstack-start-security-review/references/business-logic.md +443 -0
- package/skills/raybase-tanstack-start-security-review/references/cryptography.md +329 -0
- package/skills/raybase-tanstack-start-security-review/references/csrf.md +398 -0
- package/skills/raybase-tanstack-start-security-review/references/data-protection.md +378 -0
- package/skills/raybase-tanstack-start-security-review/references/deserialization.md +410 -0
- package/skills/raybase-tanstack-start-security-review/references/error-handling.md +436 -0
- package/skills/raybase-tanstack-start-security-review/references/file-security.md +457 -0
- package/skills/raybase-tanstack-start-security-review/references/injection.md +259 -0
- package/skills/raybase-tanstack-start-security-review/references/logging.md +433 -0
- package/skills/raybase-tanstack-start-security-review/references/misconfiguration.md +435 -0
- package/skills/raybase-tanstack-start-security-review/references/modern-threats.md +475 -0
- package/skills/raybase-tanstack-start-security-review/references/raybase-tanstack-security.md +208 -0
- package/skills/raybase-tanstack-start-security-review/references/ssrf.md +413 -0
- package/skills/raybase-tanstack-start-security-review/references/supply-chain.md +405 -0
- package/skills/raybase-tanstack-start-security-review/references/xss.md +336 -0
- package/skills-manifest.json +41 -0
- package/templates/astro-emdash/.dev.vars.example +7 -0
- package/templates/astro-emdash/AGENTS.md +122 -0
- package/templates/astro-emdash/DESIGN.md +90 -0
- package/templates/astro-emdash/components.json +21 -0
- package/templates/astro-emdash/content/docs/getting-started.mdx +20 -0
- package/templates/astro-emdash/content/docs/index.mdx +13 -0
- package/templates/astro-emdash/content/docs/mcp.mdx +11 -0
- package/templates/astro-emdash/content/docs/meta.json +4 -0
- package/templates/astro-emdash/content/docs/site-templates.mdx +62 -0
- package/templates/astro-emdash/dev/CODEBASE-MAP.md +46 -0
- package/templates/astro-emdash/dev/SPEC-OVERVIEW.md +15 -0
- package/templates/astro-emdash/dev/SPEC.md +84 -0
- package/templates/astro-emdash/dev/features/archive/.gitkeep +1 -0
- package/templates/astro-emdash/docs/theme-previews/base.svg +24 -0
- package/templates/astro-emdash/docs/theme-previews/steel.svg +24 -0
- package/templates/astro-emdash/docs/theme-previews/zen.svg +24 -0
- package/templates/astro-emdash/docs/themes.md +106 -0
- package/templates/astro-emdash/drizzle.config.ts +5 -0
- package/templates/astro-emdash/gitignore +11 -0
- package/templates/astro-emdash/migrations/app/meta/_journal.json +5 -0
- package/templates/astro-emdash/package.json +79 -0
- package/templates/astro-emdash/pnpm-workspace.yaml +71 -0
- package/templates/astro-emdash/public/_headers +4 -0
- package/templates/astro-emdash/site/astro.config.mjs +120 -0
- package/templates/astro-emdash/site/demo/README.md +72 -0
- package/templates/astro-emdash/site/demo/content/collection.json +43 -0
- package/templates/astro-emdash/site/demo/content/entries.json +120 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-card/manifest.json +51 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-card/sample-content.json +5 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-card/template.liquid +48 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/host.json +9 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/manifest.json +38 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/sample-content.json +34 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/template.liquid +84 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/manifest.json +64 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/page.json +7 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/sample-content.json +24 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/template.liquid +100 -0
- package/templates/astro-emdash/site/demo/templates/demo-menu-nav/manifest.json +51 -0
- package/templates/astro-emdash/site/demo/templates/demo-menu-nav/sample-content.json +5 -0
- package/templates/astro-emdash/site/demo/templates/demo-menu-nav/template.liquid +70 -0
- package/templates/astro-emdash/site/gitignore +1 -0
- package/templates/astro-emdash/site/package.json +56 -0
- package/templates/astro-emdash/site/scripts/apply-site-templates.mjs +560 -0
- package/templates/astro-emdash/site/scripts/galley-demo.mjs +298 -0
- package/templates/astro-emdash/site/scripts/seed-galley-starter.mjs +360 -0
- package/templates/astro-emdash/site/scripts/site-origin.mjs +45 -0
- package/templates/astro-emdash/site/seed/seed.json +154 -0
- package/templates/astro-emdash/site/seed/templates/.gitkeep +1 -0
- package/templates/astro-emdash/site/src/components/RaybaseSignedInMenu.astro +163 -0
- package/templates/astro-emdash/site/src/components/blocks/RaybaseActionIsland.astro +41 -0
- package/templates/astro-emdash/site/src/content-door/raybase-routes.ts +738 -0
- package/templates/astro-emdash/site/src/content-door/resolve-page.ts +142 -0
- package/templates/astro-emdash/site/src/content-door/seed.ts +85 -0
- package/templates/astro-emdash/site/src/env.d.ts +12 -0
- package/templates/astro-emdash/site/src/layouts/SiteLayout.astro +68 -0
- package/templates/astro-emdash/site/src/lib/palettes.gen.ts +7 -0
- package/templates/astro-emdash/site/src/lib/site-motion.ts +169 -0
- package/templates/astro-emdash/site/src/lib/site-shell.ts +294 -0
- package/templates/astro-emdash/site/src/live.config.ts +8 -0
- package/templates/astro-emdash/site/src/middleware.ts +20 -0
- package/templates/astro-emdash/site/src/pages/[...slug].astro +113 -0
- package/templates/astro-emdash/site/src/pages/_raybase/handoff/consume.ts +6 -0
- package/templates/astro-emdash/site/src/pages/_raybase/islands/action.ts +8 -0
- package/templates/astro-emdash/site/src/pages/_raybase/sign-out/index.ts +6 -0
- package/templates/astro-emdash/site/src/styles/palette-fonts.gen.css +1 -0
- package/templates/astro-emdash/site/src/styles/palettes.gen.css +3 -0
- package/templates/astro-emdash/site/src/styles.css +607 -0
- package/templates/astro-emdash/site/tsconfig.json +12 -0
- package/templates/astro-emdash/site/wrangler.jsonc +34 -0
- package/templates/astro-emdash/source.config.ts +10 -0
- package/templates/astro-emdash/src/actions.ts +58 -0
- package/templates/astro-emdash/src/ai/agents.ts +20 -0
- package/templates/astro-emdash/src/ai/retrieval.ts +36 -0
- package/templates/astro-emdash/src/auth-door.ts +18 -0
- package/templates/astro-emdash/src/client.tsx +25 -0
- package/templates/astro-emdash/src/components/.gitkeep +1 -0
- package/templates/astro-emdash/src/components/account-menu.tsx +91 -0
- package/templates/astro-emdash/src/components/auth-shell.tsx +69 -0
- package/templates/astro-emdash/src/components/mode-toggle.tsx +32 -0
- package/templates/astro-emdash/src/components/search-command-palette.tsx +107 -0
- package/templates/astro-emdash/src/components/setup-token-page.tsx +196 -0
- package/templates/astro-emdash/src/components/ui/avatar.tsx +107 -0
- package/templates/astro-emdash/src/components/ui/badge.tsx +52 -0
- package/templates/astro-emdash/src/components/ui/button.tsx +69 -0
- package/templates/astro-emdash/src/components/ui/checkbox.tsx +29 -0
- package/templates/astro-emdash/src/components/ui/dialog.tsx +158 -0
- package/templates/astro-emdash/src/components/ui/dropdown-menu.tsx +303 -0
- package/templates/astro-emdash/src/components/ui/input.tsx +20 -0
- package/templates/astro-emdash/src/components/ui/label.tsx +20 -0
- package/templates/astro-emdash/src/components/ui/scroll-area.tsx +53 -0
- package/templates/astro-emdash/src/components/ui/select.tsx +215 -0
- package/templates/astro-emdash/src/components/ui/separator.tsx +23 -0
- package/templates/astro-emdash/src/components/ui/sheet.tsx +138 -0
- package/templates/astro-emdash/src/components/ui/sidebar.tsx +728 -0
- package/templates/astro-emdash/src/components/ui/skeleton.tsx +13 -0
- package/templates/astro-emdash/src/components/ui/textarea.tsx +18 -0
- package/templates/astro-emdash/src/components/ui/tooltip.tsx +66 -0
- package/templates/astro-emdash/src/db/migrations.gen.ts +6 -0
- package/templates/astro-emdash/src/db/schema.ts +6 -0
- package/templates/astro-emdash/src/db/seed.ts +16 -0
- package/templates/astro-emdash/src/db/storage.ts +32 -0
- package/templates/astro-emdash/src/docs/docs-assets.ts +1 -0
- package/templates/astro-emdash/src/docs/docs-client.tsx +22 -0
- package/templates/astro-emdash/src/docs/docs-data.ts +24 -0
- package/templates/astro-emdash/src/docs/docs-handler.tsx +105 -0
- package/templates/astro-emdash/src/docs/docs-layout.tsx +56 -0
- package/templates/astro-emdash/src/docs/docs-mdx.tsx +79 -0
- package/templates/astro-emdash/src/docs/docs-page-actions.tsx +146 -0
- package/templates/astro-emdash/src/docs/docs-page.tsx +70 -0
- package/templates/astro-emdash/src/docs/llm-text.ts +61 -0
- package/templates/astro-emdash/src/docs/source.ts +7 -0
- package/templates/astro-emdash/src/guide/corpus.gen.ts +4 -0
- package/templates/astro-emdash/src/guide/corpus.manifest.json +72 -0
- package/templates/astro-emdash/src/hooks/use-mobile.ts +19 -0
- package/templates/astro-emdash/src/jobs.example.ts +48 -0
- package/templates/astro-emdash/src/lib/account.ts +12 -0
- package/templates/astro-emdash/src/lib/auth-client.ts +181 -0
- package/templates/astro-emdash/src/lib/utils.ts +6 -0
- package/templates/astro-emdash/src/mcp-app.ts +57 -0
- package/templates/astro-emdash/src/notifications.example.ts +37 -0
- package/templates/astro-emdash/src/raybase.auth.ts +70 -0
- package/templates/astro-emdash/src/raybase.config.ts +49 -0
- package/templates/astro-emdash/src/raybase.server.ts +56 -0
- package/templates/astro-emdash/src/realtime.example.ts +18 -0
- package/templates/astro-emdash/src/router.tsx +19 -0
- package/templates/astro-emdash/src/routes/__root.tsx +56 -0
- package/templates/astro-emdash/src/routes/_app/admin.tsx +13 -0
- package/templates/astro-emdash/src/routes/_app/forgot-password.tsx +97 -0
- package/templates/astro-emdash/src/routes/_app/index.tsx +169 -0
- package/templates/astro-emdash/src/routes/_app/invite.$token.tsx +11 -0
- package/templates/astro-emdash/src/routes/_app/login.tsx +193 -0
- package/templates/astro-emdash/src/routes/_app/profile.tsx +98 -0
- package/templates/astro-emdash/src/routes/_app/reset-password.$token.tsx +15 -0
- package/templates/astro-emdash/src/routes/_app/reset-password.tsx +115 -0
- package/templates/astro-emdash/src/routes/_app/setup.$token.tsx +11 -0
- package/templates/astro-emdash/src/routes/_app/signup.tsx +141 -0
- package/templates/astro-emdash/src/routes/_app/verify-email.$token.tsx +15 -0
- package/templates/astro-emdash/src/routes/_app/verify-email.tsx +154 -0
- package/templates/astro-emdash/src/routes/_app.tsx +33 -0
- package/templates/astro-emdash/src/routes/admin/$.ts +20 -0
- package/templates/astro-emdash/src/routes/api/$.ts +19 -0
- package/templates/astro-emdash/src/routes/docs/$.tsx +22 -0
- package/templates/astro-emdash/src/routes/docs/api/markdown.ts +12 -0
- package/templates/astro-emdash/src/routes/docs/api/search.ts +12 -0
- package/templates/astro-emdash/src/routes/docs.index.tsx +22 -0
- package/templates/astro-emdash/src/routes/docs.tsx +22 -0
- package/templates/astro-emdash/src/search.ts +6 -0
- package/templates/astro-emdash/src/settings.ts +12 -0
- package/templates/astro-emdash/src/styles-docs.css +3 -0
- package/templates/astro-emdash/src/styles.css +101 -0
- package/templates/astro-emdash/src/themes/base.css +76 -0
- package/templates/astro-emdash/src/themes/carbon.css +76 -0
- package/templates/astro-emdash/src/themes/fonts.css +25 -0
- package/templates/astro-emdash/src/themes/sage.css +76 -0
- package/templates/astro-emdash/src/themes/sand.css +76 -0
- package/templates/astro-emdash/src/themes/slate.css +81 -0
- package/templates/astro-emdash/src/themes/ultra.css +76 -0
- package/templates/astro-emdash/src/themes/zen.css +76 -0
- package/templates/astro-emdash/src/worker-entry.ts +31 -0
- package/templates/astro-emdash/tests/raybase-patterns.test.ts +29 -0
- package/templates/astro-emdash/tsconfig.json +36 -0
- package/templates/astro-emdash/vite.config.ts +130 -0
- package/templates/astro-emdash/vitest.config.ts +8 -0
- package/templates/astro-emdash/wrangler.jsonc +112 -0
- package/templates/react-router/.dev.vars.example +5 -0
- package/templates/react-router/.editorconfig +15 -0
- package/templates/react-router/AGENTS.md +54 -0
- package/templates/react-router/README.md +52 -0
- package/templates/react-router/app/app.css +44 -0
- package/templates/react-router/app/components/mdx.tsx +79 -0
- package/templates/react-router/app/components/ui/button.tsx +45 -0
- package/templates/react-router/app/components/ui/card.tsx +87 -0
- package/templates/react-router/app/components/ui/separator.tsx +22 -0
- package/templates/react-router/app/db/migrations.gen.ts +6 -0
- package/templates/react-router/app/db/schema.ts +56 -0
- package/templates/react-router/app/db/seed.ts +14 -0
- package/templates/react-router/app/entry.server.tsx +41 -0
- package/templates/react-router/app/globals.d.ts +1 -0
- package/templates/react-router/app/lib/layout.shared.tsx +52 -0
- package/templates/react-router/app/lib/source.ts +7 -0
- package/templates/react-router/app/lib/utils.ts +6 -0
- package/templates/react-router/app/raybase.server.ts +65 -0
- package/templates/react-router/app/root.tsx +23 -0
- package/templates/react-router/app/routes/_index.tsx +53 -0
- package/templates/react-router/app/routes/docs.$.tsx +49 -0
- package/templates/react-router/app/routes/docs.api.search.ts +10 -0
- package/templates/react-router/app/routes/docs.tsx +13 -0
- package/templates/react-router/app/routes.ts +3 -0
- package/templates/react-router/components.json +22 -0
- package/templates/react-router/content/docs/getting-started.mdx +15 -0
- package/templates/react-router/content/docs/index.mdx +8 -0
- package/templates/react-router/content/docs/mcp.mdx +121 -0
- package/templates/react-router/content/docs/meta.json +4 -0
- package/templates/react-router/dev/CODEBASE-MAP.md +48 -0
- package/templates/react-router/dev/SPEC-OVERVIEW.md +35 -0
- package/templates/react-router/dev/SPEC.md +93 -0
- package/templates/react-router/dev/features/archive/.gitkeep +1 -0
- package/templates/react-router/drizzle.config.ts +5 -0
- package/templates/react-router/env.d.ts +53 -0
- package/templates/react-router/gitignore +23 -0
- package/templates/react-router/migrations/app/meta/_journal.json +1 -0
- package/templates/react-router/package.json +70 -0
- package/templates/react-router/public/_headers +4 -0
- package/templates/react-router/public/favicon.ico +0 -0
- package/templates/react-router/react-router.config.ts +9 -0
- package/templates/react-router/source.config.ts +5 -0
- package/templates/react-router/tests/raybase-patterns.test.ts +23 -0
- package/templates/react-router/tsconfig.json +27 -0
- package/templates/react-router/vite.config.ts +59 -0
- package/templates/react-router/vitest.config.ts +8 -0
- package/templates/react-router/workers/app.ts +40 -0
- package/templates/react-router/wrangler.jsonc +111 -0
- package/templates/tanstack-start/.dev.vars.example +5 -0
- package/templates/tanstack-start/AGENTS.md +95 -0
- package/templates/tanstack-start/DESIGN.md +65 -0
- package/templates/tanstack-start/components.json +21 -0
- package/templates/tanstack-start/content/docs/getting-started.mdx +65 -0
- package/templates/tanstack-start/content/docs/index.mdx +10 -0
- package/templates/tanstack-start/content/docs/mcp.mdx +122 -0
- package/templates/tanstack-start/content/docs/meta.json +4 -0
- package/templates/tanstack-start/dev/CODEBASE-MAP.md +84 -0
- package/templates/tanstack-start/dev/SPEC-OVERVIEW.md +46 -0
- package/templates/tanstack-start/dev/SPEC.md +213 -0
- package/templates/tanstack-start/dev/features/archive/.gitkeep +1 -0
- package/templates/tanstack-start/docs/theme-previews/base.svg +24 -0
- package/templates/tanstack-start/docs/theme-previews/steel.svg +24 -0
- package/templates/tanstack-start/docs/theme-previews/zen.svg +24 -0
- package/templates/tanstack-start/docs/themes.md +116 -0
- package/templates/tanstack-start/drizzle.config.ts +5 -0
- package/templates/tanstack-start/gitignore +11 -0
- package/templates/tanstack-start/migrations/app/0000_low_karen_page.sql +26 -0
- package/templates/tanstack-start/migrations/app/meta/0000_snapshot.json +196 -0
- package/templates/tanstack-start/migrations/app/meta/_journal.json +13 -0
- package/templates/tanstack-start/package.json +77 -0
- package/templates/tanstack-start/public/_headers +8 -0
- package/templates/tanstack-start/public/icons/app-icon-maskable.svg +1 -0
- package/templates/tanstack-start/public/icons/app-icon.svg +1 -0
- package/templates/tanstack-start/public/icons/apple-touch-icon.png +0 -0
- package/templates/tanstack-start/public/manifest.webmanifest +14 -0
- package/templates/tanstack-start/public/raybase-push-sw.js +32 -0
- package/templates/tanstack-start/source.config.ts +10 -0
- package/templates/tanstack-start/src/actions.ts +560 -0
- package/templates/tanstack-start/src/ai/agents.ts +78 -0
- package/templates/tanstack-start/src/ai/retrieval.ts +36 -0
- package/templates/tanstack-start/src/auth-door.ts +18 -0
- package/templates/tanstack-start/src/client.tsx +25 -0
- package/templates/tanstack-start/src/components/.gitkeep +1 -0
- package/templates/tanstack-start/src/components/account-menu.tsx +127 -0
- package/templates/tanstack-start/src/components/auth-shell.tsx +69 -0
- package/templates/tanstack-start/src/components/install-app.tsx +35 -0
- package/templates/tanstack-start/src/components/mode-toggle.tsx +32 -0
- package/templates/tanstack-start/src/components/search-command-palette.tsx +107 -0
- package/templates/tanstack-start/src/components/setup-token-page.tsx +197 -0
- package/templates/tanstack-start/src/components/ui/avatar.tsx +107 -0
- package/templates/tanstack-start/src/components/ui/badge.tsx +52 -0
- package/templates/tanstack-start/src/components/ui/button.tsx +69 -0
- package/templates/tanstack-start/src/components/ui/checkbox.tsx +29 -0
- package/templates/tanstack-start/src/components/ui/dialog.tsx +158 -0
- package/templates/tanstack-start/src/components/ui/dropdown-menu.tsx +303 -0
- package/templates/tanstack-start/src/components/ui/input.tsx +20 -0
- package/templates/tanstack-start/src/components/ui/label.tsx +20 -0
- package/templates/tanstack-start/src/components/ui/scroll-area.tsx +53 -0
- package/templates/tanstack-start/src/components/ui/select.tsx +215 -0
- package/templates/tanstack-start/src/components/ui/separator.tsx +23 -0
- package/templates/tanstack-start/src/components/ui/sheet.tsx +138 -0
- package/templates/tanstack-start/src/components/ui/sidebar.tsx +728 -0
- package/templates/tanstack-start/src/components/ui/skeleton.tsx +13 -0
- package/templates/tanstack-start/src/components/ui/textarea.tsx +18 -0
- package/templates/tanstack-start/src/components/ui/tooltip.tsx +66 -0
- package/templates/tanstack-start/src/db/migrations.gen.ts +6 -0
- package/templates/tanstack-start/src/db/schema.ts +90 -0
- package/templates/tanstack-start/src/db/seed.ts +106 -0
- package/templates/tanstack-start/src/db/storage.ts +32 -0
- package/templates/tanstack-start/src/docs/docs-assets.ts +1 -0
- package/templates/tanstack-start/src/docs/docs-client.tsx +22 -0
- package/templates/tanstack-start/src/docs/docs-data.ts +24 -0
- package/templates/tanstack-start/src/docs/docs-handler.tsx +105 -0
- package/templates/tanstack-start/src/docs/docs-layout.tsx +56 -0
- package/templates/tanstack-start/src/docs/docs-mdx.tsx +79 -0
- package/templates/tanstack-start/src/docs/docs-page-actions.tsx +146 -0
- package/templates/tanstack-start/src/docs/docs-page.tsx +70 -0
- package/templates/tanstack-start/src/docs/llm-text.ts +61 -0
- package/templates/tanstack-start/src/docs/source.ts +7 -0
- package/templates/tanstack-start/src/hooks/use-mobile.ts +19 -0
- package/templates/tanstack-start/src/hooks/use-pwa-install.ts +77 -0
- package/templates/tanstack-start/src/jobs.example.ts +56 -0
- package/templates/tanstack-start/src/lib/account.ts +13 -0
- package/templates/tanstack-start/src/lib/auth-client.ts +187 -0
- package/templates/tanstack-start/src/lib/push-client.ts +98 -0
- package/templates/tanstack-start/src/lib/utils.ts +6 -0
- package/templates/tanstack-start/src/mcp-app.ts +74 -0
- package/templates/tanstack-start/src/notifications.example.ts +37 -0
- package/templates/tanstack-start/src/raybase.auth.ts +86 -0
- package/templates/tanstack-start/src/raybase.config.ts +86 -0
- package/templates/tanstack-start/src/raybase.server.ts +155 -0
- package/templates/tanstack-start/src/realtime.example.ts +46 -0
- package/templates/tanstack-start/src/router.tsx +19 -0
- package/templates/tanstack-start/src/routes/__root.tsx +73 -0
- package/templates/tanstack-start/src/routes/_app/admin.tsx +13 -0
- package/templates/tanstack-start/src/routes/_app/forgot-password.tsx +97 -0
- package/templates/tanstack-start/src/routes/_app/index.tsx +1316 -0
- package/templates/tanstack-start/src/routes/_app/invite.$token.tsx +11 -0
- package/templates/tanstack-start/src/routes/_app/login.tsx +193 -0
- package/templates/tanstack-start/src/routes/_app/profile.tsx +98 -0
- package/templates/tanstack-start/src/routes/_app/reset-password.$token.tsx +16 -0
- package/templates/tanstack-start/src/routes/_app/reset-password.tsx +115 -0
- package/templates/tanstack-start/src/routes/_app/setup.$token.tsx +11 -0
- package/templates/tanstack-start/src/routes/_app/signup.tsx +141 -0
- package/templates/tanstack-start/src/routes/_app/verify-email.$token.tsx +15 -0
- package/templates/tanstack-start/src/routes/_app/verify-email.tsx +154 -0
- package/templates/tanstack-start/src/routes/_app.tsx +33 -0
- package/templates/tanstack-start/src/routes/admin/$.ts +20 -0
- package/templates/tanstack-start/src/routes/api/$.ts +19 -0
- package/templates/tanstack-start/src/routes/docs/$.tsx +22 -0
- package/templates/tanstack-start/src/routes/docs/api/markdown.ts +12 -0
- package/templates/tanstack-start/src/routes/docs/api/search.ts +12 -0
- package/templates/tanstack-start/src/routes/docs.index.tsx +22 -0
- package/templates/tanstack-start/src/routes/docs.tsx +22 -0
- package/templates/tanstack-start/src/search.ts +26 -0
- package/templates/tanstack-start/src/settings.ts +12 -0
- package/templates/tanstack-start/src/styles-docs.css +3 -0
- package/templates/tanstack-start/src/styles.css +73 -0
- package/templates/tanstack-start/src/themes/base.css +76 -0
- package/templates/tanstack-start/src/themes/carbon.css +76 -0
- package/templates/tanstack-start/src/themes/fonts.css +18 -0
- package/templates/tanstack-start/src/themes/sage.css +76 -0
- package/templates/tanstack-start/src/themes/sand.css +76 -0
- package/templates/tanstack-start/src/themes/slate.css +76 -0
- package/templates/tanstack-start/src/themes/ultra.css +76 -0
- package/templates/tanstack-start/src/themes/zen.css +76 -0
- package/templates/tanstack-start/src/worker-entry.ts +30 -0
- package/templates/tanstack-start/tests/raybase-patterns.test.ts +247 -0
- package/templates/tanstack-start/tsconfig.json +33 -0
- package/templates/tanstack-start/vite.config.ts +132 -0
- package/templates/tanstack-start/vitest.config.ts +8 -0
- package/templates/tanstack-start/wrangler.jsonc +112 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1316 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import {
|
|
3
|
+
Archive,
|
|
4
|
+
BookText,
|
|
5
|
+
CalendarDays,
|
|
6
|
+
Check,
|
|
7
|
+
CheckCircle2,
|
|
8
|
+
ChevronDown,
|
|
9
|
+
Flag,
|
|
10
|
+
FolderPlus,
|
|
11
|
+
LayoutDashboard,
|
|
12
|
+
LogOut,
|
|
13
|
+
MoreHorizontal,
|
|
14
|
+
Plus,
|
|
15
|
+
Search,
|
|
16
|
+
Shield,
|
|
17
|
+
Trash2,
|
|
18
|
+
UserCircle
|
|
19
|
+
} from "lucide-react";
|
|
20
|
+
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
21
|
+
import { ModeToggle } from "../../components/mode-toggle";
|
|
22
|
+
import { SearchCommandPalette } from "../../components/search-command-palette";
|
|
23
|
+
import { Badge } from "../../components/ui/badge";
|
|
24
|
+
import { Button } from "../../components/ui/button";
|
|
25
|
+
import { Checkbox } from "../../components/ui/checkbox";
|
|
26
|
+
import {
|
|
27
|
+
Dialog,
|
|
28
|
+
DialogContent,
|
|
29
|
+
DialogDescription,
|
|
30
|
+
DialogFooter,
|
|
31
|
+
DialogHeader,
|
|
32
|
+
DialogTitle
|
|
33
|
+
} from "../../components/ui/dialog";
|
|
34
|
+
import {
|
|
35
|
+
DropdownMenu,
|
|
36
|
+
DropdownMenuContent,
|
|
37
|
+
DropdownMenuItem,
|
|
38
|
+
DropdownMenuSeparator,
|
|
39
|
+
DropdownMenuTrigger
|
|
40
|
+
} from "../../components/ui/dropdown-menu";
|
|
41
|
+
import { Input } from "../../components/ui/input";
|
|
42
|
+
import { Label } from "../../components/ui/label";
|
|
43
|
+
import {
|
|
44
|
+
Select,
|
|
45
|
+
SelectContent,
|
|
46
|
+
SelectItem,
|
|
47
|
+
SelectTrigger,
|
|
48
|
+
SelectValue
|
|
49
|
+
} from "../../components/ui/select";
|
|
50
|
+
import { Separator } from "../../components/ui/separator";
|
|
51
|
+
import {
|
|
52
|
+
Sidebar,
|
|
53
|
+
SidebarContent,
|
|
54
|
+
SidebarFooter,
|
|
55
|
+
SidebarGroup,
|
|
56
|
+
SidebarGroupAction,
|
|
57
|
+
SidebarGroupContent,
|
|
58
|
+
SidebarGroupLabel,
|
|
59
|
+
SidebarHeader,
|
|
60
|
+
SidebarInset,
|
|
61
|
+
SidebarMenu,
|
|
62
|
+
SidebarMenuBadge,
|
|
63
|
+
SidebarMenuButton,
|
|
64
|
+
SidebarMenuItem,
|
|
65
|
+
SidebarProvider,
|
|
66
|
+
SidebarTrigger
|
|
67
|
+
} from "../../components/ui/sidebar";
|
|
68
|
+
import { Textarea } from "../../components/ui/textarea";
|
|
69
|
+
import { loadAccountSummary, type AccountSummary } from "../../lib/account";
|
|
70
|
+
import { cn } from "../../lib/utils";
|
|
71
|
+
import { appConfig } from "../../raybase.config";
|
|
72
|
+
|
|
73
|
+
type ProjectStatus = "active" | "paused" | "done";
|
|
74
|
+
type TodoStatus = "todo" | "doing" | "done";
|
|
75
|
+
type Priority = "low" | "medium" | "high";
|
|
76
|
+
|
|
77
|
+
type User = {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
email: string;
|
|
81
|
+
roles: string[];
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type Project = {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
description: string | null;
|
|
89
|
+
status: ProjectStatus;
|
|
90
|
+
archivedAt: string | null;
|
|
91
|
+
createdBy: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type Todo = {
|
|
95
|
+
id: string;
|
|
96
|
+
projectId: string;
|
|
97
|
+
projectName: string | null;
|
|
98
|
+
title: string;
|
|
99
|
+
notes: string | null;
|
|
100
|
+
status: TodoStatus;
|
|
101
|
+
priority: Priority;
|
|
102
|
+
assigneeId: string | null;
|
|
103
|
+
assigneeName: string | null;
|
|
104
|
+
dueDate: string | null;
|
|
105
|
+
archivedAt: string | null;
|
|
106
|
+
createdBy: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
type WorkspaceSnapshot = {
|
|
110
|
+
currentUser: User & {
|
|
111
|
+
isManager: boolean;
|
|
112
|
+
visibilityLabel: string;
|
|
113
|
+
};
|
|
114
|
+
counts: {
|
|
115
|
+
projects: number;
|
|
116
|
+
todos: number;
|
|
117
|
+
activeProjects: number;
|
|
118
|
+
archivedProjects: number;
|
|
119
|
+
openTodos: number;
|
|
120
|
+
doneTodos: number;
|
|
121
|
+
archivedTodos: number;
|
|
122
|
+
highPriorityTodos: number;
|
|
123
|
+
};
|
|
124
|
+
projects: Project[];
|
|
125
|
+
todos: Todo[];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
type WorkspaceData = {
|
|
129
|
+
authRequired: boolean;
|
|
130
|
+
snapshot: WorkspaceSnapshot | null;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
type ProjectDraft = {
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
status: ProjectStatus;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
type TodoDraft = {
|
|
140
|
+
projectId: string;
|
|
141
|
+
title: string;
|
|
142
|
+
notes: string;
|
|
143
|
+
status: TodoStatus;
|
|
144
|
+
priority: Priority;
|
|
145
|
+
assigneeId: string;
|
|
146
|
+
dueDate: string;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
type TodoUpdateInput = {
|
|
150
|
+
title?: string;
|
|
151
|
+
notes?: string | null;
|
|
152
|
+
status?: TodoStatus;
|
|
153
|
+
priority?: Priority;
|
|
154
|
+
assigneeId?: string | null;
|
|
155
|
+
dueDate?: string | null;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
type View = { type: "overview" } | { type: "project"; id: string };
|
|
159
|
+
|
|
160
|
+
class AuthRequiredError extends Error {}
|
|
161
|
+
|
|
162
|
+
export const Route = createFileRoute("/_app/")({
|
|
163
|
+
ssr: false,
|
|
164
|
+
loader: () => loadWorkspace(false),
|
|
165
|
+
component: Dashboard
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
async function runAction<T>(name: string, input: Record<string, unknown> = {}): Promise<T> {
|
|
169
|
+
const response = await fetch(`/api/actions/${encodeURIComponent(name)}`, {
|
|
170
|
+
method: "POST",
|
|
171
|
+
headers: { "content-type": "application/json" },
|
|
172
|
+
body: JSON.stringify(input)
|
|
173
|
+
});
|
|
174
|
+
if (response.status === 401) throw new AuthRequiredError("Sign in required.");
|
|
175
|
+
const body = (await response.json().catch(() => ({}))) as Record<string, unknown>;
|
|
176
|
+
if (!response.ok) {
|
|
177
|
+
const message = typeof body.message === "string"
|
|
178
|
+
? body.message
|
|
179
|
+
: typeof body.error === "string"
|
|
180
|
+
? body.error
|
|
181
|
+
: "Action failed.";
|
|
182
|
+
throw new Error(message);
|
|
183
|
+
}
|
|
184
|
+
return body as T;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function loadWorkspace(showArchived: boolean): Promise<WorkspaceData> {
|
|
188
|
+
try {
|
|
189
|
+
const snapshot = await runAction<WorkspaceSnapshot>("workspace.snapshot", { showArchived });
|
|
190
|
+
return { authRequired: false, snapshot };
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error instanceof AuthRequiredError) return { authRequired: true, snapshot: null };
|
|
193
|
+
return { authRequired: true, snapshot: null };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function loadUsers(): Promise<User[]> {
|
|
198
|
+
const result = await runAction<{ users: User[] }>("users.list_assignable", { limit: 50 });
|
|
199
|
+
return result.users;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const UNASSIGNED = "__unassigned__";
|
|
203
|
+
const emptyProjectDraft: ProjectDraft = { name: "", description: "", status: "active" };
|
|
204
|
+
const emptyTodoDraft: TodoDraft = { projectId: "", title: "", notes: "", status: "todo", priority: "medium", assigneeId: "", dueDate: "" };
|
|
205
|
+
|
|
206
|
+
const projectStatusItems = [
|
|
207
|
+
{ label: "Active", value: "active" },
|
|
208
|
+
{ label: "Paused", value: "paused" },
|
|
209
|
+
{ label: "Done", value: "done" }
|
|
210
|
+
] satisfies ReadonlyArray<{ label: string; value: ProjectStatus }>;
|
|
211
|
+
const todoStatusItems = [
|
|
212
|
+
{ label: "To do", value: "todo" },
|
|
213
|
+
{ label: "In progress", value: "doing" },
|
|
214
|
+
{ label: "Done", value: "done" }
|
|
215
|
+
] satisfies ReadonlyArray<{ label: string; value: TodoStatus }>;
|
|
216
|
+
const priorityItems = [
|
|
217
|
+
{ label: "Low", value: "low" },
|
|
218
|
+
{ label: "Medium", value: "medium" },
|
|
219
|
+
{ label: "High", value: "high" }
|
|
220
|
+
] satisfies ReadonlyArray<{ label: string; value: Priority }>;
|
|
221
|
+
const projectStatusLabel = Object.fromEntries(projectStatusItems.map((item) => [item.value, item.label])) as Record<ProjectStatus, string>;
|
|
222
|
+
const todoStatusLabel = Object.fromEntries(todoStatusItems.map((item) => [item.value, item.label])) as Record<TodoStatus, string>;
|
|
223
|
+
const priorityLabel = Object.fromEntries(priorityItems.map((item) => [item.value, item.label])) as Record<Priority, string>;
|
|
224
|
+
|
|
225
|
+
function Dashboard() {
|
|
226
|
+
const loaderData = Route.useLoaderData();
|
|
227
|
+
const [snapshot, setSnapshot] = useState<WorkspaceSnapshot | null>(loaderData.snapshot);
|
|
228
|
+
const [users, setUsers] = useState<User[]>([]);
|
|
229
|
+
const [showArchived, setShowArchived] = useState(false);
|
|
230
|
+
const [searchOpen, setSearchOpen] = useState(false);
|
|
231
|
+
const [view, setView] = useState<View>({ type: "overview" });
|
|
232
|
+
const [newProjectOpen, setNewProjectOpen] = useState(false);
|
|
233
|
+
const [newTaskOpen, setNewTaskOpen] = useState(false);
|
|
234
|
+
const [projectDraft, setProjectDraft] = useState<ProjectDraft>(emptyProjectDraft);
|
|
235
|
+
const [todoDraft, setTodoDraft] = useState<TodoDraft>(emptyTodoDraft);
|
|
236
|
+
const [pendingAction, setPendingAction] = useState<string | null>(null);
|
|
237
|
+
const [message, setMessage] = useState<string | null>(null);
|
|
238
|
+
|
|
239
|
+
const refresh = async (archived = showArchived) => {
|
|
240
|
+
const [workspace, assignable] = await Promise.all([loadWorkspace(archived), loadUsers().catch(() => [])]);
|
|
241
|
+
if (!workspace.authRequired) setSnapshot(workspace.snapshot);
|
|
242
|
+
setUsers(assignable);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
setSnapshot(loaderData.snapshot);
|
|
247
|
+
}, [loaderData.snapshot]);
|
|
248
|
+
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
void refresh(showArchived);
|
|
251
|
+
}, [showArchived]);
|
|
252
|
+
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
const onDataChanged = () => {
|
|
255
|
+
void refresh(showArchived);
|
|
256
|
+
};
|
|
257
|
+
window.addEventListener("raybase:data-changed", onDataChanged);
|
|
258
|
+
return () => window.removeEventListener("raybase:data-changed", onDataChanged);
|
|
259
|
+
}, [showArchived]);
|
|
260
|
+
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
263
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
setSearchOpen(true);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
window.addEventListener("keydown", onKeyDown);
|
|
269
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
270
|
+
}, []);
|
|
271
|
+
|
|
272
|
+
const runMutation = async (key: string, name: string, input: Record<string, unknown>, onSuccess?: () => void) => {
|
|
273
|
+
setPendingAction(key);
|
|
274
|
+
setMessage(null);
|
|
275
|
+
try {
|
|
276
|
+
await runAction(name, input);
|
|
277
|
+
onSuccess?.();
|
|
278
|
+
window.dispatchEvent(new CustomEvent("raybase:data-changed"));
|
|
279
|
+
await refresh(showArchived);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
setMessage(error instanceof Error ? error.message : "Unable to update workspace.");
|
|
282
|
+
} finally {
|
|
283
|
+
setPendingAction(null);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const projects = snapshot?.projects ?? [];
|
|
288
|
+
const todos = snapshot?.todos ?? [];
|
|
289
|
+
const activeProjects = useMemo(() => projects.filter((project) => !project.archivedAt), [projects]);
|
|
290
|
+
const projectById = useMemo(() => new Map(projects.map((project) => [project.id, project])), [projects]);
|
|
291
|
+
const todosByProject = useMemo(() => {
|
|
292
|
+
const grouped = new Map<string, Todo[]>();
|
|
293
|
+
for (const todo of todos) grouped.set(todo.projectId, [...(grouped.get(todo.projectId) ?? []), todo]);
|
|
294
|
+
return grouped;
|
|
295
|
+
}, [todos]);
|
|
296
|
+
const openCountByProject = useMemo(() => {
|
|
297
|
+
const counts = new Map<string, number>();
|
|
298
|
+
for (const todo of todos) {
|
|
299
|
+
if (todo.archivedAt || todo.status === "done") continue;
|
|
300
|
+
counts.set(todo.projectId, (counts.get(todo.projectId) ?? 0) + 1);
|
|
301
|
+
}
|
|
302
|
+
return counts;
|
|
303
|
+
}, [todos]);
|
|
304
|
+
const dueTodos = useMemo(
|
|
305
|
+
() => [...todos]
|
|
306
|
+
.filter((todo) => !todo.archivedAt && todo.status !== "done" && todo.dueDate)
|
|
307
|
+
.sort((a, b) => String(a.dueDate).localeCompare(String(b.dueDate)))
|
|
308
|
+
.slice(0, 6),
|
|
309
|
+
[todos]
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
// Keep the selected project valid as the workspace changes.
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
if (view.type === "project" && !projectById.has(view.id)) {
|
|
315
|
+
setView({ type: "overview" });
|
|
316
|
+
}
|
|
317
|
+
}, [view, projectById]);
|
|
318
|
+
|
|
319
|
+
const selectedProject = view.type === "project" ? projectById.get(view.id) ?? null : null;
|
|
320
|
+
|
|
321
|
+
const openNewTask = (projectId?: string) => {
|
|
322
|
+
const fallback = projectId || activeProjects[0]?.id || projects[0]?.id || "";
|
|
323
|
+
setTodoDraft({ ...emptyTodoDraft, projectId: fallback });
|
|
324
|
+
setNewTaskOpen(true);
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
if (loaderData.authRequired && !snapshot) {
|
|
328
|
+
return (
|
|
329
|
+
<main className="grid min-h-screen place-items-center bg-background p-6 text-foreground">
|
|
330
|
+
<section className="w-full max-w-md rounded-xl border border-border bg-card p-8 text-card-foreground shadow-sm">
|
|
331
|
+
<h1 className="mb-3 text-3xl font-bold leading-tight tracking-tight">{appConfig.appName}</h1>
|
|
332
|
+
<p className="mb-6 text-muted-foreground">Sign in to view your workspace.</p>
|
|
333
|
+
<Button asChild size="lg">
|
|
334
|
+
<a href="/login">Sign in</a>
|
|
335
|
+
</Button>
|
|
336
|
+
</section>
|
|
337
|
+
</main>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return (
|
|
342
|
+
<SidebarProvider>
|
|
343
|
+
<Sidebar>
|
|
344
|
+
<SidebarHeader className="gap-2">
|
|
345
|
+
<div className="flex items-center gap-2 px-2 py-1.5">
|
|
346
|
+
<span className="grid size-7 shrink-0 place-items-center rounded-md bg-primary text-sm font-bold text-primary-foreground">
|
|
347
|
+
{appConfig.appName.trim().charAt(0).toUpperCase()}
|
|
348
|
+
</span>
|
|
349
|
+
<div className="grid min-w-0 leading-tight">
|
|
350
|
+
<span className="truncate text-sm font-semibold">{appConfig.appName}</span>
|
|
351
|
+
<span className="truncate text-xs text-muted-foreground">
|
|
352
|
+
{snapshot?.currentUser.visibilityLabel ?? "Workspace"}
|
|
353
|
+
</span>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
<Button size="sm" className="mx-1 justify-start" onClick={() => openNewTask()}>
|
|
357
|
+
<Plus aria-hidden="true" />
|
|
358
|
+
New task
|
|
359
|
+
</Button>
|
|
360
|
+
</SidebarHeader>
|
|
361
|
+
|
|
362
|
+
<SidebarContent>
|
|
363
|
+
<SidebarGroup>
|
|
364
|
+
<SidebarGroupContent>
|
|
365
|
+
<SidebarMenu>
|
|
366
|
+
<SidebarMenuItem>
|
|
367
|
+
<SidebarMenuButton
|
|
368
|
+
isActive={view.type === "overview"}
|
|
369
|
+
onClick={() => setView({ type: "overview" })}
|
|
370
|
+
>
|
|
371
|
+
<LayoutDashboard aria-hidden="true" />
|
|
372
|
+
<span>Overview</span>
|
|
373
|
+
</SidebarMenuButton>
|
|
374
|
+
</SidebarMenuItem>
|
|
375
|
+
</SidebarMenu>
|
|
376
|
+
</SidebarGroupContent>
|
|
377
|
+
</SidebarGroup>
|
|
378
|
+
|
|
379
|
+
<SidebarGroup>
|
|
380
|
+
<SidebarGroupLabel>Projects</SidebarGroupLabel>
|
|
381
|
+
<SidebarGroupAction title="New project" onClick={() => { setProjectDraft(emptyProjectDraft); setNewProjectOpen(true); }}>
|
|
382
|
+
<Plus aria-hidden="true" />
|
|
383
|
+
<span className="sr-only">New project</span>
|
|
384
|
+
</SidebarGroupAction>
|
|
385
|
+
<SidebarGroupContent>
|
|
386
|
+
<SidebarMenu>
|
|
387
|
+
{projects.map((project) => {
|
|
388
|
+
const open = openCountByProject.get(project.id) ?? 0;
|
|
389
|
+
return (
|
|
390
|
+
<SidebarMenuItem key={project.id}>
|
|
391
|
+
<SidebarMenuButton
|
|
392
|
+
isActive={view.type === "project" && view.id === project.id}
|
|
393
|
+
onClick={() => setView({ type: "project", id: project.id })}
|
|
394
|
+
className={project.archivedAt ? "opacity-60" : undefined}
|
|
395
|
+
>
|
|
396
|
+
<StatusDot status={project.status} archived={Boolean(project.archivedAt)} />
|
|
397
|
+
<span className="truncate">{project.name}</span>
|
|
398
|
+
</SidebarMenuButton>
|
|
399
|
+
{open > 0 ? <SidebarMenuBadge>{open}</SidebarMenuBadge> : null}
|
|
400
|
+
</SidebarMenuItem>
|
|
401
|
+
);
|
|
402
|
+
})}
|
|
403
|
+
{projects.length === 0 ? (
|
|
404
|
+
<p className="px-2 py-1.5 text-xs text-muted-foreground">No projects yet.</p>
|
|
405
|
+
) : null}
|
|
406
|
+
</SidebarMenu>
|
|
407
|
+
</SidebarGroupContent>
|
|
408
|
+
</SidebarGroup>
|
|
409
|
+
</SidebarContent>
|
|
410
|
+
|
|
411
|
+
<SidebarFooter>
|
|
412
|
+
<SidebarMenu>
|
|
413
|
+
<SidebarMenuItem>
|
|
414
|
+
<SidebarMenuButton asChild>
|
|
415
|
+
<a href="/docs" data-raybase-docs-nav>
|
|
416
|
+
<BookText aria-hidden="true" />
|
|
417
|
+
<span>Docs</span>
|
|
418
|
+
</a>
|
|
419
|
+
</SidebarMenuButton>
|
|
420
|
+
</SidebarMenuItem>
|
|
421
|
+
<AccountFooterItem />
|
|
422
|
+
</SidebarMenu>
|
|
423
|
+
</SidebarFooter>
|
|
424
|
+
</Sidebar>
|
|
425
|
+
|
|
426
|
+
<SidebarInset>
|
|
427
|
+
<header className="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b border-border bg-background/80 px-4 backdrop-blur">
|
|
428
|
+
<SidebarTrigger className="-ml-1" />
|
|
429
|
+
<Separator orientation="vertical" className="mr-1 !h-5" />
|
|
430
|
+
<h1 className="truncate text-sm font-semibold">
|
|
431
|
+
{view.type === "overview" ? "Overview" : selectedProject?.name ?? "Project"}
|
|
432
|
+
</h1>
|
|
433
|
+
<div className="ml-auto flex items-center gap-2">
|
|
434
|
+
<ModeToggle />
|
|
435
|
+
<Button
|
|
436
|
+
variant="outline"
|
|
437
|
+
size="sm"
|
|
438
|
+
className="text-muted-foreground"
|
|
439
|
+
onClick={() => setSearchOpen(true)}
|
|
440
|
+
>
|
|
441
|
+
<Search aria-hidden="true" />
|
|
442
|
+
<span className="hidden sm:inline">Search</span>
|
|
443
|
+
<kbd className="hidden rounded border border-border bg-muted px-1 font-mono text-[10px] sm:inline">⌘K</kbd>
|
|
444
|
+
</Button>
|
|
445
|
+
<Button
|
|
446
|
+
variant={showArchived ? "secondary" : "outline"}
|
|
447
|
+
size="sm"
|
|
448
|
+
onClick={() => setShowArchived((value) => !value)}
|
|
449
|
+
title={showArchived ? "Hiding nothing — archived items are visible" : "Show archived items"}
|
|
450
|
+
>
|
|
451
|
+
<Archive aria-hidden="true" />
|
|
452
|
+
<span className="hidden md:inline">{showArchived ? "Archived shown" : "Archived"}</span>
|
|
453
|
+
</Button>
|
|
454
|
+
</div>
|
|
455
|
+
</header>
|
|
456
|
+
|
|
457
|
+
<div className="mx-auto w-full max-w-5xl flex-1 px-4 py-6 md:px-8">
|
|
458
|
+
{message ? (
|
|
459
|
+
<p className="mb-4 rounded-md border border-destructive/20 bg-destructive/10 p-3 text-sm text-destructive">{message}</p>
|
|
460
|
+
) : null}
|
|
461
|
+
|
|
462
|
+
{view.type === "overview" ? (
|
|
463
|
+
<Overview
|
|
464
|
+
snapshot={snapshot}
|
|
465
|
+
users={users}
|
|
466
|
+
dueTodos={dueTodos}
|
|
467
|
+
projectById={projectById}
|
|
468
|
+
hasProjects={projects.length > 0}
|
|
469
|
+
onOpenProject={(id) => setView({ type: "project", id })}
|
|
470
|
+
onNewProject={() => { setProjectDraft(emptyProjectDraft); setNewProjectOpen(true); }}
|
|
471
|
+
/>
|
|
472
|
+
) : selectedProject ? (
|
|
473
|
+
<ProjectView
|
|
474
|
+
project={selectedProject}
|
|
475
|
+
todos={todosByProject.get(selectedProject.id) ?? []}
|
|
476
|
+
users={users}
|
|
477
|
+
pendingAction={pendingAction}
|
|
478
|
+
onAddTask={() => openNewTask(selectedProject.id)}
|
|
479
|
+
onUpdateProject={(input) => runMutation(`project:${selectedProject.id}:update`, "projects.update", { id: selectedProject.id, ...input })}
|
|
480
|
+
onArchiveProject={() => runMutation(`project:${selectedProject.id}:archive`, "projects.archive", { id: selectedProject.id })}
|
|
481
|
+
onDeleteProject={() => runMutation(`project:${selectedProject.id}:delete`, "projects.delete", { id: selectedProject.id }, () => setView({ type: "overview" }))}
|
|
482
|
+
onUpdateTodo={(todoId, input) => runMutation(`todo:${todoId}:update`, "todos.update", { id: todoId, ...input })}
|
|
483
|
+
onMarkDone={(todoId) => runMutation(`todo:${todoId}:done`, "todos.mark_done", { id: todoId })}
|
|
484
|
+
onReopen={(todoId) => runMutation(`todo:${todoId}:update`, "todos.update", { id: todoId, status: "todo" })}
|
|
485
|
+
onArchiveTodo={(todoId) => runMutation(`todo:${todoId}:archive`, "todos.archive", { id: todoId })}
|
|
486
|
+
onDeleteTodo={(todoId) => runMutation(`todo:${todoId}:delete`, "todos.delete", { id: todoId })}
|
|
487
|
+
/>
|
|
488
|
+
) : null}
|
|
489
|
+
</div>
|
|
490
|
+
</SidebarInset>
|
|
491
|
+
|
|
492
|
+
<ProjectDialog
|
|
493
|
+
open={newProjectOpen}
|
|
494
|
+
onOpenChange={setNewProjectOpen}
|
|
495
|
+
draft={projectDraft}
|
|
496
|
+
pending={pendingAction === "project:create"}
|
|
497
|
+
onChange={setProjectDraft}
|
|
498
|
+
onSubmit={() => runMutation("project:create", "projects.create", projectDraft, () => {
|
|
499
|
+
setProjectDraft(emptyProjectDraft);
|
|
500
|
+
setNewProjectOpen(false);
|
|
501
|
+
})}
|
|
502
|
+
/>
|
|
503
|
+
|
|
504
|
+
<TaskDialog
|
|
505
|
+
open={newTaskOpen}
|
|
506
|
+
onOpenChange={setNewTaskOpen}
|
|
507
|
+
draft={todoDraft}
|
|
508
|
+
projects={activeProjects.length ? activeProjects : projects}
|
|
509
|
+
users={users}
|
|
510
|
+
pending={pendingAction === "todo:create"}
|
|
511
|
+
onChange={setTodoDraft}
|
|
512
|
+
onSubmit={(draft) => runMutation("todo:create", "todos.create", {
|
|
513
|
+
...draft,
|
|
514
|
+
assigneeId: draft.assigneeId || null,
|
|
515
|
+
dueDate: draft.dueDate || null,
|
|
516
|
+
notes: draft.notes || undefined
|
|
517
|
+
}, () => {
|
|
518
|
+
setTodoDraft({ ...emptyTodoDraft, projectId: draft.projectId });
|
|
519
|
+
setNewTaskOpen(false);
|
|
520
|
+
setView({ type: "project", id: draft.projectId });
|
|
521
|
+
})}
|
|
522
|
+
/>
|
|
523
|
+
|
|
524
|
+
<SearchCommandPalette open={searchOpen} onOpenChange={setSearchOpen} />
|
|
525
|
+
</SidebarProvider>
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function Overview({
|
|
530
|
+
snapshot,
|
|
531
|
+
users,
|
|
532
|
+
dueTodos,
|
|
533
|
+
projectById,
|
|
534
|
+
hasProjects,
|
|
535
|
+
onOpenProject,
|
|
536
|
+
onNewProject
|
|
537
|
+
}: {
|
|
538
|
+
snapshot: WorkspaceSnapshot | null;
|
|
539
|
+
users: User[];
|
|
540
|
+
dueTodos: Todo[];
|
|
541
|
+
projectById: Map<string, Project>;
|
|
542
|
+
hasProjects: boolean;
|
|
543
|
+
onOpenProject: (id: string) => void;
|
|
544
|
+
onNewProject: () => void;
|
|
545
|
+
}) {
|
|
546
|
+
return (
|
|
547
|
+
<div className="grid gap-6">
|
|
548
|
+
<div>
|
|
549
|
+
<p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">Workspace</p>
|
|
550
|
+
<h2 className="mt-1 text-2xl font-bold tracking-tight text-balance">Team workload</h2>
|
|
551
|
+
</div>
|
|
552
|
+
|
|
553
|
+
<div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
|
|
554
|
+
<Metric label="Active projects" value={snapshot?.counts.activeProjects ?? 0} />
|
|
555
|
+
<Metric label="Open tasks" value={snapshot?.counts.openTodos ?? 0} />
|
|
556
|
+
<Metric label="High priority" value={snapshot?.counts.highPriorityTodos ?? 0} accent={(snapshot?.counts.highPriorityTodos ?? 0) > 0} />
|
|
557
|
+
<Metric label="Archived" value={(snapshot?.counts.archivedProjects ?? 0) + (snapshot?.counts.archivedTodos ?? 0)} />
|
|
558
|
+
</div>
|
|
559
|
+
|
|
560
|
+
<div className="grid gap-6 lg:grid-cols-[minmax(0,1fr)_300px]">
|
|
561
|
+
<section className="rounded-xl border border-border bg-card text-card-foreground">
|
|
562
|
+
<div className="flex items-center justify-between gap-3 border-b border-border px-5 py-3.5">
|
|
563
|
+
<h3 className="text-sm font-semibold">Due next</h3>
|
|
564
|
+
<span className="text-xs text-muted-foreground">{dueTodos.length} open</span>
|
|
565
|
+
</div>
|
|
566
|
+
<div className="divide-y divide-border">
|
|
567
|
+
{dueTodos.map((todo) => (
|
|
568
|
+
<button
|
|
569
|
+
key={todo.id}
|
|
570
|
+
type="button"
|
|
571
|
+
onClick={() => onOpenProject(todo.projectId)}
|
|
572
|
+
className="flex w-full items-center gap-3 px-5 py-3 text-left transition-colors hover:bg-muted/50 focus-visible:bg-muted/50 focus-visible:outline-none"
|
|
573
|
+
>
|
|
574
|
+
<PriorityFlag priority={todo.priority} />
|
|
575
|
+
<span className="min-w-0 flex-1 truncate text-sm font-medium">{todo.title}</span>
|
|
576
|
+
<span className="hidden truncate text-xs text-muted-foreground sm:block">{projectById.get(todo.projectId)?.name ?? "Project"}</span>
|
|
577
|
+
<span className="inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground">
|
|
578
|
+
<CalendarDays className="size-3.5" aria-hidden="true" />
|
|
579
|
+
{formatDate(todo.dueDate)}
|
|
580
|
+
</span>
|
|
581
|
+
</button>
|
|
582
|
+
))}
|
|
583
|
+
{dueTodos.length === 0 ? (
|
|
584
|
+
<p className="px-5 py-8 text-center text-sm text-muted-foreground">Nothing scheduled. You're all caught up.</p>
|
|
585
|
+
) : null}
|
|
586
|
+
</div>
|
|
587
|
+
</section>
|
|
588
|
+
|
|
589
|
+
<section className="grid h-fit gap-4 rounded-xl border border-border bg-card p-5 text-card-foreground">
|
|
590
|
+
<h3 className="text-sm font-semibold">Team visibility</h3>
|
|
591
|
+
<dl className="grid gap-3 text-sm">
|
|
592
|
+
<div className="grid gap-0.5">
|
|
593
|
+
<dt className="text-xs text-muted-foreground">Your access</dt>
|
|
594
|
+
<dd className="font-medium">
|
|
595
|
+
{snapshot?.currentUser.isManager
|
|
596
|
+
? "You can see and manage the whole team's tasks."
|
|
597
|
+
: "You see tasks assigned to you or that you created."}
|
|
598
|
+
</dd>
|
|
599
|
+
</div>
|
|
600
|
+
<Separator />
|
|
601
|
+
<div className="flex items-center justify-between">
|
|
602
|
+
<dt className="text-muted-foreground">Assignable users</dt>
|
|
603
|
+
<dd className="font-semibold tabular-nums">{users.length}</dd>
|
|
604
|
+
</div>
|
|
605
|
+
<div className="flex items-center justify-between">
|
|
606
|
+
<dt className="text-muted-foreground">Archived tasks</dt>
|
|
607
|
+
<dd className="font-semibold tabular-nums">{snapshot?.counts.archivedTodos ?? 0}</dd>
|
|
608
|
+
</div>
|
|
609
|
+
</dl>
|
|
610
|
+
</section>
|
|
611
|
+
</div>
|
|
612
|
+
|
|
613
|
+
{!hasProjects ? (
|
|
614
|
+
<section className="grid place-items-center gap-3 rounded-xl border border-dashed border-border bg-card px-6 py-12 text-center">
|
|
615
|
+
<div className="grid size-11 place-items-center rounded-full bg-muted text-muted-foreground">
|
|
616
|
+
<FolderPlus className="size-5" aria-hidden="true" />
|
|
617
|
+
</div>
|
|
618
|
+
<div className="grid gap-1">
|
|
619
|
+
<h3 className="text-base font-semibold">No projects yet</h3>
|
|
620
|
+
<p className="text-sm text-muted-foreground">Create a project to start grouping team work.</p>
|
|
621
|
+
</div>
|
|
622
|
+
<Button size="sm" onClick={onNewProject}>
|
|
623
|
+
<Plus aria-hidden="true" />
|
|
624
|
+
New project
|
|
625
|
+
</Button>
|
|
626
|
+
</section>
|
|
627
|
+
) : null}
|
|
628
|
+
</div>
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function ProjectView({
|
|
633
|
+
project,
|
|
634
|
+
todos,
|
|
635
|
+
users,
|
|
636
|
+
pendingAction,
|
|
637
|
+
onAddTask,
|
|
638
|
+
onUpdateProject,
|
|
639
|
+
onArchiveProject,
|
|
640
|
+
onDeleteProject,
|
|
641
|
+
onUpdateTodo,
|
|
642
|
+
onMarkDone,
|
|
643
|
+
onReopen,
|
|
644
|
+
onArchiveTodo,
|
|
645
|
+
onDeleteTodo
|
|
646
|
+
}: {
|
|
647
|
+
project: Project;
|
|
648
|
+
todos: Todo[];
|
|
649
|
+
users: User[];
|
|
650
|
+
pendingAction: string | null;
|
|
651
|
+
onAddTask: () => void;
|
|
652
|
+
onUpdateProject: (input: Partial<ProjectDraft>) => void;
|
|
653
|
+
onArchiveProject: () => void;
|
|
654
|
+
onDeleteProject: () => void;
|
|
655
|
+
onUpdateTodo: (todoId: string, input: TodoUpdateInput) => void;
|
|
656
|
+
onMarkDone: (todoId: string) => void;
|
|
657
|
+
onReopen: (todoId: string) => void;
|
|
658
|
+
onArchiveTodo: (todoId: string) => void;
|
|
659
|
+
onDeleteTodo: (todoId: string) => void;
|
|
660
|
+
}) {
|
|
661
|
+
const [editOpen, setEditOpen] = useState(false);
|
|
662
|
+
const [draft, setDraft] = useState<ProjectDraft>({
|
|
663
|
+
name: project.name,
|
|
664
|
+
description: project.description ?? "",
|
|
665
|
+
status: project.status
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
setDraft({ name: project.name, description: project.description ?? "", status: project.status });
|
|
670
|
+
}, [project.id, project.name, project.description, project.status]);
|
|
671
|
+
|
|
672
|
+
const doneCount = todos.filter((todo) => todo.status === "done").length;
|
|
673
|
+
const openTodos = todos.filter((todo) => todo.status !== "done");
|
|
674
|
+
const doneTodos = todos.filter((todo) => todo.status === "done");
|
|
675
|
+
const pct = todos.length ? Math.round((doneCount / todos.length) * 100) : 0;
|
|
676
|
+
|
|
677
|
+
return (
|
|
678
|
+
<div className="grid gap-6">
|
|
679
|
+
<div className="grid gap-3">
|
|
680
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
681
|
+
<div className="grid min-w-0 gap-1.5">
|
|
682
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
683
|
+
<h2 className="text-2xl font-bold tracking-tight text-balance">{project.name}</h2>
|
|
684
|
+
<StatusBadge status={project.status} archived={Boolean(project.archivedAt)} />
|
|
685
|
+
</div>
|
|
686
|
+
{project.description ? (
|
|
687
|
+
<p className="max-w-prose text-sm text-muted-foreground">{project.description}</p>
|
|
688
|
+
) : null}
|
|
689
|
+
</div>
|
|
690
|
+
<div className="flex items-center gap-2">
|
|
691
|
+
<Button size="sm" onClick={onAddTask}>
|
|
692
|
+
<Plus aria-hidden="true" />
|
|
693
|
+
Add task
|
|
694
|
+
</Button>
|
|
695
|
+
<DropdownMenu>
|
|
696
|
+
<DropdownMenuTrigger asChild>
|
|
697
|
+
<Button variant="outline" size="icon" aria-label="Project actions">
|
|
698
|
+
<MoreHorizontal aria-hidden="true" />
|
|
699
|
+
</Button>
|
|
700
|
+
</DropdownMenuTrigger>
|
|
701
|
+
<DropdownMenuContent align="end" className="w-44">
|
|
702
|
+
<DropdownMenuItem onSelect={() => setEditOpen(true)}>
|
|
703
|
+
Edit project
|
|
704
|
+
</DropdownMenuItem>
|
|
705
|
+
{project.archivedAt ? (
|
|
706
|
+
<>
|
|
707
|
+
<DropdownMenuSeparator />
|
|
708
|
+
<DropdownMenuItem variant="destructive" onSelect={onDeleteProject}>
|
|
709
|
+
<Trash2 aria-hidden="true" />
|
|
710
|
+
Delete permanently
|
|
711
|
+
</DropdownMenuItem>
|
|
712
|
+
</>
|
|
713
|
+
) : (
|
|
714
|
+
<DropdownMenuItem onSelect={onArchiveProject}>
|
|
715
|
+
<Archive aria-hidden="true" />
|
|
716
|
+
Archive project
|
|
717
|
+
</DropdownMenuItem>
|
|
718
|
+
)}
|
|
719
|
+
</DropdownMenuContent>
|
|
720
|
+
</DropdownMenu>
|
|
721
|
+
</div>
|
|
722
|
+
</div>
|
|
723
|
+
|
|
724
|
+
<div className="flex items-center gap-3">
|
|
725
|
+
<div className="h-1.5 w-full max-w-xs overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuenow={pct} aria-valuemin={0} aria-valuemax={100}>
|
|
726
|
+
<div className="h-full rounded-full bg-primary transition-[width] duration-300 ease-out" style={{ width: `${pct}%` }} />
|
|
727
|
+
</div>
|
|
728
|
+
<span className="text-xs text-muted-foreground tabular-nums">
|
|
729
|
+
{doneCount} / {todos.length} done
|
|
730
|
+
</span>
|
|
731
|
+
</div>
|
|
732
|
+
</div>
|
|
733
|
+
|
|
734
|
+
<div className="grid gap-2">
|
|
735
|
+
{todos.length === 0 ? (
|
|
736
|
+
<div className="grid place-items-center gap-3 rounded-xl border border-dashed border-border bg-card px-6 py-12 text-center">
|
|
737
|
+
<p className="text-sm text-muted-foreground">No tasks in this project yet.</p>
|
|
738
|
+
<Button size="sm" variant="outline" onClick={onAddTask}>
|
|
739
|
+
<Plus aria-hidden="true" />
|
|
740
|
+
Add the first task
|
|
741
|
+
</Button>
|
|
742
|
+
</div>
|
|
743
|
+
) : (
|
|
744
|
+
<>
|
|
745
|
+
<ul className="grid gap-2">
|
|
746
|
+
{openTodos.map((todo) => (
|
|
747
|
+
<TaskRow
|
|
748
|
+
key={todo.id}
|
|
749
|
+
todo={todo}
|
|
750
|
+
users={users}
|
|
751
|
+
pendingAction={pendingAction}
|
|
752
|
+
onUpdate={(input) => onUpdateTodo(todo.id, input)}
|
|
753
|
+
onMarkDone={() => onMarkDone(todo.id)}
|
|
754
|
+
onReopen={() => onReopen(todo.id)}
|
|
755
|
+
onArchive={() => onArchiveTodo(todo.id)}
|
|
756
|
+
onDelete={() => onDeleteTodo(todo.id)}
|
|
757
|
+
/>
|
|
758
|
+
))}
|
|
759
|
+
</ul>
|
|
760
|
+
|
|
761
|
+
{doneTodos.length > 0 ? (
|
|
762
|
+
<details className="group mt-3" open={openTodos.length === 0}>
|
|
763
|
+
<summary className="flex cursor-pointer list-none items-center gap-1.5 px-1 py-2 text-xs font-medium text-muted-foreground select-none">
|
|
764
|
+
<ChevronDown className="size-3.5 transition-transform group-open:rotate-0 -rotate-90" aria-hidden="true" />
|
|
765
|
+
Completed ({doneTodos.length})
|
|
766
|
+
</summary>
|
|
767
|
+
<ul className="mt-1 grid gap-2">
|
|
768
|
+
{doneTodos.map((todo) => (
|
|
769
|
+
<TaskRow
|
|
770
|
+
key={todo.id}
|
|
771
|
+
todo={todo}
|
|
772
|
+
users={users}
|
|
773
|
+
pendingAction={pendingAction}
|
|
774
|
+
onUpdate={(input) => onUpdateTodo(todo.id, input)}
|
|
775
|
+
onMarkDone={() => onMarkDone(todo.id)}
|
|
776
|
+
onReopen={() => onReopen(todo.id)}
|
|
777
|
+
onArchive={() => onArchiveTodo(todo.id)}
|
|
778
|
+
onDelete={() => onDeleteTodo(todo.id)}
|
|
779
|
+
/>
|
|
780
|
+
))}
|
|
781
|
+
</ul>
|
|
782
|
+
</details>
|
|
783
|
+
) : null}
|
|
784
|
+
</>
|
|
785
|
+
)}
|
|
786
|
+
</div>
|
|
787
|
+
|
|
788
|
+
<ProjectDialog
|
|
789
|
+
open={editOpen}
|
|
790
|
+
onOpenChange={setEditOpen}
|
|
791
|
+
draft={draft}
|
|
792
|
+
editing
|
|
793
|
+
pending={pendingAction === `project:${project.id}:update`}
|
|
794
|
+
onChange={setDraft}
|
|
795
|
+
onSubmit={() => {
|
|
796
|
+
onUpdateProject(draft);
|
|
797
|
+
setEditOpen(false);
|
|
798
|
+
}}
|
|
799
|
+
/>
|
|
800
|
+
</div>
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function TaskRow({
|
|
805
|
+
todo,
|
|
806
|
+
users,
|
|
807
|
+
pendingAction,
|
|
808
|
+
onUpdate,
|
|
809
|
+
onMarkDone,
|
|
810
|
+
onReopen,
|
|
811
|
+
onArchive,
|
|
812
|
+
onDelete
|
|
813
|
+
}: {
|
|
814
|
+
todo: Todo;
|
|
815
|
+
users: User[];
|
|
816
|
+
pendingAction: string | null;
|
|
817
|
+
onUpdate: (input: TodoUpdateInput) => void;
|
|
818
|
+
onMarkDone: () => void;
|
|
819
|
+
onReopen: () => void;
|
|
820
|
+
onArchive: () => void;
|
|
821
|
+
onDelete: () => void;
|
|
822
|
+
}) {
|
|
823
|
+
const [expanded, setExpanded] = useState(false);
|
|
824
|
+
const [draft, setDraft] = useState<TodoDraft>(() => toDraft(todo));
|
|
825
|
+
const done = todo.status === "done";
|
|
826
|
+
const archived = Boolean(todo.archivedAt);
|
|
827
|
+
|
|
828
|
+
useEffect(() => {
|
|
829
|
+
setDraft(toDraft(todo));
|
|
830
|
+
}, [todo.id, todo.title, todo.notes, todo.status, todo.priority, todo.assigneeId, todo.dueDate, todo.projectId]);
|
|
831
|
+
|
|
832
|
+
const dirty =
|
|
833
|
+
draft.title !== todo.title ||
|
|
834
|
+
draft.notes !== (todo.notes ?? "") ||
|
|
835
|
+
draft.status !== todo.status ||
|
|
836
|
+
draft.priority !== todo.priority ||
|
|
837
|
+
draft.assigneeId !== (todo.assigneeId ?? "") ||
|
|
838
|
+
draft.dueDate !== (todo.dueDate ?? "");
|
|
839
|
+
|
|
840
|
+
const overdue = !done && isOverdue(todo.dueDate);
|
|
841
|
+
|
|
842
|
+
return (
|
|
843
|
+
<li
|
|
844
|
+
id={`todo-${todo.id}`}
|
|
845
|
+
className={cn(
|
|
846
|
+
"scroll-mt-20 rounded-lg border border-border bg-card text-card-foreground transition-colors",
|
|
847
|
+
archived && "bg-muted/30",
|
|
848
|
+
expanded && "ring-1 ring-ring/40"
|
|
849
|
+
)}
|
|
850
|
+
>
|
|
851
|
+
<div className="flex items-center gap-3 px-3 py-2.5">
|
|
852
|
+
<Checkbox
|
|
853
|
+
checked={done}
|
|
854
|
+
disabled={archived || pendingAction === `todo:${todo.id}:done`}
|
|
855
|
+
onCheckedChange={(checked) => (checked ? onMarkDone() : onReopen())}
|
|
856
|
+
aria-label={done ? `Reopen ${todo.title}` : `Mark ${todo.title} done`}
|
|
857
|
+
/>
|
|
858
|
+
<button
|
|
859
|
+
type="button"
|
|
860
|
+
onClick={() => setExpanded((value) => !value)}
|
|
861
|
+
className="flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none"
|
|
862
|
+
aria-expanded={expanded}
|
|
863
|
+
>
|
|
864
|
+
<span className={cn("min-w-0 flex-1 truncate text-sm font-medium", done && "text-muted-foreground line-through")}>
|
|
865
|
+
{todo.title}
|
|
866
|
+
</span>
|
|
867
|
+
</button>
|
|
868
|
+
|
|
869
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
870
|
+
{todo.assigneeName ? (
|
|
871
|
+
<span className="hidden items-center gap-1.5 text-xs text-muted-foreground sm:inline-flex" title={`Assigned to ${todo.assigneeName}`}>
|
|
872
|
+
<Avatar name={todo.assigneeName} />
|
|
873
|
+
<span className="hidden max-w-24 truncate md:inline">{todo.assigneeName}</span>
|
|
874
|
+
</span>
|
|
875
|
+
) : null}
|
|
876
|
+
{todo.dueDate ? (
|
|
877
|
+
<span className={cn("hidden items-center gap-1 text-xs sm:inline-flex", overdue ? "font-medium text-destructive" : "text-muted-foreground")} title={overdue ? "Overdue" : "Due date"}>
|
|
878
|
+
<CalendarDays className="size-3.5" aria-hidden="true" />
|
|
879
|
+
{formatDate(todo.dueDate)}
|
|
880
|
+
</span>
|
|
881
|
+
) : null}
|
|
882
|
+
<PriorityBadge priority={todo.priority} />
|
|
883
|
+
{!done ? <StatusBadge status={todo.status} /> : null}
|
|
884
|
+
<button
|
|
885
|
+
type="button"
|
|
886
|
+
onClick={() => setExpanded((value) => !value)}
|
|
887
|
+
className="grid size-7 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
888
|
+
aria-label={expanded ? "Collapse task" : "Edit task"}
|
|
889
|
+
>
|
|
890
|
+
<ChevronDown className={cn("size-4 transition-transform", expanded && "rotate-180")} aria-hidden="true" />
|
|
891
|
+
</button>
|
|
892
|
+
</div>
|
|
893
|
+
</div>
|
|
894
|
+
|
|
895
|
+
{expanded ? (
|
|
896
|
+
<div className="border-t border-border p-4">
|
|
897
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
898
|
+
<Field label="Task" className="md:col-span-2">
|
|
899
|
+
<Input value={draft.title} onChange={(event) => setDraft({ ...draft, title: event.target.value })} />
|
|
900
|
+
</Field>
|
|
901
|
+
<Field label="Status">
|
|
902
|
+
<StatusSelect value={draft.status} onChange={(status) => setDraft({ ...draft, status })} />
|
|
903
|
+
</Field>
|
|
904
|
+
<Field label="Priority">
|
|
905
|
+
<PrioritySelect value={draft.priority} onChange={(priority) => setDraft({ ...draft, priority })} />
|
|
906
|
+
</Field>
|
|
907
|
+
<Field label="Assignee">
|
|
908
|
+
<UserSelect value={draft.assigneeId} users={users} onChange={(assigneeId) => setDraft({ ...draft, assigneeId })} />
|
|
909
|
+
</Field>
|
|
910
|
+
<Field label="Due date">
|
|
911
|
+
<Input type="date" value={draft.dueDate} onChange={(event) => setDraft({ ...draft, dueDate: event.target.value })} />
|
|
912
|
+
</Field>
|
|
913
|
+
<Field label="Notes" className="md:col-span-2">
|
|
914
|
+
<Textarea
|
|
915
|
+
rows={3}
|
|
916
|
+
placeholder="Add context, links, or acceptance criteria…"
|
|
917
|
+
value={draft.notes}
|
|
918
|
+
onChange={(event) => setDraft({ ...draft, notes: event.target.value })}
|
|
919
|
+
/>
|
|
920
|
+
</Field>
|
|
921
|
+
</div>
|
|
922
|
+
|
|
923
|
+
<div className="mt-4 flex flex-wrap items-center justify-between gap-2">
|
|
924
|
+
<div className="flex items-center gap-2">
|
|
925
|
+
{archived ? (
|
|
926
|
+
<Button variant="destructive" size="sm" onClick={onDelete}>
|
|
927
|
+
<Trash2 aria-hidden="true" />
|
|
928
|
+
Delete
|
|
929
|
+
</Button>
|
|
930
|
+
) : (
|
|
931
|
+
<Button variant="outline" size="sm" onClick={onArchive}>
|
|
932
|
+
<Archive aria-hidden="true" />
|
|
933
|
+
Archive
|
|
934
|
+
</Button>
|
|
935
|
+
)}
|
|
936
|
+
{done ? (
|
|
937
|
+
<Button variant="outline" size="sm" onClick={onReopen}>
|
|
938
|
+
Reopen
|
|
939
|
+
</Button>
|
|
940
|
+
) : (
|
|
941
|
+
<Button variant="outline" size="sm" onClick={onMarkDone}>
|
|
942
|
+
<CheckCircle2 aria-hidden="true" />
|
|
943
|
+
Mark done
|
|
944
|
+
</Button>
|
|
945
|
+
)}
|
|
946
|
+
</div>
|
|
947
|
+
<Button
|
|
948
|
+
size="sm"
|
|
949
|
+
disabled={!dirty || pendingAction === `todo:${todo.id}:update`}
|
|
950
|
+
onClick={() => onUpdate({
|
|
951
|
+
title: draft.title,
|
|
952
|
+
notes: draft.notes || null,
|
|
953
|
+
status: draft.status,
|
|
954
|
+
priority: draft.priority,
|
|
955
|
+
assigneeId: draft.assigneeId || null,
|
|
956
|
+
dueDate: draft.dueDate || null
|
|
957
|
+
})}
|
|
958
|
+
>
|
|
959
|
+
<Check aria-hidden="true" />
|
|
960
|
+
Save changes
|
|
961
|
+
</Button>
|
|
962
|
+
</div>
|
|
963
|
+
</div>
|
|
964
|
+
) : null}
|
|
965
|
+
</li>
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
function ProjectDialog({
|
|
970
|
+
open,
|
|
971
|
+
onOpenChange,
|
|
972
|
+
draft,
|
|
973
|
+
pending,
|
|
974
|
+
editing,
|
|
975
|
+
onChange,
|
|
976
|
+
onSubmit
|
|
977
|
+
}: {
|
|
978
|
+
open: boolean;
|
|
979
|
+
onOpenChange: (open: boolean) => void;
|
|
980
|
+
draft: ProjectDraft;
|
|
981
|
+
pending: boolean;
|
|
982
|
+
editing?: boolean;
|
|
983
|
+
onChange: (draft: ProjectDraft) => void;
|
|
984
|
+
onSubmit: () => void;
|
|
985
|
+
}) {
|
|
986
|
+
return (
|
|
987
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
988
|
+
<DialogContent className="sm:max-w-md">
|
|
989
|
+
<DialogHeader>
|
|
990
|
+
<DialogTitle>{editing ? "Edit project" : "New project"}</DialogTitle>
|
|
991
|
+
<DialogDescription>Group related tasks and track progress together.</DialogDescription>
|
|
992
|
+
</DialogHeader>
|
|
993
|
+
<form
|
|
994
|
+
className="grid gap-4"
|
|
995
|
+
onSubmit={(event) => {
|
|
996
|
+
event.preventDefault();
|
|
997
|
+
if (draft.name.trim()) onSubmit();
|
|
998
|
+
}}
|
|
999
|
+
>
|
|
1000
|
+
<Field label="Project name">
|
|
1001
|
+
<Input autoFocus value={draft.name} onChange={(event) => onChange({ ...draft, name: event.target.value })} placeholder="e.g. Q3 launch" />
|
|
1002
|
+
</Field>
|
|
1003
|
+
<Field label="Status">
|
|
1004
|
+
<Select items={projectStatusItems} value={draft.status} onValueChange={(value) => onChange({ ...draft, status: value as ProjectStatus })}>
|
|
1005
|
+
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
1006
|
+
<SelectContent>
|
|
1007
|
+
{projectStatusItems.map((item) => (
|
|
1008
|
+
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
1009
|
+
))}
|
|
1010
|
+
</SelectContent>
|
|
1011
|
+
</Select>
|
|
1012
|
+
</Field>
|
|
1013
|
+
<Field label="Description">
|
|
1014
|
+
<Textarea rows={3} value={draft.description} onChange={(event) => onChange({ ...draft, description: event.target.value })} placeholder="What is this project about?" />
|
|
1015
|
+
</Field>
|
|
1016
|
+
<DialogFooter>
|
|
1017
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
|
|
1018
|
+
<Button type="submit" disabled={pending || !draft.name.trim()}>
|
|
1019
|
+
{editing ? "Save project" : "Create project"}
|
|
1020
|
+
</Button>
|
|
1021
|
+
</DialogFooter>
|
|
1022
|
+
</form>
|
|
1023
|
+
</DialogContent>
|
|
1024
|
+
</Dialog>
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
function TaskDialog({
|
|
1029
|
+
open,
|
|
1030
|
+
onOpenChange,
|
|
1031
|
+
draft,
|
|
1032
|
+
projects,
|
|
1033
|
+
users,
|
|
1034
|
+
pending,
|
|
1035
|
+
onChange,
|
|
1036
|
+
onSubmit
|
|
1037
|
+
}: {
|
|
1038
|
+
open: boolean;
|
|
1039
|
+
onOpenChange: (open: boolean) => void;
|
|
1040
|
+
draft: TodoDraft;
|
|
1041
|
+
projects: Project[];
|
|
1042
|
+
users: User[];
|
|
1043
|
+
pending: boolean;
|
|
1044
|
+
onChange: (draft: TodoDraft) => void;
|
|
1045
|
+
onSubmit: (draft: TodoDraft) => void;
|
|
1046
|
+
}) {
|
|
1047
|
+
const projectId = draft.projectId || projects[0]?.id || "";
|
|
1048
|
+
const projectItems = projects.map((project) => ({ label: project.name, value: project.id }));
|
|
1049
|
+
const canSubmit = Boolean(projectId) && draft.title.trim().length > 0;
|
|
1050
|
+
|
|
1051
|
+
return (
|
|
1052
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
1053
|
+
<DialogContent className="sm:max-w-lg">
|
|
1054
|
+
<DialogHeader>
|
|
1055
|
+
<DialogTitle>New task</DialogTitle>
|
|
1056
|
+
<DialogDescription>Add a task and assign it to a teammate.</DialogDescription>
|
|
1057
|
+
</DialogHeader>
|
|
1058
|
+
<form
|
|
1059
|
+
className="grid gap-4"
|
|
1060
|
+
onSubmit={(event) => {
|
|
1061
|
+
event.preventDefault();
|
|
1062
|
+
if (canSubmit) onSubmit({ ...draft, projectId });
|
|
1063
|
+
}}
|
|
1064
|
+
>
|
|
1065
|
+
<Field label="Task title">
|
|
1066
|
+
<Input autoFocus value={draft.title} onChange={(event) => onChange({ ...draft, title: event.target.value })} placeholder="What needs doing?" />
|
|
1067
|
+
</Field>
|
|
1068
|
+
<div className="grid gap-4 sm:grid-cols-2">
|
|
1069
|
+
<Field label="Project">
|
|
1070
|
+
<Select items={projectItems} value={projectId} onValueChange={(value) => onChange({ ...draft, projectId: value })}>
|
|
1071
|
+
<SelectTrigger><SelectValue placeholder="Select project" /></SelectTrigger>
|
|
1072
|
+
<SelectContent>
|
|
1073
|
+
{projectItems.map((item) => (
|
|
1074
|
+
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
1075
|
+
))}
|
|
1076
|
+
</SelectContent>
|
|
1077
|
+
</Select>
|
|
1078
|
+
</Field>
|
|
1079
|
+
<Field label="Priority">
|
|
1080
|
+
<PrioritySelect value={draft.priority} onChange={(priority) => onChange({ ...draft, priority })} />
|
|
1081
|
+
</Field>
|
|
1082
|
+
<Field label="Assignee">
|
|
1083
|
+
<UserSelect value={draft.assigneeId} users={users} onChange={(assigneeId) => onChange({ ...draft, assigneeId })} />
|
|
1084
|
+
</Field>
|
|
1085
|
+
<Field label="Due date">
|
|
1086
|
+
<Input type="date" value={draft.dueDate} onChange={(event) => onChange({ ...draft, dueDate: event.target.value })} />
|
|
1087
|
+
</Field>
|
|
1088
|
+
</div>
|
|
1089
|
+
<Field label="Notes">
|
|
1090
|
+
<Textarea rows={3} value={draft.notes} onChange={(event) => onChange({ ...draft, notes: event.target.value })} placeholder="Optional details…" />
|
|
1091
|
+
</Field>
|
|
1092
|
+
<DialogFooter>
|
|
1093
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
|
|
1094
|
+
<Button type="submit" disabled={pending || !canSubmit}>Create task</Button>
|
|
1095
|
+
</DialogFooter>
|
|
1096
|
+
</form>
|
|
1097
|
+
</DialogContent>
|
|
1098
|
+
</Dialog>
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
function AccountFooterItem() {
|
|
1103
|
+
const [account, setAccount] = useState<AccountSummary | null>(null);
|
|
1104
|
+
const [failed, setFailed] = useState(false);
|
|
1105
|
+
|
|
1106
|
+
useEffect(() => {
|
|
1107
|
+
let active = true;
|
|
1108
|
+
void loadAccountSummary()
|
|
1109
|
+
.then((summary) => { if (active) setAccount(summary); })
|
|
1110
|
+
.catch(() => { if (active) setFailed(true); });
|
|
1111
|
+
return () => { active = false; };
|
|
1112
|
+
}, []);
|
|
1113
|
+
|
|
1114
|
+
if (failed) {
|
|
1115
|
+
return (
|
|
1116
|
+
<SidebarMenuItem>
|
|
1117
|
+
<SidebarMenuButton asChild>
|
|
1118
|
+
<a href="/login">
|
|
1119
|
+
<UserCircle aria-hidden="true" />
|
|
1120
|
+
<span>Sign in</span>
|
|
1121
|
+
</a>
|
|
1122
|
+
</SidebarMenuButton>
|
|
1123
|
+
</SidebarMenuItem>
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
const label = account?.name || account?.email || "Account";
|
|
1128
|
+
|
|
1129
|
+
return (
|
|
1130
|
+
<SidebarMenuItem>
|
|
1131
|
+
<DropdownMenu>
|
|
1132
|
+
<DropdownMenuTrigger asChild>
|
|
1133
|
+
<SidebarMenuButton size="lg" className="data-[state=open]:bg-sidebar-accent">
|
|
1134
|
+
<Avatar name={label} />
|
|
1135
|
+
<div className="grid min-w-0 flex-1 leading-tight">
|
|
1136
|
+
<span className="truncate text-sm font-medium">{account?.name ?? "Account"}</span>
|
|
1137
|
+
<span className="truncate text-xs text-muted-foreground">{account?.email ?? ""}</span>
|
|
1138
|
+
</div>
|
|
1139
|
+
<ChevronDown className="ml-auto size-4 text-muted-foreground" aria-hidden="true" />
|
|
1140
|
+
</SidebarMenuButton>
|
|
1141
|
+
</DropdownMenuTrigger>
|
|
1142
|
+
<DropdownMenuContent side="top" align="start" className="w-56">
|
|
1143
|
+
<DropdownMenuItem asChild>
|
|
1144
|
+
<a href="/profile">
|
|
1145
|
+
<UserCircle aria-hidden="true" />
|
|
1146
|
+
Profile
|
|
1147
|
+
</a>
|
|
1148
|
+
</DropdownMenuItem>
|
|
1149
|
+
{account?.isOperator ? (
|
|
1150
|
+
<DropdownMenuItem asChild>
|
|
1151
|
+
<a href="/admin">
|
|
1152
|
+
<Shield aria-hidden="true" />
|
|
1153
|
+
Admin
|
|
1154
|
+
</a>
|
|
1155
|
+
</DropdownMenuItem>
|
|
1156
|
+
) : null}
|
|
1157
|
+
<DropdownMenuSeparator />
|
|
1158
|
+
<DropdownMenuItem asChild variant="destructive">
|
|
1159
|
+
<form action="/api/auth/logout" method="post">
|
|
1160
|
+
<button type="submit" className="flex w-full items-center gap-2">
|
|
1161
|
+
<LogOut aria-hidden="true" />
|
|
1162
|
+
Sign out
|
|
1163
|
+
</button>
|
|
1164
|
+
</form>
|
|
1165
|
+
</DropdownMenuItem>
|
|
1166
|
+
</DropdownMenuContent>
|
|
1167
|
+
</DropdownMenu>
|
|
1168
|
+
</SidebarMenuItem>
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function Field({ label, className, children }: { label: string; className?: string; children: ReactNode }) {
|
|
1173
|
+
return (
|
|
1174
|
+
<div className={cn("grid gap-1.5", className)}>
|
|
1175
|
+
<Label className="text-xs text-muted-foreground">{label}</Label>
|
|
1176
|
+
{children}
|
|
1177
|
+
</div>
|
|
1178
|
+
);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
function StatusSelect({ value, onChange }: { value: TodoStatus; onChange: (value: TodoStatus) => void }) {
|
|
1182
|
+
return (
|
|
1183
|
+
<Select items={todoStatusItems} value={value} onValueChange={(next) => onChange(next as TodoStatus)}>
|
|
1184
|
+
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
1185
|
+
<SelectContent>
|
|
1186
|
+
{todoStatusItems.map((item) => (
|
|
1187
|
+
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
1188
|
+
))}
|
|
1189
|
+
</SelectContent>
|
|
1190
|
+
</Select>
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
function PrioritySelect({ value, onChange }: { value: Priority; onChange: (value: Priority) => void }) {
|
|
1195
|
+
return (
|
|
1196
|
+
<Select items={priorityItems} value={value} onValueChange={(next) => onChange(next as Priority)}>
|
|
1197
|
+
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
1198
|
+
<SelectContent>
|
|
1199
|
+
{priorityItems.map((item) => (
|
|
1200
|
+
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
1201
|
+
))}
|
|
1202
|
+
</SelectContent>
|
|
1203
|
+
</Select>
|
|
1204
|
+
);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
function UserSelect({ value, users, onChange }: { value: string; users: User[]; onChange: (value: string) => void }) {
|
|
1208
|
+
const userItems = [
|
|
1209
|
+
{ label: "Unassigned", value: UNASSIGNED },
|
|
1210
|
+
...users.map((user) => ({ label: user.name || user.email, value: user.id }))
|
|
1211
|
+
];
|
|
1212
|
+
|
|
1213
|
+
return (
|
|
1214
|
+
<Select items={userItems} value={value || UNASSIGNED} onValueChange={(next) => onChange(next === UNASSIGNED ? "" : next)}>
|
|
1215
|
+
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
1216
|
+
<SelectContent>
|
|
1217
|
+
{userItems.map((item) => (
|
|
1218
|
+
<SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
|
|
1219
|
+
))}
|
|
1220
|
+
</SelectContent>
|
|
1221
|
+
</Select>
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
function Metric({ label, value, accent }: { label: string; value: number; accent?: boolean }) {
|
|
1226
|
+
return (
|
|
1227
|
+
<div className="rounded-xl border border-border bg-card px-4 py-3.5 text-card-foreground">
|
|
1228
|
+
<div className={cn("text-2xl font-bold leading-none tabular-nums", accent && "text-destructive")}>{value}</div>
|
|
1229
|
+
<div className="mt-1.5 text-xs text-muted-foreground">{label}</div>
|
|
1230
|
+
</div>
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
function StatusBadge({ status, archived }: { status: ProjectStatus | TodoStatus; archived?: boolean }) {
|
|
1235
|
+
if (archived) return <Badge variant="secondary" className="text-muted-foreground">Archived</Badge>;
|
|
1236
|
+
const label = status in todoStatusLabel ? todoStatusLabel[status as TodoStatus] : projectStatusLabel[status as ProjectStatus];
|
|
1237
|
+
if (status === "doing" || status === "active") {
|
|
1238
|
+
return <Badge className="border-transparent bg-primary/10 text-primary">{label}</Badge>;
|
|
1239
|
+
}
|
|
1240
|
+
if (status === "done") {
|
|
1241
|
+
return <Badge variant="secondary" className="text-muted-foreground">{label}</Badge>;
|
|
1242
|
+
}
|
|
1243
|
+
return <Badge variant="outline" className="text-muted-foreground">{label}</Badge>;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function PriorityBadge({ priority }: { priority: Priority }) {
|
|
1247
|
+
if (priority === "high") {
|
|
1248
|
+
return (
|
|
1249
|
+
<Badge variant="destructive">
|
|
1250
|
+
<Flag className="size-3" aria-hidden="true" />
|
|
1251
|
+
High
|
|
1252
|
+
</Badge>
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
if (priority === "low") {
|
|
1256
|
+
return <Badge variant="outline" className="text-muted-foreground">Low</Badge>;
|
|
1257
|
+
}
|
|
1258
|
+
return <Badge variant="secondary">Medium</Badge>;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
function PriorityFlag({ priority }: { priority: Priority }) {
|
|
1262
|
+
const color = priority === "high" ? "text-destructive" : priority === "medium" ? "text-foreground/70" : "text-muted-foreground";
|
|
1263
|
+
return <Flag className={cn("size-3.5 shrink-0", color)} aria-hidden="true" />;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
function StatusDot({ status, archived }: { status: ProjectStatus; archived: boolean }) {
|
|
1267
|
+
const color = archived
|
|
1268
|
+
? "bg-muted-foreground/40"
|
|
1269
|
+
: status === "active"
|
|
1270
|
+
? "bg-primary"
|
|
1271
|
+
: status === "paused"
|
|
1272
|
+
? "bg-amber-500"
|
|
1273
|
+
: "bg-muted-foreground/50";
|
|
1274
|
+
return <span className={cn("size-2 shrink-0 rounded-full", color)} aria-hidden="true" />;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function Avatar({ name }: { name: string }) {
|
|
1278
|
+
return (
|
|
1279
|
+
<span className="grid size-6 shrink-0 place-items-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground">
|
|
1280
|
+
{initials(name)}
|
|
1281
|
+
</span>
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
function toDraft(todo: Todo): TodoDraft {
|
|
1286
|
+
return {
|
|
1287
|
+
projectId: todo.projectId,
|
|
1288
|
+
title: todo.title,
|
|
1289
|
+
notes: todo.notes ?? "",
|
|
1290
|
+
status: todo.status,
|
|
1291
|
+
priority: todo.priority,
|
|
1292
|
+
assigneeId: todo.assigneeId ?? "",
|
|
1293
|
+
dueDate: todo.dueDate ?? ""
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
function initials(name: string) {
|
|
1298
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
1299
|
+
if (parts.length === 0) return "?";
|
|
1300
|
+
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
1301
|
+
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function isOverdue(value?: string | null) {
|
|
1305
|
+
if (!value) return false;
|
|
1306
|
+
const due = new Date(`${value}T23:59:59`);
|
|
1307
|
+
if (Number.isNaN(due.getTime())) return false;
|
|
1308
|
+
return due.getTime() < Date.now();
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function formatDate(value?: string | null) {
|
|
1312
|
+
if (!value) return "No date";
|
|
1313
|
+
const date = new Date(`${value}T00:00:00`);
|
|
1314
|
+
if (Number.isNaN(date.getTime())) return value;
|
|
1315
|
+
return new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }).format(date);
|
|
1316
|
+
}
|