create-lego-one 2.0.10 → 2.0.13
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/dist/index.cjs +179 -0
- package/dist/index.cjs.map +1 -1
- package/package.json +5 -3
- package/template/.cursor/rules/rules.mdc +639 -0
- package/template/.dockerignore +58 -0
- package/template/.env.example +18 -0
- package/template/.eslintignore +5 -0
- package/template/.eslintrc.js +28 -0
- package/template/.prettierignore +6 -0
- package/template/.prettierrc +11 -0
- package/template/CLAUDE.md +634 -0
- package/template/Dockerfile +67 -0
- package/template/PROMPT.md +457 -0
- package/template/README.md +325 -0
- package/template/docker-compose.yml +48 -0
- package/template/docker-entrypoint.sh +23 -0
- package/template/docs/checkpoints/.template.md +64 -0
- package/template/docs/checkpoints/framework/01-infrastructure-setup.md +132 -0
- package/template/docs/checkpoints/framework/02-pocketbase-setup.md +155 -0
- package/template/docs/checkpoints/framework/03-host-kernel.md +170 -0
- package/template/docs/checkpoints/framework/04-auth-system.md +163 -0
- package/template/docs/checkpoints/framework/phase-05-multitenancy-rbac.md +223 -0
- package/template/docs/checkpoints/framework/phase-06-ui-components.md +260 -0
- package/template/docs/checkpoints/framework/phase-07-communication-system.md +276 -0
- package/template/docs/checkpoints/framework/phase-08-plugin-system.md +91 -0
- package/template/docs/checkpoints/framework/phase-09-dashboard-plugin.md +111 -0
- package/template/docs/checkpoints/framework/phase-10-todo-plugin.md +169 -0
- package/template/docs/checkpoints/framework/phase-11-testing.md +264 -0
- package/template/docs/checkpoints/framework/phase-12-deployment.md +294 -0
- package/template/docs/checkpoints/framework/phase-13-documentation.md +312 -0
- package/template/docs/framework/plans/00-index.md +164 -0
- package/template/docs/framework/plans/01-infrastructure-setup.md +855 -0
- package/template/docs/framework/plans/02-pocketbase-setup.md +1374 -0
- package/template/docs/framework/plans/03-host-kernel.md +1518 -0
- package/template/docs/framework/plans/04-auth-system.md +1466 -0
- package/template/docs/framework/plans/05-multitenancy-rbac.md +1527 -0
- package/template/docs/framework/plans/06-ui-components.md +1478 -0
- package/template/docs/framework/plans/07-communication-system.md +1106 -0
- package/template/docs/framework/plans/08-plugin-system.md +1179 -0
- package/template/docs/framework/plans/09-dashboard-plugin.md +1137 -0
- package/template/docs/framework/plans/10-todo-plugin.md +1343 -0
- package/template/docs/framework/plans/11-testing.md +935 -0
- package/template/docs/framework/plans/12-deployment.md +896 -0
- package/template/docs/framework/prompts/0-boilerplate-modernjs.md +151 -0
- package/template/docs/framework/research/00-modernjs-audit.md +488 -0
- package/template/docs/framework/research/01-system-blueprint.md +721 -0
- package/template/docs/framework/research/02-data-migration-protocol.md +699 -0
- package/template/docs/framework/research/03-host-setup.md +714 -0
- package/template/docs/framework/research/04-plugin-architecture.md +645 -0
- package/template/docs/framework/research/05-slot-injection-pattern.md +671 -0
- package/template/docs/framework/research/06-cli-strategy.md +615 -0
- package/template/docs/framework/research/07-deployment.md +629 -0
- package/template/docs/framework/research/README.md +282 -0
- package/template/docs/framework/setup/00-index.md +210 -0
- package/template/docs/framework/setup/01-framework-structure.md +308 -0
- package/template/docs/framework/setup/02-development-workflow.md +405 -0
- package/template/docs/framework/setup/03-environment-setup.md +215 -0
- package/template/docs/framework/setup/04-kernel-architecture.md +499 -0
- package/template/docs/framework/setup/05-plugin-system.md +620 -0
- package/template/docs/framework/setup/06-communication-patterns.md +451 -0
- package/template/docs/framework/setup/07-plugin-development.md +582 -0
- package/template/docs/framework/setup/08-component-library.md +658 -0
- package/template/docs/framework/setup/09-data-integration.md +609 -0
- package/template/docs/framework/setup/10-auth-rbac.md +497 -0
- package/template/docs/framework/setup/11-hooks-api.md +393 -0
- package/template/docs/framework/setup/12-components-api.md +665 -0
- package/template/docs/framework/setup/13-deployment-guide.md +566 -0
- package/template/docs/framework/setup/README.md +548 -0
- package/template/host/e2e/auth.spec.ts +38 -0
- package/template/host/e2e/layout.spec.ts +38 -0
- package/template/host/modern.config.ts +19 -0
- package/template/host/package.json +71 -0
- package/template/host/playwright.config.ts +34 -0
- package/template/host/postcss.config.mjs +6 -0
- package/template/host/src/App.tsx +6 -0
- package/template/host/src/bootstrap.tsx +74 -0
- package/template/host/src/global.css +59 -0
- package/template/host/src/index.ts +2 -0
- package/template/host/src/kernel/__tests__/lib-utils.test.ts +32 -0
- package/template/host/src/kernel/__tests__/rbac-hooks.test.tsx +114 -0
- package/template/host/src/kernel/__tests__/rbac-utils.test.ts +108 -0
- package/template/host/src/kernel/auth/ProtectedRoute.tsx +41 -0
- package/template/host/src/kernel/auth/components/LoginForm.tsx +97 -0
- package/template/host/src/kernel/auth/components/LogoutButton.tsx +79 -0
- package/template/host/src/kernel/auth/hooks.ts +174 -0
- package/template/host/src/kernel/auth/index.ts +5 -0
- package/template/host/src/kernel/auth/schemas.ts +27 -0
- package/template/host/src/kernel/auth/service.ts +197 -0
- package/template/host/src/kernel/auth/types.ts +36 -0
- package/template/host/src/kernel/channels/ChannelBus.ts +181 -0
- package/template/host/src/kernel/channels/ChannelProvider.tsx +57 -0
- package/template/host/src/kernel/channels/events.ts +27 -0
- package/template/host/src/kernel/channels/hooks.ts +168 -0
- package/template/host/src/kernel/channels/index.ts +6 -0
- package/template/host/src/kernel/channels/integrations/ToastIntegration.tsx +60 -0
- package/template/host/src/kernel/channels/plugin-hooks.ts +72 -0
- package/template/host/src/kernel/channels/types.ts +112 -0
- package/template/host/src/kernel/components/__tests__/Badge.test.tsx +35 -0
- package/template/host/src/kernel/components/__tests__/Button.test.tsx +63 -0
- package/template/host/src/kernel/components/__tests__/Input.test.tsx +64 -0
- package/template/host/src/kernel/components/index.ts +32 -0
- package/template/host/src/kernel/components/ui/alert.tsx +58 -0
- package/template/host/src/kernel/components/ui/avatar.tsx +47 -0
- package/template/host/src/kernel/components/ui/badge.tsx +35 -0
- package/template/host/src/kernel/components/ui/button.tsx +50 -0
- package/template/host/src/kernel/components/ui/card.tsx +78 -0
- package/template/host/src/kernel/components/ui/dialog.tsx +116 -0
- package/template/host/src/kernel/components/ui/dropdown-menu.tsx +192 -0
- package/template/host/src/kernel/components/ui/index.ts +7 -0
- package/template/host/src/kernel/components/ui/input.tsx +24 -0
- package/template/host/src/kernel/components/ui/label.tsx +21 -0
- package/template/host/src/kernel/components/ui/popover.tsx +28 -0
- package/template/host/src/kernel/components/ui/progress.tsx +25 -0
- package/template/host/src/kernel/components/ui/scroll-area.tsx +45 -0
- package/template/host/src/kernel/components/ui/select.tsx +155 -0
- package/template/host/src/kernel/components/ui/separator.tsx +28 -0
- package/template/host/src/kernel/components/ui/skeleton.tsx +15 -0
- package/template/host/src/kernel/components/ui/switch.tsx +26 -0
- package/template/host/src/kernel/components/ui/table.tsx +116 -0
- package/template/host/src/kernel/components/ui/tabs.tsx +52 -0
- package/template/host/src/kernel/components/ui/toast.tsx +126 -0
- package/template/host/src/kernel/components/ui/toaster.tsx +34 -0
- package/template/host/src/kernel/components/ui/tooltip.tsx +27 -0
- package/template/host/src/kernel/components/ui/use-toast.ts +183 -0
- package/template/host/src/kernel/index.ts +48 -0
- package/template/host/src/kernel/lib/cn.ts +1 -0
- package/template/host/src/kernel/lib/utils.ts +36 -0
- package/template/host/src/kernel/plugins/Slot.tsx +41 -0
- package/template/host/src/kernel/plugins/SlotProvider.tsx +88 -0
- package/template/host/src/kernel/plugins/index.ts +23 -0
- package/template/host/src/kernel/plugins/loader.ts +122 -0
- package/template/host/src/kernel/plugins/schemas.ts +54 -0
- package/template/host/src/kernel/plugins/store.ts +185 -0
- package/template/host/src/kernel/plugins/types.ts +103 -0
- package/template/host/src/kernel/providers/PocketBaseProvider.tsx +70 -0
- package/template/host/src/kernel/providers/QueryProvider.tsx +28 -0
- package/template/host/src/kernel/providers/ThemeProvider.tsx +25 -0
- package/template/host/src/kernel/providers/index.ts +3 -0
- package/template/host/src/kernel/rbac/components/OrganizationSelector.tsx +69 -0
- package/template/host/src/kernel/rbac/components/PermissionGate.tsx +43 -0
- package/template/host/src/kernel/rbac/hooks.ts +379 -0
- package/template/host/src/kernel/rbac/index.ts +6 -0
- package/template/host/src/kernel/rbac/service.ts +504 -0
- package/template/host/src/kernel/rbac/types.ts +164 -0
- package/template/host/src/kernel/rbac/utils.ts +34 -0
- package/template/host/src/kernel/shared-state/bridge.ts +31 -0
- package/template/host/src/kernel/shared-state/index.ts +3 -0
- package/template/host/src/kernel/shared-state/store.ts +62 -0
- package/template/host/src/kernel/shared-state/types.ts +60 -0
- package/template/host/src/kernel/use-migrations.ts +72 -0
- package/template/host/src/layout/MobileMenu.tsx +61 -0
- package/template/host/src/layout/Shell.tsx +42 -0
- package/template/host/src/layout/Sidebar.tsx +178 -0
- package/template/host/src/layout/Topbar.tsx +50 -0
- package/template/host/src/layout/index.ts +4 -0
- package/template/host/src/lib/pocketbase/client.ts +38 -0
- package/template/host/src/lib/pocketbase/collections/audit_logs.ts +87 -0
- package/template/host/src/lib/pocketbase/collections/index.ts +19 -0
- package/template/host/src/lib/pocketbase/collections/organizations.ts +63 -0
- package/template/host/src/lib/pocketbase/collections/permissions.ts +57 -0
- package/template/host/src/lib/pocketbase/collections/roles.ts +55 -0
- package/template/host/src/lib/pocketbase/collections/todos.ts +74 -0
- package/template/host/src/lib/pocketbase/collections/user_roles.ts +57 -0
- package/template/host/src/lib/pocketbase/collections/users.ts +43 -0
- package/template/host/src/lib/pocketbase/index.ts +5 -0
- package/template/host/src/lib/pocketbase/migrations.ts +44 -0
- package/template/host/src/lib/pocketbase/seed/permissions.ts +8 -0
- package/template/host/src/lib/pocketbase/seed/roles.ts +22 -0
- package/template/host/src/lib/pocketbase/seed.ts +113 -0
- package/template/host/src/lib/pocketbase/types.ts +102 -0
- package/template/host/src/modern.runtime.ts +26 -0
- package/template/host/src/plugins.d.ts +9 -0
- package/template/host/src/providers/PocketBaseProvider.tsx +30 -0
- package/template/host/src/routes/_.tsx +6 -0
- package/template/host/src/routes/dashboard._.tsx +41 -0
- package/template/host/src/routes/index.tsx +93 -0
- package/template/host/src/routes/login.tsx +36 -0
- package/template/host/src/saas.config.ts +52 -0
- package/template/host/src/test/setup.ts +65 -0
- package/template/host/src/test/utils.tsx +69 -0
- package/template/host/src/test/vitest-globals.d.ts +19 -0
- package/template/host/src/vite-env.d.ts +16 -0
- package/template/host/tailwind.config.ts +77 -0
- package/template/host/tsconfig.json +19 -0
- package/template/host/vitest.config.ts +30 -0
- package/template/nginx.conf +72 -0
- package/template/package.json +44 -0
- package/template/packages/plugins/@lego/plugin-dashboard/modern.config.ts +19 -0
- package/template/packages/plugins/@lego/plugin-dashboard/package.json +35 -0
- package/template/packages/plugins/@lego/plugin-dashboard/postcss.config.mjs +6 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/App.tsx +27 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/components/ActivityFeed.tsx +63 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/components/QuickActionSlot.tsx +11 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/components/QuickActions.tsx +68 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/components/SidebarWidget.tsx +35 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/components/StatCard.tsx +47 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/global.css +24 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/useChannelIntegration.ts +43 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/useDashboardStats.ts +65 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/usePocketBase.ts +47 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/hooks/useRecentActivity.ts +55 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/lib/utils.ts +6 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/pages/DashboardPage.tsx +105 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/plugin.config.ts +121 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/plugin.ts +18 -0
- package/template/packages/plugins/@lego/plugin-dashboard/src/vite-env.d.ts +32 -0
- package/template/packages/plugins/@lego/plugin-dashboard/tailwind.config.ts +35 -0
- package/template/packages/plugins/@lego/plugin-dashboard/tsconfig.json +18 -0
- package/template/packages/plugins/@lego/plugin-todo/modern.config.ts +18 -0
- package/template/packages/plugins/@lego/plugin-todo/package.json +41 -0
- package/template/packages/plugins/@lego/plugin-todo/postcss.config.mjs +6 -0
- package/template/packages/plugins/@lego/plugin-todo/src/App.tsx +12 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/SidebarWidget.tsx +16 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/TodoDialog.tsx +55 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/TodoFilters.tsx +79 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/TodoForm.tsx +94 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/TodoItem.tsx +121 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/TodoList.tsx +41 -0
- package/template/packages/plugins/@lego/plugin-todo/src/components/index.ts +6 -0
- package/template/packages/plugins/@lego/plugin-todo/src/global.css +59 -0
- package/template/packages/plugins/@lego/plugin-todo/src/hooks/useCreateTodo.ts +62 -0
- package/template/packages/plugins/@lego/plugin-todo/src/hooks/useDeleteTodo.ts +46 -0
- package/template/packages/plugins/@lego/plugin-todo/src/hooks/usePocketBase.ts +38 -0
- package/template/packages/plugins/@lego/plugin-todo/src/hooks/useTodos.ts +64 -0
- package/template/packages/plugins/@lego/plugin-todo/src/hooks/useUpdateTodo.ts +35 -0
- package/template/packages/plugins/@lego/plugin-todo/src/index.tsx +5 -0
- package/template/packages/plugins/@lego/plugin-todo/src/lib/utils.ts +20 -0
- package/template/packages/plugins/@lego/plugin-todo/src/pages/TodoPage.tsx +89 -0
- package/template/packages/plugins/@lego/plugin-todo/src/plugin.config.ts +104 -0
- package/template/packages/plugins/@lego/plugin-todo/src/plugin.ts +13 -0
- package/template/packages/plugins/@lego/plugin-todo/src/schemas.ts +37 -0
- package/template/packages/plugins/@lego/plugin-todo/src/types.ts +42 -0
- package/template/packages/plugins/@lego/plugin-todo/src/vite-env.d.ts +31 -0
- package/template/packages/plugins/@lego/plugin-todo/tailwind.config.ts +51 -0
- package/template/packages/plugins/@lego/plugin-todo/tsconfig.json +18 -0
- package/template/pnpm-workspace.yaml +4 -0
- package/template/pocketbase/CHANGELOG.md +911 -0
- package/template/pocketbase/LICENSE.md +17 -0
- package/template/scripts/create-plugin.js +221 -0
- package/template/scripts/deploy.sh +56 -0
- package/template/tsconfig.base.json +26 -0
- package/template/tsconfig.json +8 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "host",
|
|
3
|
+
"version": "2.0.13",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "modern dev",
|
|
8
|
+
"build": "modern build",
|
|
9
|
+
"start": "modern start",
|
|
10
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"test": "vitest",
|
|
13
|
+
"test:ui": "vitest --ui",
|
|
14
|
+
"test:coverage": "vitest --coverage",
|
|
15
|
+
"test:e2e": "playwright test",
|
|
16
|
+
"test:e2e:ui": "playwright test --ui",
|
|
17
|
+
"test:e2e:debug": "playwright test --debug"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@garfish/hooks": "^1.19.0",
|
|
21
|
+
"@hookform/resolvers": "^3.9.0",
|
|
22
|
+
"@modern-js/runtime": "^2.60.0",
|
|
23
|
+
"@radix-ui/react-avatar": "^1.1.11",
|
|
24
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
25
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
26
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
27
|
+
"@radix-ui/react-progress": "^1.1.8",
|
|
28
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
29
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
30
|
+
"@radix-ui/react-separator": "^1.1.8",
|
|
31
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
32
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
33
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
34
|
+
"@radix-ui/react-toast": "^1.2.15",
|
|
35
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
36
|
+
"@tanstack/react-query": "^5.59.0",
|
|
37
|
+
"@tanstack/react-query-devtools": "^5.91.2",
|
|
38
|
+
"garfish": "^1.19.0",
|
|
39
|
+
"lucide-react": "^0.454.0",
|
|
40
|
+
"pocketbase": "^0.21.5",
|
|
41
|
+
"react": "^18.3.1",
|
|
42
|
+
"react-dom": "^18.3.1",
|
|
43
|
+
"react-hook-form": "^7.53.0",
|
|
44
|
+
"tailwindcss-animate": "^1.0.7",
|
|
45
|
+
"zod": "^3.22.0",
|
|
46
|
+
"zustand": "^5.0.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@modern-js/app-tools": "^2.60.0",
|
|
50
|
+
"@modern-js/plugin-garfish": "^2.60.0",
|
|
51
|
+
"@modern-js/tsconfig": "^2.60.0",
|
|
52
|
+
"@playwright/test": "^1.58.0",
|
|
53
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
54
|
+
"@testing-library/react": "^16.3.2",
|
|
55
|
+
"@testing-library/user-event": "^14.6.1",
|
|
56
|
+
"@types/react": "^18.3.12",
|
|
57
|
+
"@types/react-dom": "^18.3.1",
|
|
58
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
59
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
60
|
+
"@vitest/ui": "^4.0.18",
|
|
61
|
+
"autoprefixer": "^10.4.20",
|
|
62
|
+
"class-variance-authority": "^0.7.0",
|
|
63
|
+
"clsx": "^2.1.1",
|
|
64
|
+
"jsdom": "^27.4.0",
|
|
65
|
+
"postcss": "^8.4.49",
|
|
66
|
+
"tailwind-merge": "^2.5.4",
|
|
67
|
+
"tailwindcss": "^3.4.15",
|
|
68
|
+
"typescript": "^5.6.3",
|
|
69
|
+
"vitest": "^4.0.18"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
testDir: './e2e',
|
|
5
|
+
fullyParallel: true,
|
|
6
|
+
forbidOnly: !!process.env.CI,
|
|
7
|
+
retries: process.env.CI ? 2 : 0,
|
|
8
|
+
workers: process.env.CI ? 1 : undefined,
|
|
9
|
+
reporter: 'html',
|
|
10
|
+
use: {
|
|
11
|
+
baseURL: 'http://localhost:8080',
|
|
12
|
+
trace: 'on-first-retry',
|
|
13
|
+
},
|
|
14
|
+
projects: [
|
|
15
|
+
{
|
|
16
|
+
name: 'chromium',
|
|
17
|
+
use: { ...devices['Desktop Chrome'] },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'firefox',
|
|
21
|
+
use: { ...devices['Desktop Firefox'] },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'webkit',
|
|
25
|
+
use: { ...devices['Desktop Safari'] },
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
webServer: {
|
|
29
|
+
command: 'pnpm run dev',
|
|
30
|
+
url: 'http://localhost:8080',
|
|
31
|
+
reuseExistingServer: !process.env.CI,
|
|
32
|
+
timeout: 120000,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { BrowserRouter } from '@modern-js/runtime/router';
|
|
4
|
+
import App from './App';
|
|
5
|
+
import { registerSharedState } from './kernel/shared-state';
|
|
6
|
+
import { PocketBaseProvider } from './kernel/providers';
|
|
7
|
+
import { QueryProvider } from './kernel/providers';
|
|
8
|
+
import { ThemeProvider } from './kernel/providers';
|
|
9
|
+
import { Toaster } from './kernel/components/ui/toaster';
|
|
10
|
+
import { ChannelProvider, initializeChannelBus } from './kernel/channels';
|
|
11
|
+
import { SlotProvider, initializePluginLoader, usePluginStore } from './kernel/plugins';
|
|
12
|
+
import { saasConfig } from './saas.config';
|
|
13
|
+
import Garfish from 'garfish';
|
|
14
|
+
|
|
15
|
+
// Register shared state bridge for plugins
|
|
16
|
+
registerSharedState();
|
|
17
|
+
|
|
18
|
+
// Initialize Garfish channel bus
|
|
19
|
+
initializeChannelBus(Garfish);
|
|
20
|
+
|
|
21
|
+
// Initialize plugin loader
|
|
22
|
+
initializePluginLoader(Garfish);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Initialize plugins from SaaS config
|
|
26
|
+
*/
|
|
27
|
+
async function initializePlugins() {
|
|
28
|
+
const store = usePluginStore.getState();
|
|
29
|
+
|
|
30
|
+
// Initialize plugins from config
|
|
31
|
+
for (const plugin of saasConfig.plugins) {
|
|
32
|
+
const pluginName = plugin.name.split('/').pop() || plugin.name;
|
|
33
|
+
|
|
34
|
+
store.registerPlugin({
|
|
35
|
+
manifest: {
|
|
36
|
+
name: plugin.name,
|
|
37
|
+
version: '1.0.0',
|
|
38
|
+
displayName: pluginName.charAt(0).toUpperCase() + pluginName.slice(1),
|
|
39
|
+
description: `${pluginName} plugin`,
|
|
40
|
+
},
|
|
41
|
+
enabled: plugin.enabled,
|
|
42
|
+
slots: [],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log('[Bootstrap] Plugins initialized from config');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Create root
|
|
50
|
+
const container = document.getElementById('root');
|
|
51
|
+
if (container) {
|
|
52
|
+
const root = createRoot(container);
|
|
53
|
+
|
|
54
|
+
// Initialize plugins
|
|
55
|
+
initializePlugins();
|
|
56
|
+
|
|
57
|
+
root.render(
|
|
58
|
+
<StrictMode>
|
|
59
|
+
<BrowserRouter>
|
|
60
|
+
<ThemeProvider>
|
|
61
|
+
<QueryProvider>
|
|
62
|
+
<PocketBaseProvider>
|
|
63
|
+
<SlotProvider>
|
|
64
|
+
<ChannelProvider />
|
|
65
|
+
<App />
|
|
66
|
+
<Toaster />
|
|
67
|
+
</SlotProvider>
|
|
68
|
+
</PocketBaseProvider>
|
|
69
|
+
</QueryProvider>
|
|
70
|
+
</ThemeProvider>
|
|
71
|
+
</BrowserRouter>
|
|
72
|
+
</StrictMode>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
@layer base {
|
|
6
|
+
:root {
|
|
7
|
+
--background: 0 0% 100%;
|
|
8
|
+
--foreground: 222.2 84% 4.9%;
|
|
9
|
+
--card: 0 0% 100%;
|
|
10
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
11
|
+
--popover: 0 0% 100%;
|
|
12
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
13
|
+
--primary: 221.2 83.2% 53.3%;
|
|
14
|
+
--primary-foreground: 210 40% 98%;
|
|
15
|
+
--secondary: 210 40% 96.1%;
|
|
16
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
17
|
+
--muted: 210 40% 96.1%;
|
|
18
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
19
|
+
--accent: 210 40% 96.1%;
|
|
20
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
21
|
+
--destructive: 0 84.2% 60.2%;
|
|
22
|
+
--destructive-foreground: 210 40% 98%;
|
|
23
|
+
--border: 214.3 31.8% 91.4%;
|
|
24
|
+
--input: 214.3 31.8% 91.4%;
|
|
25
|
+
--ring: 221.2 83.2% 53.3%;
|
|
26
|
+
--radius: 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.dark {
|
|
30
|
+
--background: 222.2 84% 4.9%;
|
|
31
|
+
--foreground: 210 40% 98%;
|
|
32
|
+
--card: 222.2 84% 4.9%;
|
|
33
|
+
--card-foreground: 210 40% 98%;
|
|
34
|
+
--popover: 222.2 84% 4.9%;
|
|
35
|
+
--popover-foreground: 210 40% 98%;
|
|
36
|
+
--primary: 217.2 91.2% 59.8%;
|
|
37
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
38
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
39
|
+
--secondary-foreground: 210 40% 98%;
|
|
40
|
+
--muted: 217.2 32.6% 17.5%;
|
|
41
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
42
|
+
--accent: 217.2 32.6% 17.5%;
|
|
43
|
+
--accent-foreground: 210 40% 98%;
|
|
44
|
+
--destructive: 0 62.8% 30.6%;
|
|
45
|
+
--destructive-foreground: 210 40% 98%;
|
|
46
|
+
--border: 217.2 32.6% 17.5%;
|
|
47
|
+
--input: 217.2 32.6% 17.5%;
|
|
48
|
+
--ring: 224.3 76.3% 48%;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@layer base {
|
|
53
|
+
* {
|
|
54
|
+
@apply border-border;
|
|
55
|
+
}
|
|
56
|
+
body {
|
|
57
|
+
@apply bg-background text-foreground;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { cn } from '../lib/utils';
|
|
3
|
+
|
|
4
|
+
describe('cn utility function', () => {
|
|
5
|
+
it('should merge class names correctly', () => {
|
|
6
|
+
expect(cn('foo', 'bar')).toBe('foo bar');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('should handle conditional classes', () => {
|
|
10
|
+
expect(cn('foo', false && 'bar', 'baz')).toBe('foo baz');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should handle undefined and null values', () => {
|
|
14
|
+
expect(cn('foo', undefined, null, 'bar')).toBe('foo bar');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should handle Tailwind conflict resolution', () => {
|
|
18
|
+
expect(cn('p-4', 'p-2')).toBe('p-2');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should handle empty input', () => {
|
|
22
|
+
expect(cn()).toBe('');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should handle arrays of classes', () => {
|
|
26
|
+
expect(cn(['foo', 'bar'], 'baz')).toBe('foo bar baz');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should handle objects with boolean values', () => {
|
|
30
|
+
expect(cn({ foo: true, bar: false, baz: true })).toBe('foo baz');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
2
|
+
import { renderHook, waitFor, act } from '@testing-library/react';
|
|
3
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
4
|
+
import {
|
|
5
|
+
useCurrentOrganization,
|
|
6
|
+
useRequirePermission,
|
|
7
|
+
useUserPermissions,
|
|
8
|
+
} from '../rbac/hooks';
|
|
9
|
+
import * as types from '../rbac/types';
|
|
10
|
+
import { useGlobalKernelState } from '../shared-state';
|
|
11
|
+
|
|
12
|
+
// Mock PocketBase
|
|
13
|
+
vi.mock('pocketbase', () => ({
|
|
14
|
+
default: vi.fn().mockImplementation(() => ({
|
|
15
|
+
collection: vi.fn(),
|
|
16
|
+
})),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
// Mock PocketBase provider
|
|
20
|
+
vi.mock('../providers/PocketBaseProvider', () => ({
|
|
21
|
+
PocketBaseProvider: ({ children }: { children: React.ReactNode }) => children,
|
|
22
|
+
usePocketBase: () => null,
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const mockPermissions: types.Permission[] = [
|
|
26
|
+
{ id: '1', resource: 'users' as const, action: 'read' as const, description: 'Read users' },
|
|
27
|
+
{ id: '2', resource: 'users' as const, action: 'write' as const, description: 'Write users' },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const createWrapper = (queryClient: QueryClient) => {
|
|
31
|
+
return ({ children }: { children: React.ReactNode }) => (
|
|
32
|
+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe('RBAC Hooks', () => {
|
|
37
|
+
let queryClient: QueryClient;
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
queryClient = new QueryClient({
|
|
41
|
+
defaultOptions: {
|
|
42
|
+
queries: { retry: false },
|
|
43
|
+
mutations: { retry: false },
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('useCurrentOrganization', () => {
|
|
49
|
+
it('should return current organization from state', () => {
|
|
50
|
+
const mockOrg: types.Organization = {
|
|
51
|
+
id: 'test-org',
|
|
52
|
+
name: 'Test Organization',
|
|
53
|
+
slug: 'test-org',
|
|
54
|
+
created: '2024-01-01',
|
|
55
|
+
updated: '2024-01-01',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const wrapper = createWrapper(queryClient);
|
|
59
|
+
const { result } = renderHook(() => useCurrentOrganization(), { wrapper });
|
|
60
|
+
|
|
61
|
+
// Initially null
|
|
62
|
+
expect(result.current.organization).toBeNull();
|
|
63
|
+
|
|
64
|
+
// Set organization via Zustand
|
|
65
|
+
act(() => {
|
|
66
|
+
useGlobalKernelState.getState().setOrganization(mockOrg);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Check that hook returns the organization
|
|
70
|
+
const { result: newResult } = renderHook(() => useCurrentOrganization(), { wrapper });
|
|
71
|
+
expect(newResult.current.organization).toEqual(mockOrg);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should clear query client when setting organization', () => {
|
|
75
|
+
const mockOrg: types.Organization = {
|
|
76
|
+
id: 'test-org',
|
|
77
|
+
name: 'Test Organization',
|
|
78
|
+
slug: 'test-org',
|
|
79
|
+
created: '2024-01-01',
|
|
80
|
+
updated: '2024-01-01',
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const clearSpy = vi.spyOn(queryClient, 'clear');
|
|
84
|
+
|
|
85
|
+
const wrapper = createWrapper(queryClient);
|
|
86
|
+
const { result } = renderHook(() => useCurrentOrganization(), { wrapper });
|
|
87
|
+
|
|
88
|
+
act(() => {
|
|
89
|
+
result.current.setCurrentOrganization(mockOrg);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(clearSpy).toHaveBeenCalled();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('useUserPermissions', () => {
|
|
97
|
+
it('should return undefined when not authenticated', () => {
|
|
98
|
+
const wrapper = createWrapper(queryClient);
|
|
99
|
+
const { result } = renderHook(() => useUserPermissions(), { wrapper });
|
|
100
|
+
|
|
101
|
+
// Service is not available (usePocketBase returns null)
|
|
102
|
+
// Query is disabled, so data is undefined
|
|
103
|
+
expect(result.current.data).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should not be enabled when user is null', () => {
|
|
107
|
+
const wrapper = createWrapper(queryClient);
|
|
108
|
+
const { result } = renderHook(() => useUserPermissions(), { wrapper });
|
|
109
|
+
|
|
110
|
+
// With no user, the hook should not be enabled
|
|
111
|
+
expect(result.current.isLoading).toBe(false);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { initializeFirstOrganization } from '../rbac/utils';
|
|
3
|
+
|
|
4
|
+
describe('RBAC Utils', () => {
|
|
5
|
+
describe('initializeFirstOrganization', () => {
|
|
6
|
+
it('should return existing organization if user has one', async () => {
|
|
7
|
+
const mockPb = {
|
|
8
|
+
collection: vi.fn().mockReturnValue({
|
|
9
|
+
getOne: vi.fn().mockResolvedValue({
|
|
10
|
+
expand: {
|
|
11
|
+
organizations: [
|
|
12
|
+
{ id: 'existing-org', name: 'Existing Org', slug: 'existing' },
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const result = await initializeFirstOrganization(mockPb, 'user-123');
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({
|
|
22
|
+
id: 'existing-org',
|
|
23
|
+
name: 'Existing Org',
|
|
24
|
+
slug: 'existing',
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should create new organization if user has none', async () => {
|
|
29
|
+
const mockPb = {
|
|
30
|
+
collection: vi.fn((name: string) => {
|
|
31
|
+
if (name === 'users') {
|
|
32
|
+
return {
|
|
33
|
+
getOne: vi.fn().mockResolvedValue({
|
|
34
|
+
name: 'Test User',
|
|
35
|
+
email: 'test@example.com',
|
|
36
|
+
expand: { organizations: [] },
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (name === 'organizations') {
|
|
41
|
+
return {
|
|
42
|
+
create: vi.fn().mockResolvedValue({
|
|
43
|
+
id: 'new-org',
|
|
44
|
+
name: "Test User's Organization",
|
|
45
|
+
slug: 'test-123456',
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {};
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const result = await initializeFirstOrganization(mockPb, 'user-123');
|
|
54
|
+
|
|
55
|
+
expect(result).toEqual({
|
|
56
|
+
id: 'new-org',
|
|
57
|
+
name: "Test User's Organization",
|
|
58
|
+
slug: 'test-123456',
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should return null on error', async () => {
|
|
63
|
+
const mockPb = {
|
|
64
|
+
collection: vi.fn().mockReturnValue({
|
|
65
|
+
getOne: vi.fn().mockRejectedValue(new Error('DB error')),
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const result = await initializeFirstOrganization(mockPb, 'user-123');
|
|
70
|
+
|
|
71
|
+
expect(result).toBeNull();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should handle user without email gracefully', async () => {
|
|
75
|
+
const mockPb = {
|
|
76
|
+
collection: vi.fn((name: string) => {
|
|
77
|
+
if (name === 'users') {
|
|
78
|
+
return {
|
|
79
|
+
getOne: vi.fn().mockResolvedValue({
|
|
80
|
+
name: null,
|
|
81
|
+
email: null,
|
|
82
|
+
expand: { organizations: [] },
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (name === 'organizations') {
|
|
87
|
+
return {
|
|
88
|
+
create: vi.fn().mockResolvedValue({
|
|
89
|
+
id: 'new-org',
|
|
90
|
+
name: "User's Organization",
|
|
91
|
+
slug: 'user-123456',
|
|
92
|
+
}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {};
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const result = await initializeFirstOrganization(mockPb, 'user-123');
|
|
100
|
+
|
|
101
|
+
expect(result).toEqual({
|
|
102
|
+
id: 'new-org',
|
|
103
|
+
name: "User's Organization",
|
|
104
|
+
slug: 'user-123456',
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useNavigate } from '@modern-js/runtime/router';
|
|
3
|
+
import { useRequireAuth } from './hooks';
|
|
4
|
+
import { Skeleton } from '../components/ui/skeleton';
|
|
5
|
+
|
|
6
|
+
interface ProtectedRouteProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
redirectTo?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ProtectedRoute({
|
|
12
|
+
children,
|
|
13
|
+
redirectTo = '/login',
|
|
14
|
+
}: ProtectedRouteProps) {
|
|
15
|
+
const { isAuthenticated, isLoading, shouldRedirect } = useRequireAuth();
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (shouldRedirect) {
|
|
20
|
+
navigate(redirectTo);
|
|
21
|
+
}
|
|
22
|
+
}, [shouldRedirect, navigate, redirectTo]);
|
|
23
|
+
|
|
24
|
+
if (isLoading) {
|
|
25
|
+
return (
|
|
26
|
+
<div className="flex min-h-[400px] items-center justify-center">
|
|
27
|
+
<div className="space-y-4 text-center">
|
|
28
|
+
<Skeleton className="mx-auto h-12 w-12 rounded-full" />
|
|
29
|
+
<Skeleton className="mx-auto h-4 w-48" />
|
|
30
|
+
<Skeleton className="mx-auto h-4 w-32" />
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!isAuthenticated) {
|
|
37
|
+
return null; // Will redirect
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return <>{children}</>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useNavigate } from '@modern-js/runtime/router';
|
|
3
|
+
import { useAuth } from '../hooks';
|
|
4
|
+
import { loginSchema, type LoginFormData } from '../schemas';
|
|
5
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
6
|
+
import { useForm } from 'react-hook-form';
|
|
7
|
+
import { Button } from '../../components/ui/button';
|
|
8
|
+
import { Input } from '../../components/ui/input';
|
|
9
|
+
import { Label } from '../../components/ui/label';
|
|
10
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../../components/ui/card';
|
|
11
|
+
import { Alert, AlertDescription } from '../../components/ui/alert';
|
|
12
|
+
import { Loader2 } from 'lucide-react';
|
|
13
|
+
|
|
14
|
+
export function LoginForm() {
|
|
15
|
+
const navigate = useNavigate();
|
|
16
|
+
const { login, isLoading, error } = useAuth();
|
|
17
|
+
const [submitError, setSubmitError] = useState<string | null>(null);
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
register,
|
|
21
|
+
handleSubmit,
|
|
22
|
+
formState: { errors },
|
|
23
|
+
} = useForm<LoginFormData>({
|
|
24
|
+
resolver: zodResolver(loginSchema),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const onSubmit = async (data: LoginFormData) => {
|
|
28
|
+
setSubmitError(null);
|
|
29
|
+
try {
|
|
30
|
+
await login(data);
|
|
31
|
+
navigate('/dashboard');
|
|
32
|
+
} catch (err: any) {
|
|
33
|
+
setSubmitError(err.message || 'Login failed. Please try again.');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Card className="w-full max-w-md">
|
|
39
|
+
<CardHeader>
|
|
40
|
+
<CardTitle className="text-2xl">Sign In</CardTitle>
|
|
41
|
+
<CardDescription>
|
|
42
|
+
Enter your credentials to access your account
|
|
43
|
+
</CardDescription>
|
|
44
|
+
</CardHeader>
|
|
45
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
46
|
+
<CardContent className="space-y-4">
|
|
47
|
+
{(submitError || error) && (
|
|
48
|
+
<Alert variant="destructive">
|
|
49
|
+
<AlertDescription>
|
|
50
|
+
{submitError || (error as any)?.message}
|
|
51
|
+
</AlertDescription>
|
|
52
|
+
</Alert>
|
|
53
|
+
)}
|
|
54
|
+
|
|
55
|
+
<div className="space-y-2">
|
|
56
|
+
<Label htmlFor="email">Email</Label>
|
|
57
|
+
<Input
|
|
58
|
+
id="email"
|
|
59
|
+
type="email"
|
|
60
|
+
placeholder="admin@example.com"
|
|
61
|
+
{...register('email')}
|
|
62
|
+
/>
|
|
63
|
+
{errors.email && (
|
|
64
|
+
<p className="text-sm text-destructive">{errors.email.message}</p>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div className="space-y-2">
|
|
69
|
+
<Label htmlFor="password">Password</Label>
|
|
70
|
+
<Input
|
|
71
|
+
id="password"
|
|
72
|
+
type="password"
|
|
73
|
+
placeholder="••••••••"
|
|
74
|
+
{...register('password')}
|
|
75
|
+
/>
|
|
76
|
+
{errors.password && (
|
|
77
|
+
<p className="text-sm text-destructive">{errors.password.message}</p>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
</CardContent>
|
|
81
|
+
|
|
82
|
+
<CardFooter>
|
|
83
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
84
|
+
{isLoading ? (
|
|
85
|
+
<>
|
|
86
|
+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
87
|
+
Signing in...
|
|
88
|
+
</>
|
|
89
|
+
) : (
|
|
90
|
+
'Sign In'
|
|
91
|
+
)}
|
|
92
|
+
</Button>
|
|
93
|
+
</CardFooter>
|
|
94
|
+
</form>
|
|
95
|
+
</Card>
|
|
96
|
+
);
|
|
97
|
+
}
|