@xk2800/nextjs-template 0.7.2-beta.0 → 0.7.2-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/README.md +1 -0
  2. package/components/auth/{loginErrorRecovery.tsx → forms/login-error-recovery.tsx} +1 -1
  3. package/components/auth/{emailPasswordLogin.tsx → forms/login-form.tsx} +8 -8
  4. package/components/auth/{emailPasswordSignup.tsx → forms/signup-form.tsx} +11 -8
  5. package/components/auth/{authCard.tsx → layout/auth-card.tsx} +5 -5
  6. package/components/auth/{authShell.tsx → layout/auth-shell.tsx} +17 -5
  7. package/components/auth/{oneTap.tsx → methods/one-tap.tsx} +2 -2
  8. package/components/auth/{passkeyLogin.tsx → methods/passkey-login.tsx} +2 -2
  9. package/components/auth/{socialLogin.tsx → methods/social-login.tsx} +3 -3
  10. package/components/auth/{twoFactorVerifyForm.tsx → mfa/two-factor-verify-form.tsx} +5 -5
  11. package/components/auth/{forgotPasswordForm.tsx → recovery/forgot-password-form.tsx} +4 -4
  12. package/components/auth/{resetPasswordForm.tsx → recovery/reset-password-form.tsx} +4 -4
  13. package/components/auth/{deviceCheck.tsx → session/device-check.tsx} +3 -3
  14. package/components/auth/{logoutButtons.tsx → session/logout-buttons.tsx} +2 -2
  15. package/components/dashboard/admin/{activityLogsSection.tsx → activity-logs/activity-logs-section.tsx} +1 -1
  16. package/components/dashboard/admin/activity-logs/admin-activity-logs-table.tsx +375 -0
  17. package/components/dashboard/admin/activity-logs/audit-severity-badge.tsx +50 -0
  18. package/components/dashboard/admin/activity-logs/security-highlights-collapsible.tsx +129 -0
  19. package/components/dashboard/admin/{adminActivityLogsSkeleton.tsx → activity-logs/skeletons/activity-logs-skeleton.tsx} +2 -2
  20. package/components/dashboard/admin/{adminStatsGrid.tsx → home/admin-stats-grid.tsx} +1 -1
  21. package/components/dashboard/admin/{deviceThrottleCard.tsx → home/device-throttle-card.tsx} +8 -5
  22. package/components/dashboard/admin/{deviceThrottleTable.tsx → home/device-throttle-table.tsx} +3 -3
  23. package/components/dashboard/admin/{newDeviceCard.tsx → home/new-device-card.tsx} +6 -2
  24. package/components/dashboard/admin/{newDeviceTable.tsx → home/new-device-table.tsx} +4 -4
  25. package/components/dashboard/admin/{sharedDeviceCard.tsx → home/shared-device-card.tsx} +3 -3
  26. package/components/dashboard/admin/{sharedDeviceTable.tsx → home/shared-device-table.tsx} +3 -3
  27. package/components/dashboard/admin/{adminStatsGridSkeleton.tsx → home/skeletons/admin-stats-skeleton.tsx} +2 -2
  28. package/components/dashboard/admin/{broadcastActions.tsx → marketing/broadcast-actions.tsx} +3 -3
  29. package/components/dashboard/admin/{confirmSendDialog.tsx → marketing/confirm-send-dialog.tsx} +1 -1
  30. package/components/dashboard/admin/{marketingEmailForm.tsx → marketing/marketing-email-form.tsx} +7 -7
  31. package/components/dashboard/admin/{marketingSection.tsx → marketing/marketing-section.tsx} +6 -6
  32. package/components/dashboard/admin/{subscribersCard.tsx → marketing/subscribers-card.tsx} +3 -3
  33. package/components/dashboard/admin/{feedbackTestForm.tsx → system-settings/feedback-test-form.tsx} +4 -4
  34. package/components/dashboard/admin/{systemSettingsSkeleton.tsx → system-settings/skeletons/system-settings-skeleton.tsx} +2 -2
  35. package/components/dashboard/admin/system-settings/system-settings-form.tsx +362 -0
  36. package/components/dashboard/admin/{systemSettingsSection.tsx → system-settings/system-settings-section.tsx} +3 -2
  37. package/components/dashboard/admin/users/admin-user-actions.tsx +238 -0
  38. package/components/dashboard/admin/users/admin-user-profile-card.tsx +70 -0
  39. package/components/dashboard/admin/users/admin-user-security-card.tsx +47 -0
  40. package/components/dashboard/admin/users/admin-user-status-card.tsx +89 -0
  41. package/components/dashboard/admin/{adminUsersTable.tsx → users/admin-users-table.tsx} +129 -132
  42. package/components/dashboard/admin/{adminUserActivityLogCard.tsx → users/detail/admin-user-activity-log-card.tsx} +3 -3
  43. package/components/dashboard/admin/{adminUserActivityLogTable.tsx → users/detail/admin-user-activity-log-table.tsx} +3 -3
  44. package/components/dashboard/admin/{adminUserConsentCard.tsx → users/detail/admin-user-consent-card.tsx} +4 -4
  45. package/components/dashboard/admin/{adminUserDevicesCard.tsx → users/detail/admin-user-devices-card.tsx} +2 -2
  46. package/components/dashboard/admin/{adminUserLoginInfoCard.tsx → users/detail/admin-user-login-info-card.tsx} +3 -3
  47. package/components/dashboard/admin/{adminUserLoginInfoTable.tsx → users/detail/admin-user-login-info-table.tsx} +3 -3
  48. package/components/dashboard/admin/{adminUserSessionsCard.tsx → users/detail/admin-user-sessions-card.tsx} +5 -5
  49. package/components/dashboard/admin/{impersonationLogCard.tsx → users/impersonation-log-card.tsx} +10 -5
  50. package/components/dashboard/admin/users/impersonation-tab.tsx +255 -0
  51. package/components/dashboard/admin/users/invite-user-dialog.tsx +80 -0
  52. package/components/dashboard/admin/{revokeAllSessionsButton.tsx → users/revoke-all-sessions.tsx} +5 -3
  53. package/components/dashboard/admin/{adminUsersSkeleton.tsx → users/skeletons/admin-users-skeleton.tsx} +2 -2
  54. package/components/dashboard/admin/{usersSection.tsx → users/users-section.tsx} +1 -1
  55. package/components/dashboard/{errorFeedback.tsx → common/error-feedback.tsx} +1 -1
  56. package/components/dashboard/{feedbackDialog.tsx → common/feedback-dialog.tsx} +4 -4
  57. package/components/dashboard/{sectionErrorFallback.tsx → common/section-error-fallback.tsx} +1 -1
  58. package/components/dashboard/{verifyEmailButton.tsx → common/verify-email-button.tsx} +2 -2
  59. package/components/dashboard/{appSidebar.tsx → layout/app-sidebar.tsx} +11 -8
  60. package/components/dashboard/{dashboardHeader.tsx → layout/dashboard-header.tsx} +1 -1
  61. package/components/dashboard/{impersonationBanner.tsx → layout/impersonation-banner.tsx} +2 -2
  62. package/components/dashboard/layout/mobile-nav.tsx +95 -0
  63. package/components/dashboard/{navStyleToggle.tsx → layout/nav-style-toggle.tsx} +1 -1
  64. package/components/dashboard/{topNav.tsx → layout/top-nav.tsx} +19 -38
  65. package/components/dashboard/{installAppCard.tsx → overview/install-app-card.tsx} +2 -2
  66. package/components/dashboard/{accountDetailsCard.tsx → settings/account-details-card.tsx} +5 -5
  67. package/components/dashboard/{activityLogsCard.tsx → settings/activity-logs-card.tsx} +6 -6
  68. package/components/dashboard/{activityLogsSection.tsx → settings/activity-logs-section.tsx} +1 -1
  69. package/components/dashboard/{adminSection.tsx → settings/admin-section.tsx} +2 -2
  70. package/components/dashboard/{deleteAccountCard.tsx → settings/delete-account-card.tsx} +7 -7
  71. package/components/dashboard/{marketingUpdatesCard.tsx → settings/marketing-updates-card.tsx} +3 -3
  72. package/components/dashboard/{marketingUpdatesSection.tsx → settings/marketing-updates-section.tsx} +1 -1
  73. package/components/dashboard/{passkeysCard.tsx → settings/passkeys-card.tsx} +8 -8
  74. package/components/dashboard/{profileCard.tsx → settings/profile-card.tsx} +4 -4
  75. package/components/dashboard/{sessionsCard.tsx → settings/sessions/sessions-card.tsx} +6 -6
  76. package/components/dashboard/{sessionsSection.tsx → settings/sessions/sessions-section.tsx} +1 -1
  77. package/components/dashboard/{sessionsCardSkeleton.tsx → settings/sessions/skeletons/sessions-card-skeleton.tsx} +2 -2
  78. package/components/dashboard/{activityLogsCardSkeleton.tsx → settings/skeletons/activity-logs-card-skeleton.tsx} +2 -2
  79. package/components/dashboard/{twoFactorCard.tsx → settings/two-factor-card.tsx} +8 -8
  80. package/components/email/team/workspace-invite.tsx +51 -0
  81. package/components/email/{send-email-button.tsx → ui/send-email-button.tsx} +1 -1
  82. package/components/error-boundary.tsx +32 -0
  83. package/components/settings/appearance/appearance-section.tsx +64 -0
  84. package/components/settings/index.ts +5 -0
  85. package/components/settings/notifications/notifications-section.tsx +31 -0
  86. package/components/settings/profile/profile-section.tsx +38 -0
  87. package/components/settings/security/security-section.tsx +24 -0
  88. package/components/settings/settings-nav.tsx +35 -0
  89. package/components/site/{cookie-banner.tsx → compliance/cookie-banner.tsx} +6 -6
  90. package/components/site/push/push-notifications-card.tsx +117 -0
  91. package/components/ui/collapsible.tsx +9 -0
  92. package/components/ui/column-picker.tsx +1 -1
  93. package/components/ui/data-table.tsx +1 -1
  94. package/components/ui/dialog.tsx +46 -13
  95. package/components/ui/drawer.tsx +88 -0
  96. package/components/ui/tabs.tsx +52 -0
  97. package/dist/activity/logger.d.mts +2 -1
  98. package/dist/activity/logger.d.ts +2 -1
  99. package/dist/activity/logger.js +66 -16
  100. package/dist/activity/logger.js.map +1 -1
  101. package/dist/activity/logger.mjs +4 -4
  102. package/dist/activity/queries.d.mts +32 -21
  103. package/dist/activity/queries.d.ts +32 -21
  104. package/dist/activity/queries.js +86 -23
  105. package/dist/activity/queries.js.map +1 -1
  106. package/dist/activity/queries.mjs +27 -14
  107. package/dist/activity/queries.mjs.map +1 -1
  108. package/dist/admin/queries.d.mts +2 -1
  109. package/dist/admin/queries.d.ts +2 -1
  110. package/dist/admin/queries.js +48 -18
  111. package/dist/admin/queries.js.map +1 -1
  112. package/dist/admin/queries.mjs +9 -9
  113. package/dist/admin/queries.mjs.map +1 -1
  114. package/dist/api/feedback.js +284 -249
  115. package/dist/api/feedback.js.map +1 -1
  116. package/dist/api/feedback.mjs +14 -12
  117. package/dist/api/feedback.mjs.map +1 -1
  118. package/dist/api/marketing.js +302 -267
  119. package/dist/api/marketing.js.map +1 -1
  120. package/dist/api/marketing.mjs +16 -25
  121. package/dist/api/marketing.mjs.map +1 -1
  122. package/dist/auth/helpers.d.mts +63 -21
  123. package/dist/auth/helpers.d.ts +63 -21
  124. package/dist/auth/helpers.js +314 -268
  125. package/dist/auth/helpers.js.map +1 -1
  126. package/dist/auth/helpers.mjs +9 -9
  127. package/dist/auth/index.d.mts +86 -47
  128. package/dist/auth/index.d.ts +86 -47
  129. package/dist/auth/index.js +278 -245
  130. package/dist/auth/index.js.map +1 -1
  131. package/dist/auth/index.mjs +8 -8
  132. package/dist/auth-client/index.d.mts +1214 -2526
  133. package/dist/auth-client/index.d.ts +1214 -2526
  134. package/dist/auth-client/index.js +37 -3
  135. package/dist/auth-client/index.js.map +1 -1
  136. package/dist/auth-client/index.mjs +19 -3
  137. package/dist/auth-client/index.mjs.map +1 -1
  138. package/dist/{chunk-KA2KMGPY.mjs → chunk-3BH6BVBQ.mjs} +17 -8
  139. package/dist/chunk-3BH6BVBQ.mjs.map +1 -0
  140. package/dist/chunk-D56ENLSX.mjs +6 -0
  141. package/dist/chunk-D56ENLSX.mjs.map +1 -0
  142. package/dist/{chunk-HUEDEAY3.mjs → chunk-DCPVEZS7.mjs} +14 -4
  143. package/dist/chunk-DCPVEZS7.mjs.map +1 -0
  144. package/dist/{chunk-NQELV53D.mjs → chunk-DWLMCMXF.mjs} +4 -4
  145. package/dist/chunk-DWLMCMXF.mjs.map +1 -0
  146. package/dist/{chunk-YH53UPUW.mjs → chunk-EXMUANQ3.mjs} +4 -4
  147. package/dist/chunk-EXMUANQ3.mjs.map +1 -0
  148. package/dist/{chunk-VHNGYAIG.mjs → chunk-IH6CMZIN.mjs} +213 -220
  149. package/dist/chunk-IH6CMZIN.mjs.map +1 -0
  150. package/dist/chunk-LADVCLEQ.mjs +43 -0
  151. package/dist/chunk-LADVCLEQ.mjs.map +1 -0
  152. package/dist/{chunk-A6JXMHOQ.mjs → chunk-NJBRKKLK.mjs} +46 -7
  153. package/dist/chunk-NJBRKKLK.mjs.map +1 -0
  154. package/dist/{chunk-6OAHCEDJ.mjs → chunk-QDUPSU5O.mjs} +5 -5
  155. package/dist/chunk-QDUPSU5O.mjs.map +1 -0
  156. package/dist/{chunk-JUSU6UZA.mjs → chunk-S23GC776.mjs} +41 -29
  157. package/dist/chunk-S23GC776.mjs.map +1 -0
  158. package/dist/{chunk-L242CZ64.mjs → chunk-TIR7KHXL.mjs} +3 -3
  159. package/dist/chunk-TIR7KHXL.mjs.map +1 -0
  160. package/dist/{chunk-4F6KE47S.mjs → chunk-ZOQHHFYA.mjs} +7 -4
  161. package/dist/chunk-ZOQHHFYA.mjs.map +1 -0
  162. package/dist/config/env.d.mts +3 -0
  163. package/dist/config/env.d.ts +3 -0
  164. package/dist/config/env.js +12 -2
  165. package/dist/config/env.js.map +1 -1
  166. package/dist/config/env.mjs +1 -1
  167. package/dist/db/index.d.mts +3 -7
  168. package/dist/db/index.d.ts +3 -7
  169. package/dist/db/index.js +61 -13
  170. package/dist/db/index.js.map +1 -1
  171. package/dist/db/index.mjs +3 -3
  172. package/dist/db/schema.d.mts +1 -1
  173. package/dist/db/schema.d.ts +1 -1
  174. package/dist/db/schema.js +14 -5
  175. package/dist/db/schema.js.map +1 -1
  176. package/dist/db/schema.mjs +1 -1
  177. package/dist/errors.d.mts +2 -1
  178. package/dist/errors.d.ts +2 -1
  179. package/dist/errors.js +62 -14
  180. package/dist/errors.js.map +1 -1
  181. package/dist/errors.mjs +4 -4
  182. package/dist/marketing/index.d.mts +4 -3
  183. package/dist/marketing/index.d.ts +4 -3
  184. package/dist/marketing/index.js +14 -4
  185. package/dist/marketing/index.js.map +1 -1
  186. package/dist/marketing/index.mjs +3 -3
  187. package/dist/{email-template-passkey-change-F5Q2SXHD.mjs → passkey-changed-KEGNTIPE.mjs} +2 -2
  188. package/dist/passkey-changed-KEGNTIPE.mjs.map +1 -0
  189. package/dist/{email-template-reset-password-QTCQNXOD.mjs → reset-password-64VQEXBW.mjs} +2 -2
  190. package/dist/reset-password-64VQEXBW.mjs.map +1 -0
  191. package/dist/{schema-DzC5zdOq.d.mts → schema-BujGgvAy.d.mts} +35 -2
  192. package/dist/{schema-DzC5zdOq.d.ts → schema-BujGgvAy.d.ts} +35 -2
  193. package/dist/sessions/queries.js +61 -13
  194. package/dist/sessions/queries.js.map +1 -1
  195. package/dist/sessions/queries.mjs +3 -3
  196. package/dist/sessions/queries.mjs.map +1 -1
  197. package/dist/settings/queries.d.mts +11 -2
  198. package/dist/settings/queries.d.ts +11 -2
  199. package/dist/settings/queries.js +84 -14
  200. package/dist/settings/queries.js.map +1 -1
  201. package/dist/settings/queries.mjs +4 -4
  202. package/dist/users/queries.d.mts +41 -21
  203. package/dist/users/queries.d.ts +41 -21
  204. package/dist/users/queries.js +117 -24
  205. package/dist/users/queries.js.map +1 -1
  206. package/dist/users/queries.mjs +57 -17
  207. package/dist/users/queries.mjs.map +1 -1
  208. package/dist/{email-template-verify-email-WZDCCAKK.mjs → verify-email-4KMNGDKN.mjs} +2 -2
  209. package/dist/verify-email-4KMNGDKN.mjs.map +1 -0
  210. package/lib/{auth-client.ts → auth/client.ts} +22 -2
  211. package/lib/{maintenance.ts → config/maintenance.ts} +0 -1
  212. package/lib/push/client.ts +39 -0
  213. package/lib/security/activity-severity.ts +57 -0
  214. package/lib/{request-info.ts → utils/request-info.ts} +7 -3
  215. package/package.json +177 -75
  216. package/scripts/check-deps.mjs +68 -0
  217. package/components/dashboard/admin/adminActivityLogsTable.tsx +0 -323
  218. package/components/dashboard/admin/adminUserStatusCard.tsx +0 -57
  219. package/components/dashboard/admin/systemSettingsForm.tsx +0 -289
  220. package/dist/chunk-4C7JHGT5.mjs +0 -30
  221. package/dist/chunk-4C7JHGT5.mjs.map +0 -1
  222. package/dist/chunk-4F6KE47S.mjs.map +0 -1
  223. package/dist/chunk-6OAHCEDJ.mjs.map +0 -1
  224. package/dist/chunk-A6JXMHOQ.mjs.map +0 -1
  225. package/dist/chunk-HUEDEAY3.mjs.map +0 -1
  226. package/dist/chunk-JUSU6UZA.mjs.map +0 -1
  227. package/dist/chunk-KA2KMGPY.mjs.map +0 -1
  228. package/dist/chunk-L242CZ64.mjs.map +0 -1
  229. package/dist/chunk-NQELV53D.mjs.map +0 -1
  230. package/dist/chunk-VHNGYAIG.mjs.map +0 -1
  231. package/dist/chunk-YH53UPUW.mjs.map +0 -1
  232. package/dist/email-template-passkey-change-F5Q2SXHD.mjs.map +0 -1
  233. package/dist/email-template-reset-password-QTCQNXOD.mjs.map +0 -1
  234. package/dist/email-template-verify-email-WZDCCAKK.mjs.map +0 -1
  235. /package/components/dashboard/{heartbeat.tsx → common/heartbeat.tsx} +0 -0
  236. /package/components/email/{email-template-reset-password.tsx → auth/reset-password.tsx} +0 -0
  237. /package/components/email/{email-template-verify-email.tsx → auth/verify-email.tsx} +0 -0
  238. /package/components/email/{email-template-welcome.tsx → auth/welcome.tsx} +0 -0
  239. /package/components/email/{email-template.tsx → layout/base-layout.tsx} +0 -0
  240. /package/components/email/{email-template-2.tsx → marketing/general-announcement.tsx} +0 -0
  241. /package/components/email/{email-template-banned.tsx → security/account-banned.tsx} +0 -0
  242. /package/components/email/{email-template-new-device.tsx → security/new-device-alert.tsx} +0 -0
  243. /package/components/email/{email-template-passkey-change.tsx → security/passkey-changed.tsx} +0 -0
  244. /package/lib/{cookie-consent.ts → security/cookie-consent.ts} +0 -0
  245. /package/lib/{cookie-names.ts → security/cookie-names.ts} +0 -0
  246. /package/lib/{device-fingerprint.ts → security/device-fingerprint.ts} +0 -0
  247. /package/lib/{formatters.ts → utils/formatters.ts} +0 -0
  248. /package/lib/{recalculate-columns.ts → utils/recalculate-columns.ts} +0 -0
