create-ej-app 26.0.0 → 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -226
- package/cli.ts +79 -29
- package/package.json +2 -2
- package/template/api/.vscode/settings.json +1 -1
- package/template/api/{.github/copilot-instructions.md → AGENTS.md} +0 -2
- package/template/api/CLAUDE.md +1 -0
- package/template/api/package.json +10 -10
- package/template/nextjs/.dockerignore +1 -0
- package/template/nextjs/AGENTS.md +260 -0
- package/template/nextjs/CLAUDE.md +1 -0
- package/template/nextjs/README.md +109 -0
- package/template/nextjs/bunfig.toml +3 -0
- package/template/nextjs/eslint.config.mjs +6 -5
- package/template/nextjs/gitignore +6 -1
- package/template/nextjs/next.config.ts +8 -1
- package/template/nextjs/package.json +46 -39
- package/template/nextjs/public/logo-dark.svg +4 -0
- package/template/nextjs/public/logo.svg +4 -0
- package/template/nextjs/src/app/(admin)/actions/users.ts +183 -0
- package/template/nextjs/src/app/(admin)/admin/_components/admin-header.tsx +24 -0
- package/template/nextjs/src/app/(admin)/admin/_components/admin-search.tsx +16 -0
- package/template/nextjs/src/app/(admin)/admin/_components/admin-sidebar.tsx +42 -0
- package/template/nextjs/src/app/(admin)/admin/layout.tsx +53 -0
- package/template/nextjs/src/app/(admin)/admin/page.tsx +11 -2
- package/template/nextjs/src/app/(admin)/admin/settings/layout.tsx +24 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/[userId]/page.tsx +43 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/new/page.tsx +16 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/page.tsx +377 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/user-form.tsx +138 -0
- package/template/nextjs/src/app/(admin)/admin/settings/users/validation.ts +23 -0
- package/template/nextjs/src/app/(app)/app/layout.tsx +44 -0
- package/template/nextjs/src/app/(app)/app/page.tsx +14 -2
- package/template/nextjs/src/app/(auth)/(account)/layout.tsx +64 -0
- package/template/nextjs/src/app/(auth)/(account)/profile/page.tsx +16 -0
- package/template/nextjs/src/app/(auth)/(account)/profile/profile-form.tsx +247 -0
- package/template/nextjs/src/app/(auth)/login/email-login-form.tsx +56 -29
- package/template/nextjs/src/app/(auth)/login/page.tsx +45 -12
- package/template/nextjs/src/app/(auth)/login/social-login-buttons.tsx +85 -17
- package/template/nextjs/src/app/(marketing)/layout.tsx +35 -4
- package/template/nextjs/src/app/(marketing)/legal.tsx +56 -0
- package/template/nextjs/src/app/(marketing)/page.tsx +20 -2
- package/template/nextjs/src/app/(marketing)/privacy/page.tsx +43 -2
- package/template/nextjs/src/app/(marketing)/terms/page.tsx +33 -2
- package/template/nextjs/src/app/error.tsx +37 -0
- package/template/nextjs/src/app/fonts/geist-mono/GeistMono-Variable.woff2 +0 -0
- package/template/nextjs/src/app/fonts/geist-sans/Geist-Variable.woff2 +0 -0
- package/template/nextjs/src/app/fonts/index.ts +60 -0
- package/template/nextjs/src/app/global-error.tsx +38 -0
- package/template/nextjs/src/app/globals.css +29 -0
- package/template/nextjs/src/app/layout.tsx +45 -18
- package/template/nextjs/src/app/not-found.tsx +25 -3
- package/template/nextjs/src/app/robots.ts +29 -0
- package/template/nextjs/src/app/sitemap.ts +21 -0
- package/template/nextjs/src/components/confirm-dialog.tsx +79 -0
- package/template/nextjs/src/components/dashboard-header.tsx +70 -0
- package/template/nextjs/src/components/data-table/enum.ts +5 -0
- package/template/nextjs/src/components/data-table/features.ts +49 -0
- package/template/nextjs/src/components/data-table/index.tsx +961 -0
- package/template/nextjs/src/components/data-table/types.ts +76 -0
- package/template/nextjs/src/components/error.tsx +71 -0
- package/template/nextjs/src/components/loader.tsx +18 -2
- package/template/nextjs/src/components/logo.tsx +49 -0
- package/template/nextjs/src/components/navigation-search.tsx +140 -0
- package/template/nextjs/src/components/navigation-sidebar.tsx +241 -0
- package/template/nextjs/src/components/page-heading.tsx +38 -0
- package/template/nextjs/src/components/react-query-provider.tsx +41 -2
- package/template/nextjs/src/components/route-error.tsx +55 -0
- package/template/nextjs/src/components/screen-size.tsx +36 -0
- package/template/nextjs/src/components/site-footer.tsx +20 -4
- package/template/nextjs/src/components/theme-provider.tsx +48 -0
- package/template/nextjs/src/components/theme-toggle.tsx +58 -5
- package/template/nextjs/src/components/ui/alert-dialog.tsx +199 -0
- package/template/nextjs/src/components/ui/avatar.tsx +112 -0
- package/template/nextjs/src/components/ui/badge.tsx +54 -0
- package/template/nextjs/src/components/ui/button.tsx +3 -1
- package/template/nextjs/src/components/ui/card.tsx +4 -4
- package/template/nextjs/src/components/ui/collapsible.tsx +33 -0
- package/template/nextjs/src/components/ui/command.tsx +192 -0
- package/template/nextjs/src/components/ui/dialog.tsx +164 -0
- package/template/nextjs/src/components/ui/dropdown-menu.tsx +273 -0
- package/template/nextjs/src/components/ui/input-group.tsx +156 -0
- package/template/nextjs/src/components/ui/select.tsx +195 -0
- package/template/nextjs/src/components/ui/sheet.tsx +143 -0
- package/template/nextjs/src/components/ui/sidebar.tsx +702 -0
- package/template/nextjs/src/components/ui/skeleton.tsx +13 -0
- package/template/nextjs/src/components/ui/table.tsx +116 -0
- package/template/nextjs/src/components/ui/textarea.tsx +18 -0
- package/template/nextjs/src/components/ui/tooltip.tsx +57 -0
- package/template/nextjs/src/components/user-menu.tsx +206 -0
- package/template/nextjs/src/db/common.ts +10 -0
- package/template/nextjs/src/db/index.ts +16 -6
- package/template/nextjs/src/db/relations.ts +21 -0
- package/template/nextjs/src/db/schema.ts +85 -46
- package/template/nextjs/src/emails/components/email-layout.tsx +27 -11
- package/template/nextjs/src/emails/magic-link.tsx +15 -13
- package/template/nextjs/src/emails/test.tsx +11 -9
- package/template/nextjs/src/emails/welcome.tsx +12 -9
- package/template/nextjs/src/env.ts +1 -1
- package/template/nextjs/src/hooks/use-mobile.ts +14 -12
- package/template/nextjs/src/instrumentation.ts +20 -2
- package/template/nextjs/src/lib/actions.ts +55 -0
- package/template/nextjs/src/lib/admin-navigation.ts +43 -0
- package/template/nextjs/src/lib/auth-client.ts +20 -9
- package/template/nextjs/src/lib/auth-permissions.ts +61 -0
- package/template/nextjs/src/lib/auth.ts +33 -3
- package/template/nextjs/src/lib/callback-url.ts +28 -0
- package/template/nextjs/src/lib/constants.ts +21 -0
- package/template/nextjs/src/lib/delay.ts +10 -0
- package/template/nextjs/src/lib/email-service.ts +21 -0
- package/template/nextjs/src/lib/errors.ts +74 -0
- package/template/nextjs/src/lib/format-currency.ts +22 -24
- package/template/nextjs/src/lib/format-date.ts +69 -6
- package/template/nextjs/src/lib/nodemailer.ts +27 -3
- package/template/nextjs/src/lib/otel.ts +92 -2
- package/template/nextjs/src/lib/safe-action-client.ts +60 -9
- package/template/nextjs/src/lib/safe-action.ts +152 -16
- package/template/nextjs/src/lib/search.ts +16 -0
- package/template/nextjs/src/lib/seo.ts +7 -0
- package/template/nextjs/src/lib/siteConfig.ts +17 -1
- package/template/nextjs/src/lib/toast-message.ts +87 -1
- package/template/nextjs/src/lib/validations.ts +30 -0
- package/template/nextjs/src/proxy.ts +48 -0
- package/template/nextjs/src/scripts/reset-db.ts +22 -0
- package/template/nextjs/src/scripts/seed.ts +59 -8
- package/template/nextjs/src/scripts/test-mail.ts +28 -20
- package/template/nextjs/tests/admin/users.test.ts +64 -0
- package/template/nextjs/tests/db/fk-indexes.test.ts +62 -0
- package/template/nextjs/tests/db/seed.test.ts +49 -0
- package/template/nextjs/tests/helpers/action.ts +71 -0
- package/template/nextjs/tests/helpers/fixtures.ts +78 -0
- package/template/nextjs/tests/helpers/index.ts +2 -0
- package/template/nextjs/tests/lib/callback-url.test.ts +48 -0
- package/template/nextjs/tests/lib/client-server-boundary.test.ts +57 -0
- package/template/nextjs/tests/lib/errors.test.ts +10 -0
- package/template/nextjs/tests/lib/search.test.ts +23 -0
- package/template/nextjs/tests/setup/pglite-db.ts +63 -0
- package/template/nextjs/tests/setup/preload.ts +95 -0
- package/template/nextjs/tsconfig.json +1 -0
- package/template/saas-starter/.dockerignore +1 -0
- package/template/saas-starter/.env.example +15 -15
- package/template/saas-starter/AGENTS.md +302 -0
- package/template/saas-starter/CLAUDE.md +1 -0
- package/template/saas-starter/README.md +124 -2
- package/template/saas-starter/bunfig.toml +3 -0
- package/template/saas-starter/eslint.config.mjs +6 -5
- package/template/saas-starter/gitignore +6 -1
- package/template/saas-starter/next.config.ts +19 -1
- package/template/saas-starter/package.json +49 -44
- package/template/saas-starter/public/logo-dark.svg +4 -0
- package/template/saas-starter/public/logo.svg +4 -0
- package/template/saas-starter/src/app/(admin)/actions/contact-leads.ts +51 -0
- package/template/saas-starter/src/app/(admin)/actions/feedbacks.ts +91 -0
- package/template/saas-starter/src/app/(admin)/actions/users.ts +145 -59
- package/template/saas-starter/src/app/(admin)/admin/_components/admin-header.tsx +4 -1
- package/template/saas-starter/src/app/(admin)/admin/_components/admin-sidebar.tsx +12 -10
- package/template/saas-starter/src/app/(admin)/admin/contact-leads/page.tsx +123 -0
- package/template/saas-starter/src/app/(admin)/admin/feedbacks/page.tsx +161 -0
- package/template/saas-starter/src/app/(admin)/admin/layout.tsx +24 -28
- package/template/saas-starter/src/app/(admin)/admin/page.tsx +59 -2
- package/template/saas-starter/src/app/(admin)/admin/settings/layout.tsx +24 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/[userId]/page.tsx +43 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/new/page.tsx +16 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/page.tsx +372 -10
- package/template/saas-starter/src/app/(admin)/admin/settings/users/user-form.tsx +138 -0
- package/template/saas-starter/src/app/(admin)/admin/settings/users/validation.ts +23 -0
- package/template/saas-starter/src/app/(admin)/admin/support-tickets/[ticketId]/page.tsx +17 -0
- package/template/saas-starter/src/app/(admin)/admin/support-tickets/page.tsx +5 -0
- package/template/saas-starter/src/app/(app)/actions/billing.ts +171 -107
- package/template/saas-starter/src/app/(app)/actions/feedbacks.ts +28 -0
- package/template/saas-starter/src/app/(app)/actions/feedbacks.validation.ts +12 -0
- package/template/saas-starter/src/app/(app)/actions/members.ts +149 -123
- package/template/saas-starter/src/app/(app)/actions/organizations.ts +230 -0
- package/template/saas-starter/src/app/(app)/actions/organizations.validation.ts +17 -0
- package/template/saas-starter/src/app/(app)/app/[orgId]/dashboard/page.tsx +6 -9
- package/template/saas-starter/src/app/(app)/app/[orgId]/layout.tsx +6 -9
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/billing-email-form.tsx +45 -53
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/danger-zone.tsx +40 -47
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/general-settings-form.tsx +80 -105
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/_components/plans-section.tsx +72 -82
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/billing/page.tsx +51 -52
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/layout.tsx +24 -0
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/members/_components/invite-member-dialog.tsx +15 -16
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/members/_components/members-tabs.tsx +77 -44
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/members/page.tsx +11 -18
- package/template/saas-starter/src/app/(app)/app/[orgId]/settings/page.tsx +14 -28
- package/template/saas-starter/src/app/(app)/app/[orgId]/support-tickets/[ticketId]/page.tsx +25 -0
- package/template/saas-starter/src/app/(app)/app/[orgId]/support-tickets/page.tsx +25 -0
- package/template/saas-starter/src/app/(app)/app/_components/app-header.tsx +15 -13
- package/template/saas-starter/src/app/(app)/app/_components/app-search.tsx +15 -6
- package/template/saas-starter/src/app/(app)/app/_components/app-sidebar.tsx +6 -3
- package/template/saas-starter/src/app/(app)/app/_components/feedback-dialog.tsx +108 -0
- package/template/saas-starter/src/app/(app)/app/_components/organization-context.tsx +5 -9
- package/template/saas-starter/src/app/(app)/app/_components/organization-switcher.tsx +68 -8
- package/template/saas-starter/src/app/(app)/app/layout.tsx +44 -32
- package/template/saas-starter/src/app/(app)/app/onboarding/_components/create-organization-form.tsx +75 -87
- package/template/saas-starter/src/app/(app)/app/onboarding/page.tsx +10 -12
- package/template/saas-starter/src/app/(app)/app/page.tsx +16 -21
- package/template/saas-starter/src/app/(auth)/(account)/layout.tsx +64 -0
- package/template/saas-starter/src/app/(auth)/(account)/profile/page.tsx +16 -0
- package/template/saas-starter/src/app/(auth)/(account)/profile/profile-form.tsx +247 -0
- package/template/saas-starter/src/app/(auth)/(account)/support/[ticketId]/page.tsx +19 -0
- package/template/saas-starter/src/app/(auth)/(account)/support/page.tsx +9 -0
- package/template/saas-starter/src/app/(auth)/login/email-login-form.tsx +49 -27
- package/template/saas-starter/src/app/(auth)/login/page.tsx +39 -21
- package/template/saas-starter/src/app/(auth)/login/social-login-buttons.tsx +80 -18
- package/template/saas-starter/src/app/(invitation)/accept-invitation/[id]/accept-invitation-form.tsx +16 -10
- package/template/saas-starter/src/app/(invitation)/accept-invitation/[id]/page.tsx +28 -42
- package/template/saas-starter/src/app/(invitation)/actions/invitations.ts +32 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/actions.ts +23 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/contact-form.tsx +118 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/page.tsx +20 -0
- package/template/saas-starter/src/app/(marketing)/contact-us/validation.ts +22 -0
- package/template/saas-starter/src/app/(marketing)/layout.tsx +38 -4
- package/template/saas-starter/src/app/(marketing)/legal.tsx +66 -0
- package/template/saas-starter/src/app/(marketing)/page.tsx +23 -2
- package/template/saas-starter/src/app/(marketing)/privacy/page.tsx +62 -2
- package/template/saas-starter/src/app/(marketing)/terms/page.tsx +40 -2
- package/template/saas-starter/src/app/actions/support-tickets.ts +510 -0
- package/template/saas-starter/src/app/actions/support-tickets.validation.ts +112 -0
- package/template/saas-starter/src/app/actions/uploads.ts +36 -0
- package/template/saas-starter/src/app/actions/uploads.validation.ts +24 -0
- package/template/saas-starter/src/app/error.tsx +37 -0
- package/template/saas-starter/src/app/fonts/geist-mono/GeistMono-Variable.woff2 +0 -0
- package/template/saas-starter/src/app/fonts/geist-sans/Geist-Variable.woff2 +0 -0
- package/template/saas-starter/src/app/fonts/index.ts +60 -0
- package/template/saas-starter/src/app/global-error.tsx +38 -0
- package/template/saas-starter/src/app/globals.css +29 -0
- package/template/saas-starter/src/app/layout.tsx +43 -19
- package/template/saas-starter/src/app/not-found.tsx +25 -3
- package/template/saas-starter/src/app/robots.ts +14 -10
- package/template/saas-starter/src/app/sitemap.ts +2 -1
- package/template/saas-starter/src/components/confirm-dialog.tsx +79 -0
- package/template/saas-starter/src/components/dashboard-header.tsx +7 -1
- package/template/saas-starter/src/components/data-table/features.ts +49 -0
- package/template/saas-starter/src/components/data-table/index.tsx +65 -64
- package/template/saas-starter/src/components/data-table/types.ts +5 -4
- package/template/saas-starter/src/components/error.tsx +45 -0
- package/template/saas-starter/src/components/file-upload.tsx +65 -26
- package/template/saas-starter/src/components/loader.tsx +18 -2
- package/template/saas-starter/src/components/logo.tsx +49 -0
- package/template/saas-starter/src/components/navigation-search.tsx +2 -2
- package/template/saas-starter/src/components/page-heading.tsx +6 -0
- package/template/saas-starter/src/components/react-query-provider.tsx +41 -2
- package/template/saas-starter/src/components/route-error.tsx +55 -0
- package/template/saas-starter/src/components/screen-size.tsx +36 -0
- package/template/saas-starter/src/components/site-footer.tsx +20 -4
- package/template/saas-starter/src/components/support/create-support-ticket-dialog.tsx +122 -0
- package/template/saas-starter/src/components/support/support-ticket-conversation.tsx +236 -0
- package/template/saas-starter/src/components/support/support-ticket-shared.tsx +58 -0
- package/template/saas-starter/src/components/support/support-tickets-table.tsx +281 -0
- package/template/saas-starter/src/components/theme-provider.tsx +48 -0
- package/template/saas-starter/src/components/theme-toggle.tsx +58 -5
- package/template/saas-starter/src/components/ui/alert-dialog.tsx +199 -0
- package/template/saas-starter/src/components/ui/badge.tsx +6 -1
- package/template/saas-starter/src/components/ui/button.tsx +2 -0
- package/template/saas-starter/src/components/ui/command.tsx +1 -1
- package/template/saas-starter/src/components/user-menu.tsx +147 -24
- package/template/saas-starter/src/db/common.ts +33 -1
- package/template/saas-starter/src/db/enums.ts +24 -0
- package/template/saas-starter/src/db/index.ts +14 -5
- package/template/saas-starter/src/db/relations.ts +40 -3
- package/template/saas-starter/src/db/schema.ts +186 -35
- package/template/saas-starter/src/emails/components/email-layout.tsx +27 -11
- package/template/saas-starter/src/emails/invitation.tsx +34 -21
- package/template/saas-starter/src/emails/magic-link.tsx +15 -13
- package/template/saas-starter/src/emails/test.tsx +11 -9
- package/template/saas-starter/src/emails/welcome.tsx +12 -9
- package/template/saas-starter/src/env.ts +1 -1
- package/template/saas-starter/src/hooks/use-mobile.ts +14 -12
- package/template/saas-starter/src/instrumentation.ts +20 -2
- package/template/saas-starter/src/lib/actions.ts +34 -0
- package/template/saas-starter/src/lib/admin-navigation.ts +33 -1
- package/template/saas-starter/src/lib/app-navigation.ts +45 -41
- package/template/saas-starter/src/lib/auth-client.ts +8 -3
- package/template/saas-starter/src/lib/auth-permissions.ts +50 -11
- package/template/saas-starter/src/lib/auth.ts +122 -21
- package/template/saas-starter/src/lib/billing.ts +59 -24
- package/template/saas-starter/src/lib/callback-url.ts +28 -0
- package/template/saas-starter/src/lib/constants.ts +78 -9
- package/template/saas-starter/src/lib/delay.ts +10 -0
- package/template/saas-starter/src/lib/email-service.ts +30 -1
- package/template/saas-starter/src/lib/errors.ts +74 -0
- package/template/saas-starter/src/lib/format-currency.ts +22 -24
- package/template/saas-starter/src/lib/format-date.ts +69 -6
- package/template/saas-starter/src/lib/image-url.ts +54 -0
- package/template/saas-starter/src/lib/nodemailer.ts +27 -3
- package/template/saas-starter/src/lib/organization-access.ts +56 -76
- package/template/saas-starter/src/lib/otel.ts +92 -2
- package/template/saas-starter/src/lib/plan-limits.ts +37 -0
- package/template/saas-starter/src/lib/plans.ts +40 -13
- package/template/saas-starter/src/lib/rbac.ts +44 -0
- package/template/saas-starter/src/lib/safe-action-client.ts +60 -9
- package/template/saas-starter/src/lib/safe-action.ts +137 -17
- package/template/saas-starter/src/lib/search.ts +16 -0
- package/template/saas-starter/src/lib/seo.ts +7 -0
- package/template/saas-starter/src/lib/siteConfig.ts +17 -1
- package/template/saas-starter/src/lib/storage.ts +176 -46
- package/template/saas-starter/src/lib/stripe.ts +4 -1
- package/template/saas-starter/src/lib/toast-message.ts +87 -1
- package/template/saas-starter/src/lib/validations.ts +85 -2
- package/template/saas-starter/src/proxy.ts +48 -0
- package/template/saas-starter/src/scripts/cleanup-temp-uploads.ts +24 -0
- package/template/saas-starter/src/scripts/seed.ts +82 -8
- package/template/saas-starter/src/scripts/setup-db.ts +72 -0
- package/template/saas-starter/src/scripts/setup-stripe-plans.ts +13 -7
- package/template/saas-starter/src/scripts/test-mail.ts +28 -20
- package/template/saas-starter/tests/admin/users.test.ts +64 -0
- package/template/saas-starter/tests/db/fk-indexes.test.ts +62 -0
- package/template/saas-starter/tests/db/seed.test.ts +57 -0
- package/template/saas-starter/tests/helpers/action.ts +71 -0
- package/template/saas-starter/tests/helpers/fixtures.ts +151 -0
- package/template/saas-starter/tests/helpers/index.ts +2 -0
- package/template/saas-starter/tests/lib/callback-url.test.ts +48 -0
- package/template/saas-starter/tests/lib/client-server-boundary.test.ts +57 -0
- package/template/saas-starter/tests/lib/errors.test.ts +10 -0
- package/template/saas-starter/tests/lib/image-url.test.ts +31 -0
- package/template/saas-starter/tests/lib/search.test.ts +23 -0
- package/template/saas-starter/tests/marketing/contact-and-feedback.test.ts +86 -0
- package/template/saas-starter/tests/organizations/organizations.test.ts +175 -0
- package/template/saas-starter/tests/setup/pglite-db.ts +67 -0
- package/template/saas-starter/tests/setup/preload.ts +108 -0
- package/template/saas-starter/tests/support/support-tickets.test.ts +145 -0
- package/template/saas-starter/tsconfig.json +1 -0
- package/cli.js +0 -147
- package/template/nextjs/src/app/(admin)/layout.tsx +0 -20
- package/template/nextjs/src/app/(app)/layout.tsx +0 -20
- package/template/nextjs/terraform/artifact-registry.tf +0 -5
- package/template/nextjs/terraform/backend-service.tf +0 -13
- package/template/nextjs/terraform/cleanup.sh +0 -9
- package/template/nextjs/terraform/cloudbuild.tf +0 -70
- package/template/nextjs/terraform/cloudrun.tf +0 -68
- package/template/nextjs/terraform/database.tf +0 -60
- package/template/nextjs/terraform/forwarding-rule.tf +0 -43
- package/template/nextjs/terraform/gitignore +0 -4
- package/template/nextjs/terraform/ip-address.tf +0 -11
- package/template/nextjs/terraform/network-endpoint-group.tf +0 -11
- package/template/nextjs/terraform/network.tf +0 -21
- package/template/nextjs/terraform/pre.sh +0 -3
- package/template/nextjs/terraform/providers.tf +0 -18
- package/template/nextjs/terraform/secret.txt +0 -11
- package/template/nextjs/terraform/setup.sh +0 -25
- package/template/nextjs/terraform/ssl-certs.tf +0 -32
- package/template/nextjs/terraform/target-https-proxy copy.tf +0 -14
- package/template/nextjs/terraform/target-https-proxy.tf +0 -14
- package/template/nextjs/terraform/terraform.tfvars +0 -4
- package/template/nextjs/terraform/url-map.tf +0 -23
- package/template/nextjs/terraform/variables.tf +0 -21
- package/template/saas-starter/next-env.d.ts +0 -6
- package/template/saas-starter/src/actions/uploads.ts +0 -28
- package/template/saas-starter/src/actions/uploads.validation.ts +0 -14
- package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/create-user-dialog.tsx +0 -183
- package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/edit-name-dialog.tsx +0 -129
- package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/users-table.tsx +0 -415
- package/template/saas-starter/src/app/(app)/actions/organization.ts +0 -92
- package/template/saas-starter/src/app/proxy.ts +0 -28
- package/template/saas-starter/src/components/impersonation-banner.tsx +0 -44
- package/template/saas-starter/src/lib/organization-plan-limits.ts +0 -38
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
resource "google_compute_global_forwarding_rule" "main_lb_https_ipv4_frontend" {
|
|
2
|
-
name = "main-lb-https-ipv4-frontend"
|
|
3
|
-
ip_protocol = "TCP"
|
|
4
|
-
ip_address = google_compute_global_address.main_lb_ipv4.address
|
|
5
|
-
load_balancing_scheme = "EXTERNAL_MANAGED"
|
|
6
|
-
port_range = "443"
|
|
7
|
-
target = google_compute_target_https_proxy.main_lb_target_proxy.id
|
|
8
|
-
|
|
9
|
-
depends_on = [google_compute_global_address.main_lb_ipv4, google_compute_target_https_proxy.main_lb_target_proxy]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
resource "google_compute_global_forwarding_rule" "main_lb_https_ipv6_frontend" {
|
|
13
|
-
name = "main-lb-https-ipv6-frontend"
|
|
14
|
-
ip_protocol = "TCP"
|
|
15
|
-
ip_address = google_compute_global_address.main_lb_ipv6.address
|
|
16
|
-
load_balancing_scheme = "EXTERNAL_MANAGED"
|
|
17
|
-
port_range = "443"
|
|
18
|
-
target = google_compute_target_https_proxy.main_lb_target_proxy.id
|
|
19
|
-
|
|
20
|
-
depends_on = [google_compute_global_address.main_lb_ipv6, google_compute_target_https_proxy.main_lb_target_proxy]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
resource "google_compute_global_forwarding_rule" "main_lb_ipv4_http_forwarding_rule" {
|
|
24
|
-
name = "main-lb-ipv4-http-forwarding-rule"
|
|
25
|
-
ip_protocol = "TCP"
|
|
26
|
-
ip_address = google_compute_global_address.main_lb_ipv4.address
|
|
27
|
-
load_balancing_scheme = "EXTERNAL_MANAGED"
|
|
28
|
-
port_range = "80"
|
|
29
|
-
target = google_compute_target_http_proxy.main_lb_http_redirect_proxy.id
|
|
30
|
-
|
|
31
|
-
depends_on = [google_compute_global_forwarding_rule.main_lb_https_ipv4_frontend]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
resource "google_compute_global_forwarding_rule" "main_lb_ipv6_http_forwarding_rule" {
|
|
35
|
-
name = "main-lb-ipv6-http-forwarding-rule"
|
|
36
|
-
ip_protocol = "TCP"
|
|
37
|
-
ip_address = google_compute_global_address.main_lb_ipv6.address
|
|
38
|
-
load_balancing_scheme = "EXTERNAL_MANAGED"
|
|
39
|
-
port_range = "80"
|
|
40
|
-
target = google_compute_target_http_proxy.main_lb_http_redirect_proxy.id
|
|
41
|
-
|
|
42
|
-
depends_on = [google_compute_global_forwarding_rule.main_lb_https_ipv6_frontend]
|
|
43
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
resource "google_compute_global_address" "main_lb_ipv4" {
|
|
2
|
-
name = "main-lb-ipv4"
|
|
3
|
-
ip_version = "IPV4"
|
|
4
|
-
address_type = "EXTERNAL"
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
resource "google_compute_global_address" "main_lb_ipv6" {
|
|
8
|
-
name = "main-lb-ipv6"
|
|
9
|
-
ip_version = "IPV6"
|
|
10
|
-
address_type = "EXTERNAL"
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
resource "google_compute_region_network_endpoint_group" "my_app_prod_neg" {
|
|
2
|
-
name = "my-app-prod-neg"
|
|
3
|
-
network_endpoint_type = "SERVERLESS"
|
|
4
|
-
region = var.region
|
|
5
|
-
|
|
6
|
-
cloud_run {
|
|
7
|
-
service = google_cloud_run_v2_service.my_app_prod.name
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
depends_on = [google_cloud_run_v2_service.my_app_prod]
|
|
11
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
resource "google_compute_network" "vpc_network" {
|
|
2
|
-
name = "terraform-network"
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
resource "google_compute_global_address" "private_ip_range" {
|
|
6
|
-
name = "private-ip-range"
|
|
7
|
-
prefix_length = 16
|
|
8
|
-
address_type = "INTERNAL"
|
|
9
|
-
purpose = "VPC_PEERING"
|
|
10
|
-
network = google_compute_network.vpc_network.self_link
|
|
11
|
-
|
|
12
|
-
depends_on = [google_compute_network.vpc_network]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
resource "google_service_networking_connection" "private_connection" {
|
|
16
|
-
network = google_compute_network.vpc_network.id
|
|
17
|
-
service = "servicenetworking.googleapis.com"
|
|
18
|
-
reserved_peering_ranges = [google_compute_global_address.private_ip_range.name]
|
|
19
|
-
|
|
20
|
-
depends_on = [google_compute_global_address.private_ip_range]
|
|
21
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
terraform {
|
|
2
|
-
required_providers {
|
|
3
|
-
google = {
|
|
4
|
-
source = "hashicorp/google"
|
|
5
|
-
version = "7.8.0"
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
backend "gcs" {
|
|
10
|
-
bucket = "project-id-tf-state"
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
provider "google" {
|
|
15
|
-
project = var.project
|
|
16
|
-
region = var.region
|
|
17
|
-
zone = var.zone
|
|
18
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
echo "Starting pre.sh script..."
|
|
2
|
-
|
|
3
|
-
gcloud config set project project-id
|
|
4
|
-
|
|
5
|
-
gcloud auth application-default set-quota-project project-id
|
|
6
|
-
|
|
7
|
-
echo "Setting up Google Cloud SDK and enabling required APIs..."
|
|
8
|
-
|
|
9
|
-
gcloud services enable logging.googleapis.com monitoring.googleapis.com compute.googleapis.com run.googleapis.com artifactregistry.googleapis.com vpcaccess.googleapis.com cloudbuild.googleapis.com servicenetworking.googleapis.com networkconnectivity.googleapis.com certificatemanager.googleapis.com sql-component.googleapis.com storage-component.googleapis.com storage.googleapis.com cloudapis.googleapis.com secretmanager.googleapis.com
|
|
10
|
-
|
|
11
|
-
echo "Enabling APIs completed."
|
|
12
|
-
|
|
13
|
-
echo "Please manually create a db secret in Secret Manager with names in file secret.txt"
|
|
14
|
-
|
|
15
|
-
echo "Creating storage bucket for Terraform state..."
|
|
16
|
-
|
|
17
|
-
gcloud storage buckets create gs://project-id-tf-state --location=us
|
|
18
|
-
|
|
19
|
-
gcloud storage buckets update gs://project-id-tf-state --versioning
|
|
20
|
-
|
|
21
|
-
echo "Creating storage bucket for Terraform state completed."
|
|
22
|
-
|
|
23
|
-
echo "Please manually connect github repositories on cloud build repositories from here https://console.cloud.google.com/cloud-build/repositories/1st-gen"
|
|
24
|
-
|
|
25
|
-
echo "And then copy the service account (eg:- 123456-compute@developer.gserviceaccount.com) to vars terraform.tfvars file from this link https://console.cloud.google.com/iam-admin/iam"
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
resource "google_certificate_manager_certificate" "my_app_cert" {
|
|
2
|
-
name = "my-app-cert"
|
|
3
|
-
|
|
4
|
-
managed {
|
|
5
|
-
domains = [
|
|
6
|
-
"myapp.com"
|
|
7
|
-
]
|
|
8
|
-
dns_authorizations = [
|
|
9
|
-
google_certificate_manager_dns_authorization.my_app_prod_auth.id,
|
|
10
|
-
]
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
depends_on = [
|
|
14
|
-
google_certificate_manager_dns_authorization.my_app_prod_auth,
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
resource "google_certificate_manager_dns_authorization" "my_app_prod_auth" {
|
|
19
|
-
name = "my-app-prod-auth"
|
|
20
|
-
domain = "myapp.com"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
resource "google_certificate_manager_certificate_map" "default" {
|
|
24
|
-
name = "default-cert-map"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
resource "google_certificate_manager_certificate_map_entry" "my_app_prod_entry" {
|
|
28
|
-
name = "my-app-prod-entry"
|
|
29
|
-
map = google_certificate_manager_certificate_map.default.name
|
|
30
|
-
hostname = "myapp.com"
|
|
31
|
-
certificates = [google_certificate_manager_certificate.my_app_cert.id]
|
|
32
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
resource "google_compute_target_https_proxy" "main_lb_target_proxy" {
|
|
2
|
-
name = "main-lb-target-proxy"
|
|
3
|
-
url_map = google_compute_url_map.main_lb.id
|
|
4
|
-
certificate_map = "//certificatemanager.googleapis.com/projects/${var.project}/locations/global/certificateMaps/${google_certificate_manager_certificate_map.default.name}"
|
|
5
|
-
|
|
6
|
-
depends_on = [google_compute_url_map.main_lb]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
resource "google_compute_target_http_proxy" "main_lb_http_redirect_proxy" {
|
|
10
|
-
name = "main-lb-http-redirect-proxy"
|
|
11
|
-
url_map = google_compute_url_map.main_lb_http_redirect.id
|
|
12
|
-
|
|
13
|
-
depends_on = [google_compute_url_map.main_lb_http_redirect]
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
resource "google_compute_target_https_proxy" "main_lb_target_proxy" {
|
|
2
|
-
name = "main-lb-target-proxy"
|
|
3
|
-
url_map = google_compute_url_map.main_lb.id
|
|
4
|
-
certificate_map = "//certificatemanager.googleapis.com/projects/${var.project}/locations/global/certificateMaps/${google_certificate_manager_certificate_map.default.name}"
|
|
5
|
-
|
|
6
|
-
depends_on = [google_compute_url_map.main_lb]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
resource "google_compute_target_http_proxy" "main_lb_http_redirect_proxy" {
|
|
10
|
-
name = "main-lb-http-redirect-proxy"
|
|
11
|
-
url_map = google_compute_url_map.main_lb_http_redirect.id
|
|
12
|
-
|
|
13
|
-
depends_on = [google_compute_url_map.main_lb_http_redirect]
|
|
14
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
resource "google_compute_url_map" "main_lb" {
|
|
2
|
-
name = "main-lb"
|
|
3
|
-
default_service = google_compute_backend_service.my_app_prod_service.id
|
|
4
|
-
|
|
5
|
-
host_rule {
|
|
6
|
-
path_matcher = "path-matcher-my-app-prod"
|
|
7
|
-
hosts = ["myapp.com"]
|
|
8
|
-
}
|
|
9
|
-
path_matcher {
|
|
10
|
-
name = "path-matcher-my-app-prod"
|
|
11
|
-
default_service = google_compute_backend_service.my_app_prod_service.id
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
resource "google_compute_url_map" "main_lb_http_redirect" {
|
|
16
|
-
name = "main-lb-http-to-https-redirect"
|
|
17
|
-
|
|
18
|
-
default_url_redirect {
|
|
19
|
-
https_redirect = true
|
|
20
|
-
strip_query = false
|
|
21
|
-
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
variable "project" {
|
|
2
|
-
description = "Google Cloud Project ID"
|
|
3
|
-
type = string
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
variable "region" {
|
|
7
|
-
description = "Google Cloud Region"
|
|
8
|
-
type = string
|
|
9
|
-
default = "us-central1"
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
variable "zone" {
|
|
13
|
-
description = "Google Cloud Zone"
|
|
14
|
-
type = string
|
|
15
|
-
default = "us-central1-a"
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
variable "compute_service_account" {
|
|
19
|
-
description = "Default compiute Service account"
|
|
20
|
-
type = string
|
|
21
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use server'
|
|
2
|
-
|
|
3
|
-
import { assertUserMembership } from '~/lib/organization-access'
|
|
4
|
-
import { authActionClient } from '~/lib/safe-action'
|
|
5
|
-
import { generateUploadUrl, isR2Configured } from '~/lib/storage'
|
|
6
|
-
import { generateUploadUrlSchema } from './uploads.validation'
|
|
7
|
-
|
|
8
|
-
export const generateUploadUrlAction = authActionClient
|
|
9
|
-
.inputSchema(generateUploadUrlSchema)
|
|
10
|
-
.action(async ({ parsedInput, ctx: { user } }) => {
|
|
11
|
-
if (!isR2Configured()) {
|
|
12
|
-
return { mode: 'base64' as const }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (parsedInput.organizationId) {
|
|
16
|
-
await assertUserMembership(parsedInput.organizationId)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const { uploadUrl, key } = await generateUploadUrl({
|
|
20
|
-
filename: parsedInput.filename,
|
|
21
|
-
mimeType: parsedInput.mimeType,
|
|
22
|
-
size: parsedInput.size,
|
|
23
|
-
uploadedBy: user.id,
|
|
24
|
-
organizationId: parsedInput.organizationId
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return { mode: 'r2' as const, uploadUrl, key }
|
|
28
|
-
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { MAX_FILE_SIZE_BYTES, MAX_FILE_SIZE_MB } from '~/lib/constants'
|
|
3
|
-
import { stringValidation } from '~/lib/validations'
|
|
4
|
-
|
|
5
|
-
export const generateUploadUrlSchema = z.object({
|
|
6
|
-
filename: stringValidation,
|
|
7
|
-
mimeType: stringValidation,
|
|
8
|
-
size: z
|
|
9
|
-
.number()
|
|
10
|
-
.int()
|
|
11
|
-
.positive()
|
|
12
|
-
.max(MAX_FILE_SIZE_BYTES, `File must be under ${MAX_FILE_SIZE_MB}MB`),
|
|
13
|
-
organizationId: stringValidation
|
|
14
|
-
})
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { zodResolver } from '@hookform/resolvers/zod'
|
|
4
|
-
import { useQueryClient } from '@tanstack/react-query'
|
|
5
|
-
import { Loader2 } from 'lucide-react'
|
|
6
|
-
import { useEffect, useState } from 'react'
|
|
7
|
-
import { Controller, useForm } from 'react-hook-form'
|
|
8
|
-
import { z } from 'zod'
|
|
9
|
-
import { Button } from '~/components/ui/button'
|
|
10
|
-
import {
|
|
11
|
-
Dialog,
|
|
12
|
-
DialogContent,
|
|
13
|
-
DialogDescription,
|
|
14
|
-
DialogFooter,
|
|
15
|
-
DialogHeader,
|
|
16
|
-
DialogTitle,
|
|
17
|
-
DialogTrigger
|
|
18
|
-
} from '~/components/ui/dialog'
|
|
19
|
-
import {
|
|
20
|
-
Field,
|
|
21
|
-
FieldContent,
|
|
22
|
-
FieldError,
|
|
23
|
-
FieldTitle
|
|
24
|
-
} from '~/components/ui/field'
|
|
25
|
-
import { Input } from '~/components/ui/input'
|
|
26
|
-
import {
|
|
27
|
-
Select,
|
|
28
|
-
SelectContent,
|
|
29
|
-
SelectItem,
|
|
30
|
-
SelectTrigger,
|
|
31
|
-
SelectValue
|
|
32
|
-
} from '~/components/ui/select'
|
|
33
|
-
import { admin } from '~/lib/auth-client'
|
|
34
|
-
import { toastErrorMessage, toastSuccessMessage } from '~/lib/toast-message'
|
|
35
|
-
import { emailValidation, stringValidation } from '~/lib/validations'
|
|
36
|
-
|
|
37
|
-
const schema = z.object({
|
|
38
|
-
name: stringValidation,
|
|
39
|
-
email: emailValidation,
|
|
40
|
-
role: z.enum(['user', 'admin', 'superadmin'])
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
type Form = z.infer<typeof schema>
|
|
44
|
-
|
|
45
|
-
interface CreateUserDialogProps {
|
|
46
|
-
children: React.ReactNode
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function CreateUserDialog({ children }: CreateUserDialogProps) {
|
|
50
|
-
const queryClient = useQueryClient()
|
|
51
|
-
const [open, setOpen] = useState(false)
|
|
52
|
-
|
|
53
|
-
const {
|
|
54
|
-
register,
|
|
55
|
-
handleSubmit,
|
|
56
|
-
reset,
|
|
57
|
-
control,
|
|
58
|
-
formState: { errors, isSubmitting }
|
|
59
|
-
} = useForm<Form>({
|
|
60
|
-
resolver: zodResolver(schema),
|
|
61
|
-
defaultValues: { name: '', email: '', role: 'user' }
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (open) reset({ name: '', email: '', role: 'user' })
|
|
66
|
-
}, [open, reset])
|
|
67
|
-
|
|
68
|
-
async function onSubmit(values: Form) {
|
|
69
|
-
const { error } = await admin.createUser({
|
|
70
|
-
name: values.name,
|
|
71
|
-
email: values.email,
|
|
72
|
-
role: values.role as any,
|
|
73
|
-
data: {}
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
if (error) {
|
|
77
|
-
toastErrorMessage(error.message ?? 'Failed to create user')
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
toastSuccessMessage(`Account created for ${values.email}`)
|
|
82
|
-
setOpen(false)
|
|
83
|
-
queryClient.invalidateQueries({ queryKey: ['admin-users'] })
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<Dialog open={open} onOpenChange={setOpen}>
|
|
88
|
-
<DialogTrigger asChild>{children}</DialogTrigger>
|
|
89
|
-
<DialogContent className="sm:max-w-md">
|
|
90
|
-
<DialogHeader>
|
|
91
|
-
<DialogTitle>Create user</DialogTitle>
|
|
92
|
-
<DialogDescription>
|
|
93
|
-
Create a new account. The user will sign in via magic link.
|
|
94
|
-
</DialogDescription>
|
|
95
|
-
</DialogHeader>
|
|
96
|
-
|
|
97
|
-
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4 py-1">
|
|
98
|
-
<Field orientation="vertical">
|
|
99
|
-
<FieldContent>
|
|
100
|
-
<FieldTitle className="text-foreground mb-1.5 text-[13px] font-semibold">
|
|
101
|
-
Name
|
|
102
|
-
</FieldTitle>
|
|
103
|
-
<Input
|
|
104
|
-
autoFocus
|
|
105
|
-
placeholder="Jane Doe"
|
|
106
|
-
{...register('name')}
|
|
107
|
-
aria-invalid={!!errors.name}
|
|
108
|
-
/>
|
|
109
|
-
<FieldError
|
|
110
|
-
errors={[errors.name]}
|
|
111
|
-
className="mt-1.5 text-[13px]"
|
|
112
|
-
/>
|
|
113
|
-
</FieldContent>
|
|
114
|
-
</Field>
|
|
115
|
-
|
|
116
|
-
<Field orientation="vertical">
|
|
117
|
-
<FieldContent>
|
|
118
|
-
<FieldTitle className="text-foreground mb-1.5 text-[13px] font-semibold">
|
|
119
|
-
Email
|
|
120
|
-
</FieldTitle>
|
|
121
|
-
<Input
|
|
122
|
-
type="email"
|
|
123
|
-
placeholder="jane@example.com"
|
|
124
|
-
autoComplete="off"
|
|
125
|
-
{...register('email')}
|
|
126
|
-
aria-invalid={!!errors.email}
|
|
127
|
-
/>
|
|
128
|
-
<FieldError
|
|
129
|
-
errors={[errors.email]}
|
|
130
|
-
className="mt-1.5 text-[13px]"
|
|
131
|
-
/>
|
|
132
|
-
</FieldContent>
|
|
133
|
-
</Field>
|
|
134
|
-
|
|
135
|
-
<Field orientation="vertical">
|
|
136
|
-
<FieldContent>
|
|
137
|
-
<FieldTitle className="text-foreground mb-1.5 text-[13px] font-semibold">
|
|
138
|
-
Role
|
|
139
|
-
</FieldTitle>
|
|
140
|
-
<Controller
|
|
141
|
-
control={control}
|
|
142
|
-
name="role"
|
|
143
|
-
render={({ field }) => (
|
|
144
|
-
<Select value={field.value} onValueChange={field.onChange}>
|
|
145
|
-
<SelectTrigger className="w-full">
|
|
146
|
-
<SelectValue placeholder="Select role" />
|
|
147
|
-
</SelectTrigger>
|
|
148
|
-
<SelectContent>
|
|
149
|
-
<SelectItem value="user">User</SelectItem>
|
|
150
|
-
<SelectItem value="admin">Admin</SelectItem>
|
|
151
|
-
<SelectItem value="superadmin">Superadmin</SelectItem>
|
|
152
|
-
</SelectContent>
|
|
153
|
-
</Select>
|
|
154
|
-
)}
|
|
155
|
-
/>
|
|
156
|
-
<FieldError
|
|
157
|
-
errors={[errors.role]}
|
|
158
|
-
className="mt-1.5 text-[13px]"
|
|
159
|
-
/>
|
|
160
|
-
</FieldContent>
|
|
161
|
-
</Field>
|
|
162
|
-
|
|
163
|
-
<DialogFooter>
|
|
164
|
-
<Button
|
|
165
|
-
type="button"
|
|
166
|
-
variant="outline"
|
|
167
|
-
onClick={() => setOpen(false)}
|
|
168
|
-
disabled={isSubmitting}
|
|
169
|
-
>
|
|
170
|
-
Cancel
|
|
171
|
-
</Button>
|
|
172
|
-
<Button type="submit" disabled={isSubmitting}>
|
|
173
|
-
{isSubmitting && (
|
|
174
|
-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
175
|
-
)}
|
|
176
|
-
Create account
|
|
177
|
-
</Button>
|
|
178
|
-
</DialogFooter>
|
|
179
|
-
</form>
|
|
180
|
-
</DialogContent>
|
|
181
|
-
</Dialog>
|
|
182
|
-
)
|
|
183
|
-
}
|
package/template/saas-starter/src/app/(admin)/admin/settings/users/_components/edit-name-dialog.tsx
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { zodResolver } from '@hookform/resolvers/zod'
|
|
4
|
-
import { useQueryClient } from '@tanstack/react-query'
|
|
5
|
-
import { Loader2 } from 'lucide-react'
|
|
6
|
-
import { useEffect, useState } from 'react'
|
|
7
|
-
import { useForm } from 'react-hook-form'
|
|
8
|
-
import { z } from 'zod'
|
|
9
|
-
import { Button } from '~/components/ui/button'
|
|
10
|
-
import {
|
|
11
|
-
Dialog,
|
|
12
|
-
DialogContent,
|
|
13
|
-
DialogDescription,
|
|
14
|
-
DialogFooter,
|
|
15
|
-
DialogHeader,
|
|
16
|
-
DialogTitle,
|
|
17
|
-
DialogTrigger
|
|
18
|
-
} from '~/components/ui/dialog'
|
|
19
|
-
import {
|
|
20
|
-
Field,
|
|
21
|
-
FieldContent,
|
|
22
|
-
FieldError,
|
|
23
|
-
FieldTitle
|
|
24
|
-
} from '~/components/ui/field'
|
|
25
|
-
import { Input } from '~/components/ui/input'
|
|
26
|
-
import { admin } from '~/lib/auth-client'
|
|
27
|
-
import { toastErrorMessage, toastSuccessMessage } from '~/lib/toast-message'
|
|
28
|
-
import { stringValidation } from '~/lib/validations'
|
|
29
|
-
|
|
30
|
-
const schema = z.object({
|
|
31
|
-
name: stringValidation
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
type Form = z.infer<typeof schema>
|
|
35
|
-
|
|
36
|
-
interface EditNameDialogProps {
|
|
37
|
-
userId: string
|
|
38
|
-
currentName: string
|
|
39
|
-
children: React.ReactNode
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function EditNameDialog({
|
|
43
|
-
userId,
|
|
44
|
-
currentName,
|
|
45
|
-
children
|
|
46
|
-
}: EditNameDialogProps) {
|
|
47
|
-
const queryClient = useQueryClient()
|
|
48
|
-
const [open, setOpen] = useState(false)
|
|
49
|
-
|
|
50
|
-
const {
|
|
51
|
-
register,
|
|
52
|
-
handleSubmit,
|
|
53
|
-
reset,
|
|
54
|
-
formState: { errors, isSubmitting, isDirty }
|
|
55
|
-
} = useForm<Form>({
|
|
56
|
-
resolver: zodResolver(schema),
|
|
57
|
-
defaultValues: { name: currentName }
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (open) reset({ name: currentName })
|
|
62
|
-
}, [open, currentName, reset])
|
|
63
|
-
|
|
64
|
-
async function onSubmit(values: Form) {
|
|
65
|
-
const { error } = await admin.updateUser({
|
|
66
|
-
userId,
|
|
67
|
-
data: { name: values.name }
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
if (error) {
|
|
71
|
-
toastErrorMessage(error.message ?? 'Failed to update name')
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
toastSuccessMessage('Name updated')
|
|
76
|
-
setOpen(false)
|
|
77
|
-
queryClient.invalidateQueries({ queryKey: ['admin-users'] })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Dialog open={open} onOpenChange={setOpen}>
|
|
82
|
-
<DialogTrigger asChild>{children}</DialogTrigger>
|
|
83
|
-
<DialogContent className="sm:max-w-sm">
|
|
84
|
-
<DialogHeader>
|
|
85
|
-
<DialogTitle>Edit name</DialogTitle>
|
|
86
|
-
<DialogDescription>
|
|
87
|
-
Update the user's display name.
|
|
88
|
-
</DialogDescription>
|
|
89
|
-
</DialogHeader>
|
|
90
|
-
|
|
91
|
-
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4 py-1">
|
|
92
|
-
<Field orientation="vertical">
|
|
93
|
-
<FieldContent>
|
|
94
|
-
<FieldTitle className="text-foreground mb-1.5 text-[13px] font-semibold">
|
|
95
|
-
Name
|
|
96
|
-
</FieldTitle>
|
|
97
|
-
<Input
|
|
98
|
-
autoFocus
|
|
99
|
-
{...register('name')}
|
|
100
|
-
aria-invalid={!!errors.name}
|
|
101
|
-
/>
|
|
102
|
-
<FieldError
|
|
103
|
-
errors={[errors.name]}
|
|
104
|
-
className="mt-1.5 text-[13px]"
|
|
105
|
-
/>
|
|
106
|
-
</FieldContent>
|
|
107
|
-
</Field>
|
|
108
|
-
|
|
109
|
-
<DialogFooter>
|
|
110
|
-
<Button
|
|
111
|
-
type="button"
|
|
112
|
-
variant="outline"
|
|
113
|
-
onClick={() => setOpen(false)}
|
|
114
|
-
disabled={isSubmitting}
|
|
115
|
-
>
|
|
116
|
-
Cancel
|
|
117
|
-
</Button>
|
|
118
|
-
<Button type="submit" disabled={isSubmitting || !isDirty}>
|
|
119
|
-
{isSubmitting && (
|
|
120
|
-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
121
|
-
)}
|
|
122
|
-
Save
|
|
123
|
-
</Button>
|
|
124
|
-
</DialogFooter>
|
|
125
|
-
</form>
|
|
126
|
-
</DialogContent>
|
|
127
|
-
</Dialog>
|
|
128
|
-
)
|
|
129
|
-
}
|