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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use server'
|
|
2
|
+
|
|
3
|
+
import { asc, count, desc, ilike, or } from 'drizzle-orm'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
import { SortOrderEnum } from '~/components/data-table/enum'
|
|
6
|
+
import { db } from '~/db'
|
|
7
|
+
import { contactLeadsTable } from '~/db/schema'
|
|
8
|
+
import { getPaginationSchema, getSortSchema } from '~/lib/actions'
|
|
9
|
+
import { adminActionClient, withWideEvent } from '~/lib/safe-action'
|
|
10
|
+
import { likeContains } from '~/lib/search'
|
|
11
|
+
import { optionalStringValidation } from '~/lib/validations'
|
|
12
|
+
|
|
13
|
+
export const getContactLeads = adminActionClient
|
|
14
|
+
.inputSchema(
|
|
15
|
+
z.object({
|
|
16
|
+
...getPaginationSchema(),
|
|
17
|
+
...getSortSchema(['createdAt', 'name', 'email']),
|
|
18
|
+
search: optionalStringValidation
|
|
19
|
+
})
|
|
20
|
+
)
|
|
21
|
+
.action(
|
|
22
|
+
withWideEvent(
|
|
23
|
+
'getContactLeads',
|
|
24
|
+
async ({ parsedInput: { page, limit, sortBy, sortOrder, search } }) => {
|
|
25
|
+
const where = search
|
|
26
|
+
? or(
|
|
27
|
+
ilike(contactLeadsTable.name, likeContains(search)),
|
|
28
|
+
ilike(contactLeadsTable.email, likeContains(search)),
|
|
29
|
+
ilike(contactLeadsTable.subject, likeContains(search)),
|
|
30
|
+
ilike(contactLeadsTable.message, likeContains(search))
|
|
31
|
+
)
|
|
32
|
+
: undefined
|
|
33
|
+
|
|
34
|
+
const [results, total] = await Promise.all([
|
|
35
|
+
db.query.contactLeadsTable.findMany({
|
|
36
|
+
where,
|
|
37
|
+
limit,
|
|
38
|
+
offset: (page - 1) * limit,
|
|
39
|
+
orderBy: [
|
|
40
|
+
sortOrder === SortOrderEnum.ASC
|
|
41
|
+
? asc(contactLeadsTable[sortBy || 'createdAt'])
|
|
42
|
+
: desc(contactLeadsTable[sortBy || 'createdAt'])
|
|
43
|
+
]
|
|
44
|
+
}),
|
|
45
|
+
db.select({ count: count() }).from(contactLeadsTable).where(where)
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
return [results, total[0]?.count || 0] as const
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use server'
|
|
2
|
+
|
|
3
|
+
import { and, asc, count, desc, eq, ilike, inArray, or } from 'drizzle-orm'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
import { SortOrderEnum } from '~/components/data-table/enum'
|
|
6
|
+
import { db } from '~/db'
|
|
7
|
+
import { feedbacksTable, organizationsTable, usersTable } from '~/db/schema'
|
|
8
|
+
import { getPaginationSchema, getSortSchema } from '~/lib/actions'
|
|
9
|
+
import { MAX_FILTER_VALUES, MAX_RATING, MIN_RATING } from '~/lib/constants'
|
|
10
|
+
import { adminActionClient, withWideEvent } from '~/lib/safe-action'
|
|
11
|
+
import { likeContains } from '~/lib/search'
|
|
12
|
+
import { optionalStringValidation } from '~/lib/validations'
|
|
13
|
+
|
|
14
|
+
export const getFeedbacks = adminActionClient
|
|
15
|
+
.inputSchema(
|
|
16
|
+
z.object({
|
|
17
|
+
...getPaginationSchema(),
|
|
18
|
+
...getSortSchema(['createdAt', 'rating']),
|
|
19
|
+
search: optionalStringValidation,
|
|
20
|
+
filters: z
|
|
21
|
+
.object({
|
|
22
|
+
rating: z
|
|
23
|
+
.array(z.coerce.number().int().min(MIN_RATING).max(MAX_RATING))
|
|
24
|
+
.max(MAX_FILTER_VALUES)
|
|
25
|
+
.optional()
|
|
26
|
+
})
|
|
27
|
+
.optional()
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
.action(
|
|
31
|
+
withWideEvent(
|
|
32
|
+
'getFeedbacks',
|
|
33
|
+
async ({
|
|
34
|
+
parsedInput: { page, limit, sortBy, sortOrder, search, filters }
|
|
35
|
+
}) => {
|
|
36
|
+
const where = and(
|
|
37
|
+
search
|
|
38
|
+
? or(
|
|
39
|
+
ilike(feedbacksTable.comment, likeContains(search)),
|
|
40
|
+
ilike(usersTable.email, likeContains(search)),
|
|
41
|
+
ilike(usersTable.name, likeContains(search)),
|
|
42
|
+
ilike(organizationsTable.name, likeContains(search))
|
|
43
|
+
)
|
|
44
|
+
: undefined,
|
|
45
|
+
filters?.rating?.length
|
|
46
|
+
? inArray(feedbacksTable.rating, filters.rating)
|
|
47
|
+
: undefined
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
const [results, total] = await Promise.all([
|
|
51
|
+
db
|
|
52
|
+
.select({
|
|
53
|
+
id: feedbacksTable.id,
|
|
54
|
+
rating: feedbacksTable.rating,
|
|
55
|
+
comment: feedbacksTable.comment,
|
|
56
|
+
createdAt: feedbacksTable.createdAt,
|
|
57
|
+
userId: feedbacksTable.userId,
|
|
58
|
+
organizationId: feedbacksTable.organizationId,
|
|
59
|
+
userEmail: usersTable.email,
|
|
60
|
+
userName: usersTable.name,
|
|
61
|
+
organizationName: organizationsTable.name
|
|
62
|
+
})
|
|
63
|
+
.from(feedbacksTable)
|
|
64
|
+
.leftJoin(usersTable, eq(feedbacksTable.userId, usersTable.id))
|
|
65
|
+
.leftJoin(
|
|
66
|
+
organizationsTable,
|
|
67
|
+
eq(feedbacksTable.organizationId, organizationsTable.id)
|
|
68
|
+
)
|
|
69
|
+
.where(where)
|
|
70
|
+
.limit(limit)
|
|
71
|
+
.offset((page - 1) * limit)
|
|
72
|
+
.orderBy(
|
|
73
|
+
sortOrder === SortOrderEnum.ASC
|
|
74
|
+
? asc(feedbacksTable[sortBy || 'createdAt'])
|
|
75
|
+
: desc(feedbacksTable[sortBy || 'createdAt'])
|
|
76
|
+
),
|
|
77
|
+
db
|
|
78
|
+
.select({ count: count() })
|
|
79
|
+
.from(feedbacksTable)
|
|
80
|
+
.leftJoin(usersTable, eq(feedbacksTable.userId, usersTable.id))
|
|
81
|
+
.leftJoin(
|
|
82
|
+
organizationsTable,
|
|
83
|
+
eq(feedbacksTable.organizationId, organizationsTable.id)
|
|
84
|
+
)
|
|
85
|
+
.where(where)
|
|
86
|
+
])
|
|
87
|
+
|
|
88
|
+
return [results, total[0]?.count || 0] as const
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
)
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
asc,
|
|
6
6
|
count,
|
|
7
7
|
desc,
|
|
8
|
+
eq,
|
|
8
9
|
ilike,
|
|
9
10
|
inArray,
|
|
10
11
|
isNotNull,
|
|
@@ -15,83 +16,168 @@ import { SortOrderEnum } from '~/components/data-table/enum'
|
|
|
15
16
|
import { db } from '~/db'
|
|
16
17
|
import { usersTable } from '~/db/schema'
|
|
17
18
|
import { getPaginationSchema, getSortSchema } from '~/lib/actions'
|
|
18
|
-
import {
|
|
19
|
+
import { MAX_FILTER_VALUES } from '~/lib/constants'
|
|
20
|
+
import { AppError, AppErrorCode, rethrowUniqueViolation } from '~/lib/errors'
|
|
21
|
+
import { superAdminActionClient, withWideEvent } from '~/lib/safe-action'
|
|
22
|
+
import { likeContains } from '~/lib/search'
|
|
23
|
+
import { optionalStringValidation, stringValidation } from '~/lib/validations'
|
|
24
|
+
import {
|
|
25
|
+
createUserSchema,
|
|
26
|
+
updateUserSchema
|
|
27
|
+
} from '../admin/settings/users/validation'
|
|
28
|
+
|
|
29
|
+
const EMAIL_TAKEN = 'Another account already uses this email address.'
|
|
19
30
|
|
|
20
|
-
export const getUsers =
|
|
31
|
+
export const getUsers = superAdminActionClient
|
|
21
32
|
.inputSchema(
|
|
22
33
|
z.object({
|
|
23
34
|
...getPaginationSchema(),
|
|
24
35
|
...getSortSchema(['name', 'email', 'createdAt']),
|
|
25
|
-
search:
|
|
36
|
+
search: optionalStringValidation,
|
|
26
37
|
filters: z
|
|
27
38
|
.object({
|
|
28
|
-
role: z.array(z.string()).optional(),
|
|
29
|
-
banned: z.array(z.boolean()).optional()
|
|
39
|
+
role: z.array(z.string()).max(MAX_FILTER_VALUES).optional(),
|
|
40
|
+
banned: z.array(z.boolean()).max(MAX_FILTER_VALUES).optional()
|
|
30
41
|
})
|
|
31
42
|
.optional()
|
|
32
43
|
})
|
|
33
44
|
)
|
|
34
45
|
.action(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
withWideEvent(
|
|
47
|
+
'getUsers',
|
|
48
|
+
async ({
|
|
49
|
+
parsedInput: { page, limit, sortBy, sortOrder, search, filters }
|
|
50
|
+
}) => {
|
|
51
|
+
const where = and(
|
|
52
|
+
search
|
|
53
|
+
? or(
|
|
54
|
+
ilike(usersTable.name, likeContains(search)),
|
|
55
|
+
ilike(usersTable.email, likeContains(search))
|
|
56
|
+
)
|
|
57
|
+
: undefined,
|
|
58
|
+
filters?.role?.length
|
|
59
|
+
? inArray(usersTable.role, filters.role)
|
|
60
|
+
: undefined,
|
|
61
|
+
filters?.banned?.length
|
|
62
|
+
? inArray(usersTable.banned, filters.banned)
|
|
63
|
+
: undefined
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const [results, total] = await Promise.all([
|
|
67
|
+
db.query.usersTable.findMany({
|
|
68
|
+
where,
|
|
69
|
+
limit,
|
|
70
|
+
offset: (page - 1) * limit,
|
|
71
|
+
orderBy: [
|
|
72
|
+
sortOrder === SortOrderEnum.ASC
|
|
73
|
+
? asc(usersTable[sortBy || 'createdAt'])
|
|
74
|
+
: desc(usersTable[sortBy || 'createdAt'])
|
|
75
|
+
]
|
|
76
|
+
}),
|
|
77
|
+
db.select({ count: count() }).from(usersTable).where(where)
|
|
78
|
+
])
|
|
79
|
+
|
|
80
|
+
return [results, total[0]?.count || 0] as const
|
|
81
|
+
}
|
|
82
|
+
)
|
|
69
83
|
)
|
|
70
84
|
|
|
71
|
-
export const getDistinctRoles =
|
|
85
|
+
export const getDistinctRoles = superAdminActionClient
|
|
72
86
|
.inputSchema(
|
|
73
87
|
z.object({
|
|
74
|
-
search:
|
|
88
|
+
search: optionalStringValidation,
|
|
75
89
|
...getPaginationSchema(20)
|
|
76
90
|
})
|
|
77
91
|
)
|
|
78
|
-
.action(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
.action(
|
|
93
|
+
withWideEvent(
|
|
94
|
+
'getDistinctRoles',
|
|
95
|
+
async ({ parsedInput: { search, limit } }) => {
|
|
96
|
+
const where = and(
|
|
97
|
+
isNotNull(usersTable.role),
|
|
98
|
+
search ? ilike(usersTable.role, likeContains(search)) : undefined
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const rows = await db
|
|
102
|
+
.selectDistinct({ role: usersTable.role })
|
|
103
|
+
.from(usersTable)
|
|
104
|
+
.where(where)
|
|
105
|
+
.orderBy(asc(usersTable.role))
|
|
106
|
+
.limit(limit)
|
|
107
|
+
|
|
108
|
+
return rows
|
|
109
|
+
.filter(r => r.role !== null)
|
|
110
|
+
.map(r => ({
|
|
111
|
+
value: r.role!,
|
|
112
|
+
label: r.role!.charAt(0).toUpperCase() + r.role!.slice(1)
|
|
113
|
+
}))
|
|
114
|
+
}
|
|
82
115
|
)
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
export const getUserById = superAdminActionClient
|
|
119
|
+
.inputSchema(z.object({ userId: stringValidation }))
|
|
120
|
+
.action(
|
|
121
|
+
withWideEvent('getUserById', async ({ parsedInput: { userId } }) => {
|
|
122
|
+
const user = await db.query.usersTable.findFirst({
|
|
123
|
+
where: eq(usersTable.id, userId),
|
|
124
|
+
columns: { id: true, name: true, email: true, role: true }
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
if (!user) {
|
|
128
|
+
throw new AppError(AppErrorCode.NOT_FOUND, 'User not found.')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return user
|
|
132
|
+
})
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
/** Creates an account that signs in by magic link or OAuth with this email. */
|
|
136
|
+
export const createUser = superAdminActionClient
|
|
137
|
+
.inputSchema(createUserSchema)
|
|
138
|
+
.action(
|
|
139
|
+
withWideEvent('createUser', async ({ parsedInput }) => {
|
|
140
|
+
const [created] = await db
|
|
141
|
+
.insert(usersTable)
|
|
142
|
+
.values({
|
|
143
|
+
name: parsedInput.name,
|
|
144
|
+
email: parsedInput.email,
|
|
145
|
+
role: parsedInput.role
|
|
146
|
+
})
|
|
147
|
+
.returning()
|
|
148
|
+
.catch(error => rethrowUniqueViolation(error, EMAIL_TAKEN))
|
|
149
|
+
|
|
150
|
+
return created
|
|
151
|
+
})
|
|
152
|
+
)
|
|
83
153
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
154
|
+
export const updateUser = superAdminActionClient
|
|
155
|
+
.inputSchema(updateUserSchema)
|
|
156
|
+
.action(
|
|
157
|
+
withWideEvent('updateUser', async ({ parsedInput, ctx }) => {
|
|
158
|
+
// Demoting yourself would lock you out of this page with no way back.
|
|
159
|
+
if (parsedInput.id === ctx.user.id && parsedInput.role !== 'superadmin') {
|
|
160
|
+
throw new AppError(
|
|
161
|
+
AppErrorCode.BAD_REQUEST,
|
|
162
|
+
'You cannot remove your own superadmin role. Ask another superadmin to change it.'
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const [updated] = await db
|
|
167
|
+
.update(usersTable)
|
|
168
|
+
.set({
|
|
169
|
+
name: parsedInput.name,
|
|
170
|
+
email: parsedInput.email,
|
|
171
|
+
role: parsedInput.role
|
|
172
|
+
})
|
|
173
|
+
.where(eq(usersTable.id, parsedInput.id))
|
|
174
|
+
.returning()
|
|
175
|
+
.catch(error => rethrowUniqueViolation(error, EMAIL_TAKEN))
|
|
176
|
+
|
|
177
|
+
if (!updated) {
|
|
178
|
+
throw new AppError(AppErrorCode.NOT_FOUND, 'User not found.')
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return updated
|
|
182
|
+
})
|
|
183
|
+
)
|
|
@@ -11,10 +11,13 @@ export const AdminHeader: FC<{
|
|
|
11
11
|
image?: string | null
|
|
12
12
|
}
|
|
13
13
|
isSuperAdmin: boolean
|
|
14
|
-
|
|
14
|
+
isImpersonating: boolean
|
|
15
|
+
}> = ({ user, isSuperAdmin, isImpersonating }) => {
|
|
15
16
|
return (
|
|
16
17
|
<DashboardHeader
|
|
17
18
|
user={user}
|
|
19
|
+
isSuperAdmin={isSuperAdmin}
|
|
20
|
+
isImpersonating={isImpersonating}
|
|
18
21
|
search={<AdminSearch isSuperAdmin={isSuperAdmin} />}
|
|
19
22
|
/>
|
|
20
23
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { LayoutGrid } from 'lucide-react'
|
|
4
3
|
import Link from 'next/link'
|
|
5
4
|
import { FC } from 'react'
|
|
5
|
+
import { Logo } from '~/components/logo'
|
|
6
6
|
import { NavigationSidebar } from '~/components/navigation-sidebar'
|
|
7
7
|
import {
|
|
8
8
|
SidebarMenu,
|
|
@@ -10,25 +10,27 @@ import {
|
|
|
10
10
|
SidebarMenuItem
|
|
11
11
|
} from '~/components/ui/sidebar'
|
|
12
12
|
import { getAdminNavigation } from '~/lib/admin-navigation'
|
|
13
|
+
import { siteConfig } from '~/lib/siteConfig'
|
|
13
14
|
|
|
14
15
|
export const AdminSidebar: FC<{
|
|
15
|
-
companyName: string
|
|
16
16
|
isSuperAdmin: boolean
|
|
17
|
-
}> = ({
|
|
17
|
+
}> = ({ isSuperAdmin }) => {
|
|
18
18
|
return (
|
|
19
19
|
<NavigationSidebar
|
|
20
20
|
groups={getAdminNavigation(isSuperAdmin)}
|
|
21
21
|
header={
|
|
22
22
|
<SidebarMenu>
|
|
23
23
|
<SidebarMenuItem>
|
|
24
|
-
<SidebarMenuButton size="lg" asChild>
|
|
24
|
+
<SidebarMenuButton size="lg" asChild tooltip={siteConfig.name}>
|
|
25
25
|
<Link href="/admin">
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<span className="truncate text-xs">
|
|
26
|
+
<Logo size={32} showName={false} />
|
|
27
|
+
<div className="grid min-w-0 flex-1 text-left text-sm leading-tight group-data-[collapsible=icon]:hidden">
|
|
28
|
+
<span className="truncate font-medium">
|
|
29
|
+
{siteConfig.name}
|
|
30
|
+
</span>
|
|
31
|
+
<span className="text-muted-foreground truncate text-xs">
|
|
32
|
+
Admin Panel
|
|
33
|
+
</span>
|
|
32
34
|
</div>
|
|
33
35
|
</Link>
|
|
34
36
|
</SidebarMenuButton>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { MessageSquare } from 'lucide-react'
|
|
4
|
+
import { parseAsInteger, parseAsString, useQueryStates } from 'nuqs'
|
|
5
|
+
import { DataTable, type DataTableColumnDef } from '~/components/data-table'
|
|
6
|
+
import { SortOrderEnum } from '~/components/data-table/enum'
|
|
7
|
+
import { PageHeading } from '~/components/page-heading'
|
|
8
|
+
import { formatDate } from '~/lib/format-date'
|
|
9
|
+
import { useSafeActionQuery } from '~/lib/safe-action-client'
|
|
10
|
+
import { getContactLeads } from '../../actions/contact-leads'
|
|
11
|
+
|
|
12
|
+
type ContactLead = {
|
|
13
|
+
id: string
|
|
14
|
+
name: string
|
|
15
|
+
email: string
|
|
16
|
+
phone: string | null
|
|
17
|
+
subject: string
|
|
18
|
+
message: string
|
|
19
|
+
createdAt: Date
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const columns: DataTableColumnDef<ContactLead>[] = [
|
|
23
|
+
{
|
|
24
|
+
accessorKey: 'name',
|
|
25
|
+
header: 'Name',
|
|
26
|
+
enableSorting: true,
|
|
27
|
+
cell: ({ row }) => (
|
|
28
|
+
<div className="flex flex-col">
|
|
29
|
+
<span className="text-sm font-medium">{row.original.name}</span>
|
|
30
|
+
<span className="text-muted-foreground text-xs">
|
|
31
|
+
{row.original.email}
|
|
32
|
+
</span>
|
|
33
|
+
{row.original.phone && (
|
|
34
|
+
<span className="text-muted-foreground text-xs">
|
|
35
|
+
{row.original.phone}
|
|
36
|
+
</span>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
accessorKey: 'subject',
|
|
43
|
+
header: 'Subject',
|
|
44
|
+
enableSorting: false,
|
|
45
|
+
cell: ({ row }) => (
|
|
46
|
+
<span className="text-sm font-medium">{row.original.subject}</span>
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
accessorKey: 'message',
|
|
51
|
+
header: 'Message',
|
|
52
|
+
enableSorting: false,
|
|
53
|
+
cell: ({ row }) => (
|
|
54
|
+
<span className="text-muted-foreground line-clamp-2 max-w-100 text-sm">
|
|
55
|
+
{row.original.message}
|
|
56
|
+
</span>
|
|
57
|
+
)
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
accessorKey: 'createdAt',
|
|
61
|
+
header: 'Submitted On',
|
|
62
|
+
enableSorting: true,
|
|
63
|
+
cell: ({ row }) => formatDate(row.original.createdAt, { short: true })
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
export default function ContactLeadsPage() {
|
|
68
|
+
const [queryState, setQueryState] = useQueryStates({
|
|
69
|
+
page: parseAsInteger.withDefault(1),
|
|
70
|
+
limit: parseAsInteger.withDefault(10),
|
|
71
|
+
sortBy: parseAsString,
|
|
72
|
+
sortOrder: parseAsString,
|
|
73
|
+
search: parseAsString
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const params = {
|
|
77
|
+
page: queryState.page,
|
|
78
|
+
limit: queryState.limit,
|
|
79
|
+
sortBy: (queryState.sortBy ?? undefined) as
|
|
80
|
+
'createdAt' | 'name' | 'email' | undefined,
|
|
81
|
+
sortOrder: (queryState.sortOrder ?? undefined) as SortOrderEnum | undefined,
|
|
82
|
+
search: queryState.search ?? undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { data, isLoading } = useSafeActionQuery(
|
|
86
|
+
'admin-contact-leads',
|
|
87
|
+
getContactLeads,
|
|
88
|
+
params
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div className="space-y-6">
|
|
93
|
+
<PageHeading
|
|
94
|
+
title="Contact Leads"
|
|
95
|
+
description="View contact form submissions."
|
|
96
|
+
icon={MessageSquare}
|
|
97
|
+
/>
|
|
98
|
+
|
|
99
|
+
<DataTable
|
|
100
|
+
columns={columns}
|
|
101
|
+
data={data?.[0]}
|
|
102
|
+
isLoading={isLoading}
|
|
103
|
+
totalCount={data?.[1]}
|
|
104
|
+
enableSearch
|
|
105
|
+
initialSearch={params.search}
|
|
106
|
+
searchPlaceholder="Search by name, email, subject, or message…"
|
|
107
|
+
manualPagination
|
|
108
|
+
manualSorting
|
|
109
|
+
pageIndex={params.page - 1}
|
|
110
|
+
pageSize={params.limit}
|
|
111
|
+
onParamsChange={({ page, limit, sortBy, sortOrder, search }) =>
|
|
112
|
+
setQueryState({
|
|
113
|
+
page,
|
|
114
|
+
limit,
|
|
115
|
+
sortBy: sortBy ?? null,
|
|
116
|
+
sortOrder: sortOrder ?? null,
|
|
117
|
+
search: search ?? null
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
)
|
|
123
|
+
}
|