@@ -2,35 +2,33 @@
2
2
 
3
3
  import Link from "next/link"
4
4
  import { usePathname } from "next/navigation"
5
- import { ArrowLeft, LogOut } from "lucide-react"
5
+ import { LogOut } from "lucide-react"
6
6
 
7
- import { authClient } from "../../lib/auth-client"
8
- import { cn } from "../../lib/utils"
9
- import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"
10
- import { Button } from "../ui/button"
11
- import { adminLinks, workspaceLinks, type AppSidebarProps } from "./appSidebar"
7
+ import { authClient } from "../../../lib/auth/client"
8
+ import { cn } from "../../../lib/utils"
9
+ import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar"
10
+ import { Button } from "../../ui/button"
11
+ import { adminLinks, workspaceLinks, type AppSidebarProps } from "./app-sidebar"
12
+ import MobileNav, { type MobileNavAction, type MobileNavVariant } from "./mobile-nav"
12
13
 
13
14
  export default function TopNav({
14
15
  user,
15
16
  isAdmin,
16
17
  brandName = "Template",
17
18
  brandHref = "/",
19
+ links: workspace = workspaceLinks,
18
20
  actions,
19
- }: AppSidebarProps & { actions?: React.ReactNode }) {
21
+ mobileNav = "tabs",
22
+ mobileAction,
23
+ }: AppSidebarProps & {
24
+ actions?: React.ReactNode
25
+ /** Bottom navigation style below `md`. */
26
+ mobileNav?: MobileNavVariant
27
+ /** Optional centre button for the "dock" style. */
28
+ mobileAction?: MobileNavAction
29
+ }) {
20
30
  const pathname = usePathname()
21
- const links = isAdmin ? [...workspaceLinks, ...adminLinks] : workspaceLinks
22
- const inAdmin = isAdmin && pathname.startsWith("/dashboard/admin")
23
- const tabs = inAdmin
24
- ? [...adminLinks, { href: "/dashboard", label: "Exit", icon: ArrowLeft, exit: true }]
25
- : isAdmin
26
- ? [...workspaceLinks, { ...adminLinks[0], label: "Admin" }]
27
- : workspaceLinks
28
- const tabActive = (href: string, exit?: boolean) =>
29
- !exit &&
30
- (href === "/dashboard" || href === adminLinks[0].href
31
- ? pathname === href
32
- : pathname.startsWith(href))
33
-
31
+ const links = isAdmin ? [...workspace, ...adminLinks] : workspace
34
32
  return (
35
33
  <>
36
34
  <header className="sticky top-0 z-20 border-b bg-background">
@@ -72,24 +70,7 @@ export default function TopNav({
72
70
  </Button>
73
71
  </div>
74
72
  </header>
75
- <nav
76
- aria-label="Primary"
77
- className="fixed inset-x-0 bottom-0 z-20 flex border-t bg-background pb-[env(safe-area-inset-bottom)] md:hidden"
78
- >
79
- {tabs.map(({ href, label, icon: Icon, ...rest }) => (
80
- <Link
81
- key={href}
82
- href={href}
83
- className={cn(
84
- "flex min-w-0 flex-1 flex-col items-center justify-start gap-0.5 px-1 py-2 text-center text-[11px] leading-tight text-muted-foreground",
85
- tabActive(href, "exit" in rest) && "font-medium text-foreground"
86
- )}
87
- >
88
- <Icon className="size-5" />
89
- <span className="w-full text-center">{label}</span>
90
- </Link>
91
- ))}
92
- </nav>
73
+ <MobileNav isAdmin={isAdmin} links={workspace} variant={mobileNav} action={mobileAction} />
93
74
  </>
94
75
  )
95
76
  }
@@ -2,8 +2,8 @@
2
2
 
3
3
  import { useEffect, useState, type ReactNode } from 'react'
4
4
  import { CircleCheck, Download } from 'lucide-react'
5
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../ui/card'
6
- import { Button } from '../ui/button'
5
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
6
+ import { Button } from '../../ui/button'
7
7
 
8
8
  // Chrome/Edge's install event; not in the DOM typings yet.
9
9
  type InstallPromptEvent = Event & { prompt: () => Promise<{ outcome: 'accepted' | 'dismissed' }> }
@@ -1,8 +1,8 @@
1
- import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"
2
- import { Badge } from "../ui/badge"
3
- import { Separator } from "../ui/separator"
4
- import { formatDate } from "../../lib/formatters"
5
- import VerifyEmailButton from "./verifyEmailButton"
1
+ import { Card, CardContent, CardHeader, CardTitle } from "../../ui/card"
2
+ import { Badge } from "../../ui/badge"
3
+ import { Separator } from "../../ui/separator"
4
+ import { formatDate } from "../../../lib/utils/formatters"
5
+ import VerifyEmailButton from "../common/verify-email-button"
6
6
 
7
7
  type User = {
8
8
  id: string
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
 
3
3
  import { useEffect, useState } from 'react'
4
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../ui/card'
5
- import { Badge } from '../ui/badge'
6
- import { Skeleton } from '../ui/skeleton'
7
- import { DataTable, type Column } from '../ui/data-table'
8
- import { formatDateTime, actionBadgeVariant } from '../../lib/formatters'
4
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
5
+ import { Badge } from '../../ui/badge'
6
+ import { Skeleton } from '../../ui/skeleton'
7
+ import { DataTable, type Column } from '../../ui/data-table'
8
+ import { formatDateTime, actionBadgeVariant } from '../../../lib/utils/formatters'
9
9
 
10
10
  interface ActivityLog {
11
11
  id: string
@@ -16,7 +16,7 @@ interface ActivityLog {
16
16
  deviceLabel?: string
17
17
  location?: string
18
18
  createdAt: Date | string
19
- userId: string
19
+ userId: string | null
20
20
  userName?: string | null
21
21
  userEmail?: string | null
22
22
  }
@@ -1,5 +1,5 @@
1
1
  import { getUserActivityLogs, getAllActivityLogs } from "@xk2800/nextjs-template/activity/queries"
2
- import ActivityLogsCard from "./activityLogsCard"
2
+ import ActivityLogsCard from "./activity-logs-card"
3
3
 
4
4
  export default async function ActivityLogsSection({
5
5
  userId,
@@ -1,7 +1,7 @@
1
1
  import Link from "next/link"
2
2
  import { ShieldCheck, LayoutDashboard } from "lucide-react"
3
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"
4
- import { Button } from "../ui/button"
3
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../../ui/card"
4
+ import { Button } from "../../ui/button"
5
5
 
6
6
  export default function AdminSection() {
7
7
  return (
@@ -2,10 +2,10 @@
2
2
 
3
3
  import { useEffect, useState } from 'react'
4
4
  import { toast } from 'sonner'
5
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../ui/card'
6
- import { Button } from '../ui/button'
7
- import { Input } from '../ui/input'
8
- import { PasswordInput } from '../ui/password-input'
5
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
6
+ import { Button } from '../../ui/button'
7
+ import { Input } from '../../ui/input'
8
+ import { PasswordInput } from '../../ui/password-input'
9
9
  import {
10
10
  AlertDialog,
11
11
  AlertDialogCancel,
@@ -14,9 +14,9 @@ import {
14
14
  AlertDialogFooter,
15
15
  AlertDialogHeader,
16
16
  AlertDialogTitle,
17
- } from '../ui/alert-dialog'
18
- import { authClient, useSession } from '../../lib/auth-client'
19
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'
17
+ } from '../../ui/alert-dialog'
18
+ import { authClient, useSession } from '../../../lib/auth/client'
19
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/tooltip'
20
20
 
21
21
  type Props = {
22
22
  /**
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { useState } from "react"
4
4
  import { toast } from "sonner"
5
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"
6
- import { Switch } from "../ui/switch"
7
- import { Label } from "../ui/label"
5
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../../ui/card"
6
+ import { Switch } from "../../ui/switch"
7
+ import { Label } from "../../ui/label"
8
8
 
9
9
  export default function MarketingUpdatesCard({
10
10
  initialSubscribed,
@@ -1,5 +1,5 @@
1
1
  import { isSubscribed, MARKETING_SEGMENT_ID } from "@xk2800/nextjs-template/marketing"
2
- import MarketingUpdatesCard from "./marketingUpdatesCard"
2
+ import MarketingUpdatesCard from "./marketing-updates-card"
3
3
 
4
4
  // Dashboard opt-in for product updates. Renders nothing until
5
5
  // RESEND_MARKETING_SEGMENT_ID is set.
@@ -2,11 +2,11 @@
2
2
 
3
3
  import { useCallback, useEffect, useState } from 'react'
4
4
  import { toast } from 'sonner'
5
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../ui/card'
6
- import { Button } from '../ui/button'
7
- import { Input } from '../ui/input'
8
- import { Skeleton } from '../ui/skeleton'
9
- import { DataTable, type Column } from '../ui/data-table'
5
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
6
+ import { Button } from '../../ui/button'
7
+ import { Input } from '../../ui/input'
8
+ import { Skeleton } from '../../ui/skeleton'
9
+ import { DataTable, type Column } from '../../ui/data-table'
10
10
  import {
11
11
  AlertDialog,
12
12
  AlertDialogAction,
@@ -16,9 +16,9 @@ import {
16
16
  AlertDialogFooter,
17
17
  AlertDialogHeader,
18
18
  AlertDialogTitle,
19
- } from '../ui/alert-dialog'
20
- import { formatDateTime } from '../../lib/formatters'
21
- import { authClient } from '../../lib/auth-client'
19
+ } from '../../ui/alert-dialog'
20
+ import { formatDateTime } from '../../../lib/utils/formatters'
21
+ import { authClient } from '../../../lib/auth/client'
22
22
 
23
23
  type Passkey = {
24
24
  id: string
@@ -1,7 +1,7 @@
1
- import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"
2
- import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"
3
- import { Badge } from "../ui/badge"
4
- import { getUserInitials } from "../../lib/formatters"
1
+ import { Card, CardContent, CardHeader, CardTitle } from "../../ui/card"
2
+ import { Avatar, AvatarFallback, AvatarImage } from "../../ui/avatar"
3
+ import { Badge } from "../../ui/badge"
4
+ import { getUserInitials } from "../../../lib/utils/formatters"
5
5
 
6
6
  type User = {
7
7
  id: string
@@ -1,9 +1,9 @@
1
1
  'use client'
2
2
 
3
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"
4
- import { Badge } from "../ui/badge"
5
- import { Button } from "../ui/button"
6
- import { DataTable, type Column } from "../ui/data-table"
3
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../../../ui/card"
4
+ import { Badge } from "../../../ui/badge"
5
+ import { Button } from "../../../ui/button"
6
+ import { DataTable, type Column } from "../../../ui/data-table"
7
7
  import {
8
8
  AlertDialog,
9
9
  AlertDialogAction,
@@ -13,8 +13,8 @@ import {
13
13
  AlertDialogFooter,
14
14
  AlertDialogHeader,
15
15
  AlertDialogTitle,
16
- } from "../ui/alert-dialog"
17
- import { formatDateTime } from "../../lib/formatters"
16
+ } from "../../../ui/alert-dialog"
17
+ import { formatDateTime } from "../../../../lib/utils/formatters"
18
18
  import { useState } from "react"
19
19
  import { useRouter } from "next/navigation"
20
20
  import { toast } from "sonner"
@@ -1,7 +1,7 @@
1
1
  import { cookies } from "next/headers"
2
2
  import { getUserSessions } from "@xk2800/nextjs-template/sessions/queries"
3
3
  import { getSystemSettings } from "@xk2800/nextjs-template/settings/queries"
4
- import SessionsCard from "./sessionsCard"
4
+ import SessionsCard from "./sessions-card"
5
5
 
6
6
  export default async function SessionsSection({ userId }: { userId: string }) {
7
7
  const [allSessions, settings] = await Promise.all([
@@ -1,5 +1,5 @@
1
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"
2
- import { Skeleton } from "../ui/skeleton"
1
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../../../../ui/card"
2
+ import { Skeleton } from "../../../../ui/skeleton"
3
3
 
4
4
  export default function SessionsCardSkeleton() {
5
5
  return (
@@ -1,5 +1,5 @@
1
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"
2
- import { Skeleton } from "../ui/skeleton"
1
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../../../ui/card"
2
+ import { Skeleton } from "../../../ui/skeleton"
3
3
 
4
4
  export default function ActivityLogsCardSkeleton() {
5
5
  return (
@@ -4,12 +4,12 @@ import { useState } from 'react'
4
4
  import { useRouter } from 'next/navigation'
5
5
  import QRCode from 'react-qr-code'
6
6
  import { toast } from 'sonner'
7
- import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../ui/card'
8
- import { Button } from '../ui/button'
9
- import { Input } from '../ui/input'
10
- import { Label } from '../ui/label'
11
- import { PasswordInput } from '../ui/password-input'
12
- import { Badge } from '../ui/badge'
7
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
8
+ import { Button } from '../../ui/button'
9
+ import { Input } from '../../ui/input'
10
+ import { Label } from '../../ui/label'
11
+ import { PasswordInput } from '../../ui/password-input'
12
+ import { Badge } from '../../ui/badge'
13
13
  import {
14
14
  Dialog,
15
15
  DialogContent,
@@ -17,8 +17,8 @@ import {
17
17
  DialogFooter,
18
18
  DialogHeader,
19
19
  DialogTitle,
20
- } from '../ui/dialog'
21
- import { useSession, authClient } from '../../lib/auth-client'
20
+ } from '../../ui/dialog'
21
+ import { useSession, authClient } from '../../../lib/auth/client'
22
22
 
23
23
  type SetupStep = 'password' | 'verify' | 'backup'
24
24
 
@@ -0,0 +1,51 @@
1
+ import {
2
+ Html,
3
+ Head,
4
+ Body,
5
+ Container,
6
+ Section,
7
+ Text,
8
+ Heading,
9
+ Button,
10
+ Tailwind,
11
+ } from '@react-email/components';
12
+
13
+ interface EmailTemplateInviteProps {
14
+ firstName: string;
15
+ url: string;
16
+ }
17
+
18
+ // Sent by the admin invite route (rides the reset-password flow, see server/auth.ts).
19
+ export function EmailTemplateInvite({ firstName, url }: EmailTemplateInviteProps) {
20
+ return (
21
+ <Html>
22
+ <Head />
23
+ <Tailwind>
24
+ <Body className="bg-white font-sans">
25
+ <Container className="mx-auto max-w-[560px] px-0 pt-5 pb-12">
26
+ <Section className="rounded-xl bg-[#f8f9fa] p-10 text-center">
27
+ <Heading className="mb-3 text-[28px] font-bold text-[#1a1a1a]">
28
+ You’re invited
29
+ </Heading>
30
+ <Text className="mb-8 text-base leading-6 text-[#666666]">
31
+ Hi {firstName}, an admin invited you to join. Set a password with the button below, or just sign in with a social provider using this email address. This link expires in 7 days.
32
+ </Text>
33
+ <Section className="mb-8">
34
+ <Button
35
+ href={url}
36
+ className="rounded-md bg-black px-8 py-3 text-base font-bold text-white no-underline"
37
+ >
38
+ Set password and join
39
+ </Button>
40
+ </Section>
41
+ <Text className="break-all text-[13px] leading-5 text-[#999999]">
42
+ Or paste this link into your browser:<br />
43
+ <a href={url} className="text-black underline">{url}</a>
44
+ </Text>
45
+ </Section>
46
+ </Container>
47
+ </Body>
48
+ </Tailwind>
49
+ </Html>
50
+ );
51
+ }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { Button } from "../ui/button";
3
+ import { Button } from "../../ui/button";
4
4
  import { useState } from "react";
5
5
 
6
6
  export function SendEmailButton() {
@@ -0,0 +1,32 @@
1
+ 'use client'
2
+
3
+ import { Component, type ReactNode } from "react"
4
+
5
+ interface ErrorBoundaryProps {
6
+ children: ReactNode
7
+ fallback: ReactNode
8
+ }
9
+
10
+ interface ErrorBoundaryState {
11
+ hasError: boolean
12
+ }
13
+
14
+ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
15
+ state: ErrorBoundaryState = { hasError: false }
16
+
17
+ static getDerivedStateFromError() {
18
+ return { hasError: true }
19
+ }
20
+
21
+ componentDidCatch(error: unknown) {
22
+ console.error(error)
23
+ }
24
+
25
+ render() {
26
+ if (this.state.hasError) {
27
+ return this.props.fallback
28
+ }
29
+
30
+ return this.props.children
31
+ }
32
+ }
@@ -0,0 +1,64 @@
1
+ 'use client'
2
+
3
+ import { useState, useEffect } from 'react'
4
+ import { useTheme } from 'next-themes'
5
+ import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
6
+ import { Label } from '../../ui/label'
7
+ import { Skeleton } from '../../ui/skeleton'
8
+
9
+ export function AppearanceSection() {
10
+ const { theme, setTheme, systemTheme } = useTheme()
11
+ const [mounted, setMounted] = useState(false)
12
+
13
+ useEffect(() => {
14
+ setMounted(true)
15
+ }, [])
16
+
17
+ const currentTheme = theme === 'system' ? systemTheme : theme
18
+
19
+ return (
20
+ <Card>
21
+ <CardHeader>
22
+ <CardTitle>Appearance</CardTitle>
23
+ <CardDescription>Customize how the application looks and feels</CardDescription>
24
+ </CardHeader>
25
+ <CardContent className="space-y-6">
26
+ {!mounted ? (
27
+ <Skeleton className="h-20 w-full" />
28
+ ) : (
29
+ <div className="space-y-4">
30
+ <div>
31
+ <Label className="text-base font-semibold mb-4 block">Theme</Label>
32
+ <div className="grid grid-cols-3 gap-4">
33
+ {[
34
+ { value: 'light', label: 'Light', description: 'Light theme' },
35
+ { value: 'dark', label: 'Dark', description: 'Dark theme' },
36
+ { value: 'system', label: 'System', description: 'Follow system setting' },
37
+ ].map((option) => (
38
+ <button
39
+ key={option.value}
40
+ onClick={() => setTheme(option.value)}
41
+ className={`p-4 rounded-lg border-2 transition-all ${
42
+ theme === option.value
43
+ ? 'border-primary bg-primary/10'
44
+ : 'border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600'
45
+ }`}
46
+ >
47
+ <div className="font-medium text-sm">{option.label}</div>
48
+ <div className="text-xs text-gray-600 dark:text-gray-400 mt-1">{option.description}</div>
49
+ </button>
50
+ ))}
51
+ </div>
52
+ </div>
53
+
54
+ <div className="pt-4 border-t dark:border-gray-700">
55
+ <p className="text-sm text-gray-600 dark:text-gray-400">
56
+ Current theme: <strong>{currentTheme === 'light' ? 'Light' : 'Dark'}</strong>
57
+ </p>
58
+ </div>
59
+ </div>
60
+ )}
61
+ </CardContent>
62
+ </Card>
63
+ )
64
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./settings-nav"
2
+ export * from "./profile/profile-section"
3
+ export * from "./security/security-section"
4
+ export * from "./appearance/appearance-section"
5
+ export * from "./notifications/notifications-section"
@@ -0,0 +1,31 @@
1
+ import { Suspense } from "react"
2
+ import { requireAuth } from "@xk2800/nextjs-template/auth/helpers"
3
+ import { ErrorBoundary } from "../../error-boundary"
4
+ import SectionErrorFallback from "../../dashboard/common/section-error-fallback"
5
+ import MarketingUpdatesSection from "../../dashboard/settings/marketing-updates-section"
6
+ import InstallAppCard from "../../dashboard/overview/install-app-card"
7
+ import PushNotificationsCard from "../../site/push/push-notifications-card"
8
+ import { Skeleton } from "../../ui/skeleton"
9
+ import { MARKETING_SEGMENT_ID } from "@xk2800/nextjs-template/marketing"
10
+
11
+ export async function NotificationsSection() {
12
+ const session = await requireAuth()
13
+
14
+ return (
15
+ <div className="space-y-6">
16
+ {MARKETING_SEGMENT_ID && (
17
+ <ErrorBoundary fallback={<SectionErrorFallback title="Email updates" />}>
18
+ <Suspense fallback={<Skeleton className="h-32 w-full" />}>
19
+ <MarketingUpdatesSection email={session.user.email} emailVerified={session.user.emailVerified} />
20
+ </Suspense>
21
+ </ErrorBoundary>
22
+ )}
23
+ <div>
24
+ <h2 className="text-xl font-semibold">This device</h2>
25
+ <p className="mt-1 text-sm text-muted-foreground">Push notifications and installing the app</p>
26
+ </div>
27
+ <PushNotificationsCard />
28
+ <InstallAppCard />
29
+ </div>
30
+ )
31
+ }
@@ -0,0 +1,38 @@
1
+ import { Suspense } from "react"
2
+ import { requireAuth, hasRole } from "@xk2800/nextjs-template/auth/helpers"
3
+ import { ErrorBoundary } from "../../error-boundary"
4
+ import SectionErrorFallback from "../../dashboard/common/section-error-fallback"
5
+ import ProfileCard from "../../dashboard/settings/profile-card"
6
+ import AccountDetailsCard from "../../dashboard/settings/account-details-card"
7
+ import AdminSection from "../../dashboard/settings/admin-section"
8
+ import ActivityLogsSection from "../../dashboard/settings/activity-logs-section"
9
+ import ActivityLogsCardSkeleton from "../../dashboard/settings/skeletons/activity-logs-card-skeleton"
10
+ import DeleteAccountCard from "../../dashboard/settings/delete-account-card"
11
+
12
+ export async function ProfileSection() {
13
+ const session = await requireAuth()
14
+ const isAdmin = hasRole(session.user.role, "admin")
15
+
16
+ return (
17
+ <div className="space-y-6">
18
+ <div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
19
+ <ProfileCard user={session.user} isAdmin={isAdmin} />
20
+ <AccountDetailsCard user={session.user} />
21
+ </div>
22
+
23
+ {isAdmin && <AdminSection />}
24
+
25
+ <ErrorBoundary fallback={<SectionErrorFallback title="Activity Logs" />}>
26
+ <Suspense fallback={<ActivityLogsCardSkeleton />}>
27
+ <ActivityLogsSection userId={session.user.id} isAdmin={isAdmin} />
28
+ </Suspense>
29
+ </ErrorBoundary>
30
+
31
+ <div>
32
+ <h2 className="text-xl font-semibold">Danger zone</h2>
33
+ <p className="mt-1 text-sm text-muted-foreground">Irreversible actions on your account</p>
34
+ </div>
35
+ <DeleteAccountCard />
36
+ </div>
37
+ )
38
+ }
@@ -0,0 +1,24 @@
1
+ import { Suspense } from "react"
2
+ import { requireAuth } from "@xk2800/nextjs-template/auth/helpers"
3
+ import { ErrorBoundary } from "../../error-boundary"
4
+ import SectionErrorFallback from "../../dashboard/common/section-error-fallback"
5
+ import TwoFactorCard from "../../dashboard/settings/two-factor-card"
6
+ import PasskeysCard from "../../dashboard/settings/passkeys-card"
7
+ import SessionsSection from "../../dashboard/settings/sessions/sessions-section"
8
+ import SessionsCardSkeleton from "../../dashboard/settings/sessions/skeletons/sessions-card-skeleton"
9
+
10
+ export async function SecuritySection() {
11
+ const session = await requireAuth()
12
+
13
+ return (
14
+ <div className="space-y-6">
15
+ <TwoFactorCard />
16
+ <PasskeysCard />
17
+ <ErrorBoundary fallback={<SectionErrorFallback title="Active Sessions" />}>
18
+ <Suspense fallback={<SessionsCardSkeleton />}>
19
+ <SessionsSection userId={session.user.id} />
20
+ </Suspense>
21
+ </ErrorBoundary>
22
+ </div>
23
+ )
24
+ }
@@ -0,0 +1,35 @@
1
+ import Link from "next/link"
2
+ import { cn } from "../../lib/utils"
3
+
4
+ export const SETTINGS_TABS = [
5
+ { value: "profile", label: "Profile" },
6
+ { value: "security", label: "Security & sessions" },
7
+ { value: "appearance", label: "Appearance" },
8
+ { value: "notifications", label: "Notifications" },
9
+ ] as const
10
+
11
+ export type SettingsTab = (typeof SETTINGS_TABS)[number]["value"]
12
+
13
+ // Link-based tabs: the active tab is the `?tab=` param, so only that tab's
14
+ // server components render and each tab is bookmarkable.
15
+ export function SettingsNav({ active }: { active: SettingsTab }) {
16
+ return (
17
+ <nav className="flex gap-1 overflow-x-auto border-b" aria-label="Settings sections">
18
+ {SETTINGS_TABS.map(({ value, label }) => (
19
+ <Link
20
+ key={value}
21
+ href={`/dashboard/settings?tab=${value}`}
22
+ aria-current={active === value ? "page" : undefined}
23
+ className={cn(
24
+ "-mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm font-medium transition-colors",
25
+ active === value
26
+ ? "border-primary text-foreground"
27
+ : "border-transparent text-muted-foreground hover:text-foreground",
28
+ )}
29
+ >
30
+ {label}
31
+ </Link>
32
+ ))}
33
+ </nav>
34
+ )
35
+ }