@xk2800/nextjs-template 0.7.2-beta.1 → 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.
- package/README.md +1 -0
- package/components/auth/{loginErrorRecovery.tsx → forms/login-error-recovery.tsx} +1 -1
- package/components/auth/{emailPasswordLogin.tsx → forms/login-form.tsx} +8 -8
- package/components/auth/{emailPasswordSignup.tsx → forms/signup-form.tsx} +11 -8
- package/components/auth/{authCard.tsx → layout/auth-card.tsx} +5 -5
- package/components/auth/{authShell.tsx → layout/auth-shell.tsx} +17 -5
- package/components/auth/{oneTap.tsx → methods/one-tap.tsx} +2 -2
- package/components/auth/{passkeyLogin.tsx → methods/passkey-login.tsx} +2 -2
- package/components/auth/{socialLogin.tsx → methods/social-login.tsx} +3 -3
- package/components/auth/{twoFactorVerifyForm.tsx → mfa/two-factor-verify-form.tsx} +5 -5
- package/components/auth/{forgotPasswordForm.tsx → recovery/forgot-password-form.tsx} +4 -4
- package/components/auth/{resetPasswordForm.tsx → recovery/reset-password-form.tsx} +4 -4
- package/components/auth/{deviceCheck.tsx → session/device-check.tsx} +3 -3
- package/components/auth/{logoutButtons.tsx → session/logout-buttons.tsx} +2 -2
- package/components/dashboard/admin/{activityLogsSection.tsx → activity-logs/activity-logs-section.tsx} +1 -1
- package/components/dashboard/admin/activity-logs/admin-activity-logs-table.tsx +375 -0
- package/components/dashboard/admin/activity-logs/audit-severity-badge.tsx +50 -0
- package/components/dashboard/admin/activity-logs/security-highlights-collapsible.tsx +129 -0
- package/components/dashboard/admin/{adminActivityLogsSkeleton.tsx → activity-logs/skeletons/activity-logs-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{adminStatsGrid.tsx → home/admin-stats-grid.tsx} +1 -1
- package/components/dashboard/admin/{deviceThrottleCard.tsx → home/device-throttle-card.tsx} +8 -5
- package/components/dashboard/admin/{deviceThrottleTable.tsx → home/device-throttle-table.tsx} +3 -3
- package/components/dashboard/admin/{newDeviceCard.tsx → home/new-device-card.tsx} +6 -2
- package/components/dashboard/admin/{newDeviceTable.tsx → home/new-device-table.tsx} +4 -4
- package/components/dashboard/admin/{sharedDeviceCard.tsx → home/shared-device-card.tsx} +3 -3
- package/components/dashboard/admin/{sharedDeviceTable.tsx → home/shared-device-table.tsx} +3 -3
- package/components/dashboard/admin/{adminStatsGridSkeleton.tsx → home/skeletons/admin-stats-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{broadcastActions.tsx → marketing/broadcast-actions.tsx} +3 -3
- package/components/dashboard/admin/{confirmSendDialog.tsx → marketing/confirm-send-dialog.tsx} +1 -1
- package/components/dashboard/admin/{marketingEmailForm.tsx → marketing/marketing-email-form.tsx} +7 -7
- package/components/dashboard/admin/{marketingSection.tsx → marketing/marketing-section.tsx} +6 -6
- package/components/dashboard/admin/{subscribersCard.tsx → marketing/subscribers-card.tsx} +3 -3
- package/components/dashboard/admin/{feedbackTestForm.tsx → system-settings/feedback-test-form.tsx} +4 -4
- package/components/dashboard/admin/{systemSettingsSkeleton.tsx → system-settings/skeletons/system-settings-skeleton.tsx} +2 -2
- package/components/dashboard/admin/system-settings/system-settings-form.tsx +362 -0
- package/components/dashboard/admin/{systemSettingsSection.tsx → system-settings/system-settings-section.tsx} +3 -2
- package/components/dashboard/admin/users/admin-user-actions.tsx +238 -0
- package/components/dashboard/admin/users/admin-user-profile-card.tsx +70 -0
- package/components/dashboard/admin/users/admin-user-security-card.tsx +47 -0
- package/components/dashboard/admin/users/admin-user-status-card.tsx +89 -0
- package/components/dashboard/admin/{adminUsersTable.tsx → users/admin-users-table.tsx} +129 -132
- package/components/dashboard/admin/{adminUserActivityLogCard.tsx → users/detail/admin-user-activity-log-card.tsx} +3 -3
- package/components/dashboard/admin/{adminUserActivityLogTable.tsx → users/detail/admin-user-activity-log-table.tsx} +3 -3
- package/components/dashboard/admin/{adminUserConsentCard.tsx → users/detail/admin-user-consent-card.tsx} +4 -4
- package/components/dashboard/admin/{adminUserDevicesCard.tsx → users/detail/admin-user-devices-card.tsx} +2 -2
- package/components/dashboard/admin/{adminUserLoginInfoCard.tsx → users/detail/admin-user-login-info-card.tsx} +3 -3
- package/components/dashboard/admin/{adminUserLoginInfoTable.tsx → users/detail/admin-user-login-info-table.tsx} +3 -3
- package/components/dashboard/admin/{adminUserSessionsCard.tsx → users/detail/admin-user-sessions-card.tsx} +5 -5
- package/components/dashboard/admin/{impersonationLogCard.tsx → users/impersonation-log-card.tsx} +10 -5
- package/components/dashboard/admin/users/impersonation-tab.tsx +255 -0
- package/components/dashboard/admin/users/invite-user-dialog.tsx +80 -0
- package/components/dashboard/admin/{revokeAllSessionsButton.tsx → users/revoke-all-sessions.tsx} +5 -3
- package/components/dashboard/admin/{adminUsersSkeleton.tsx → users/skeletons/admin-users-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{usersSection.tsx → users/users-section.tsx} +1 -1
- package/components/dashboard/{errorFeedback.tsx → common/error-feedback.tsx} +1 -1
- package/components/dashboard/{feedbackDialog.tsx → common/feedback-dialog.tsx} +4 -4
- package/components/dashboard/{sectionErrorFallback.tsx → common/section-error-fallback.tsx} +1 -1
- package/components/dashboard/{verifyEmailButton.tsx → common/verify-email-button.tsx} +2 -2
- package/components/dashboard/{appSidebar.tsx → layout/app-sidebar.tsx} +11 -8
- package/components/dashboard/{dashboardHeader.tsx → layout/dashboard-header.tsx} +1 -1
- package/components/dashboard/{impersonationBanner.tsx → layout/impersonation-banner.tsx} +2 -2
- package/components/dashboard/layout/mobile-nav.tsx +95 -0
- package/components/dashboard/{navStyleToggle.tsx → layout/nav-style-toggle.tsx} +1 -1
- package/components/dashboard/{topNav.tsx → layout/top-nav.tsx} +19 -38
- package/components/dashboard/{installAppCard.tsx → overview/install-app-card.tsx} +2 -2
- package/components/dashboard/{accountDetailsCard.tsx → settings/account-details-card.tsx} +5 -5
- package/components/dashboard/{activityLogsCard.tsx → settings/activity-logs-card.tsx} +6 -6
- package/components/dashboard/{activityLogsSection.tsx → settings/activity-logs-section.tsx} +1 -1
- package/components/dashboard/{adminSection.tsx → settings/admin-section.tsx} +2 -2
- package/components/dashboard/{deleteAccountCard.tsx → settings/delete-account-card.tsx} +7 -7
- package/components/dashboard/{marketingUpdatesCard.tsx → settings/marketing-updates-card.tsx} +3 -3
- package/components/dashboard/{marketingUpdatesSection.tsx → settings/marketing-updates-section.tsx} +1 -1
- package/components/dashboard/{passkeysCard.tsx → settings/passkeys-card.tsx} +8 -8
- package/components/dashboard/{profileCard.tsx → settings/profile-card.tsx} +4 -4
- package/components/dashboard/{sessionsCard.tsx → settings/sessions/sessions-card.tsx} +6 -6
- package/components/dashboard/{sessionsSection.tsx → settings/sessions/sessions-section.tsx} +1 -1
- package/components/dashboard/{sessionsCardSkeleton.tsx → settings/sessions/skeletons/sessions-card-skeleton.tsx} +2 -2
- package/components/dashboard/{activityLogsCardSkeleton.tsx → settings/skeletons/activity-logs-card-skeleton.tsx} +2 -2
- package/components/dashboard/{twoFactorCard.tsx → settings/two-factor-card.tsx} +8 -8
- package/components/email/team/workspace-invite.tsx +51 -0
- package/components/email/{send-email-button.tsx → ui/send-email-button.tsx} +1 -1
- package/components/error-boundary.tsx +32 -0
- package/components/settings/appearance/appearance-section.tsx +64 -0
- package/components/settings/index.ts +5 -0
- package/components/settings/notifications/notifications-section.tsx +31 -0
- package/components/settings/profile/profile-section.tsx +38 -0
- package/components/settings/security/security-section.tsx +24 -0
- package/components/settings/settings-nav.tsx +35 -0
- package/components/site/{cookie-banner.tsx → compliance/cookie-banner.tsx} +6 -6
- package/components/site/push/push-notifications-card.tsx +117 -0
- package/components/ui/collapsible.tsx +9 -0
- package/components/ui/column-picker.tsx +1 -1
- package/components/ui/data-table.tsx +1 -1
- package/components/ui/dialog.tsx +46 -13
- package/components/ui/drawer.tsx +88 -0
- package/components/ui/tabs.tsx +52 -0
- package/dist/activity/logger.d.mts +2 -1
- package/dist/activity/logger.d.ts +2 -1
- package/dist/activity/logger.js +66 -15
- package/dist/activity/logger.js.map +1 -1
- package/dist/activity/logger.mjs +4 -4
- package/dist/activity/queries.d.mts +32 -21
- package/dist/activity/queries.d.ts +32 -21
- package/dist/activity/queries.js +86 -22
- package/dist/activity/queries.js.map +1 -1
- package/dist/activity/queries.mjs +27 -14
- package/dist/activity/queries.mjs.map +1 -1
- package/dist/admin/queries.d.mts +2 -1
- package/dist/admin/queries.d.ts +2 -1
- package/dist/admin/queries.js +48 -17
- package/dist/admin/queries.js.map +1 -1
- package/dist/admin/queries.mjs +9 -9
- package/dist/admin/queries.mjs.map +1 -1
- package/dist/api/feedback.js +284 -248
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +14 -12
- package/dist/api/feedback.mjs.map +1 -1
- package/dist/api/marketing.js +302 -266
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +16 -25
- package/dist/api/marketing.mjs.map +1 -1
- package/dist/auth/helpers.d.mts +63 -21
- package/dist/auth/helpers.d.ts +63 -21
- package/dist/auth/helpers.js +314 -267
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +9 -9
- package/dist/auth/index.d.mts +86 -47
- package/dist/auth/index.d.ts +86 -47
- package/dist/auth/index.js +278 -244
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +8 -8
- package/dist/auth-client/index.d.mts +1214 -2526
- package/dist/auth-client/index.d.ts +1214 -2526
- package/dist/auth-client/index.js +37 -3
- package/dist/auth-client/index.js.map +1 -1
- package/dist/auth-client/index.mjs +19 -3
- package/dist/auth-client/index.mjs.map +1 -1
- package/dist/{chunk-TE5BEAQB.mjs → chunk-3BH6BVBQ.mjs} +17 -7
- package/dist/chunk-3BH6BVBQ.mjs.map +1 -0
- package/dist/chunk-D56ENLSX.mjs +6 -0
- package/dist/chunk-D56ENLSX.mjs.map +1 -0
- package/dist/{chunk-HUEDEAY3.mjs → chunk-DCPVEZS7.mjs} +14 -4
- package/dist/chunk-DCPVEZS7.mjs.map +1 -0
- package/dist/{chunk-NQELV53D.mjs → chunk-DWLMCMXF.mjs} +4 -4
- package/dist/chunk-DWLMCMXF.mjs.map +1 -0
- package/dist/{chunk-653GF7OT.mjs → chunk-EXMUANQ3.mjs} +4 -4
- package/dist/chunk-EXMUANQ3.mjs.map +1 -0
- package/dist/{chunk-EIS4SCQW.mjs → chunk-IH6CMZIN.mjs} +213 -220
- package/dist/chunk-IH6CMZIN.mjs.map +1 -0
- package/dist/chunk-LADVCLEQ.mjs +43 -0
- package/dist/chunk-LADVCLEQ.mjs.map +1 -0
- package/dist/{chunk-2BJ3B4FR.mjs → chunk-NJBRKKLK.mjs} +46 -7
- package/dist/chunk-NJBRKKLK.mjs.map +1 -0
- package/dist/{chunk-6OAHCEDJ.mjs → chunk-QDUPSU5O.mjs} +5 -5
- package/dist/chunk-QDUPSU5O.mjs.map +1 -0
- package/dist/{chunk-H3XZTZ5K.mjs → chunk-S23GC776.mjs} +41 -29
- package/dist/chunk-S23GC776.mjs.map +1 -0
- package/dist/{chunk-L242CZ64.mjs → chunk-TIR7KHXL.mjs} +3 -3
- package/dist/chunk-TIR7KHXL.mjs.map +1 -0
- package/dist/{chunk-O5EQYHNC.mjs → chunk-ZOQHHFYA.mjs} +7 -4
- package/dist/chunk-ZOQHHFYA.mjs.map +1 -0
- package/dist/config/env.d.mts +3 -0
- package/dist/config/env.d.ts +3 -0
- package/dist/config/env.js +12 -2
- package/dist/config/env.js.map +1 -1
- package/dist/config/env.mjs +1 -1
- package/dist/db/index.d.mts +3 -7
- package/dist/db/index.d.ts +3 -7
- package/dist/db/index.js +61 -12
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +3 -3
- package/dist/db/schema.d.mts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.js +14 -4
- package/dist/db/schema.js.map +1 -1
- package/dist/db/schema.mjs +1 -1
- package/dist/errors.d.mts +2 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.js +62 -13
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +4 -4
- package/dist/marketing/index.d.mts +4 -3
- package/dist/marketing/index.d.ts +4 -3
- package/dist/marketing/index.js +14 -4
- package/dist/marketing/index.js.map +1 -1
- package/dist/marketing/index.mjs +3 -3
- package/dist/{email-template-passkey-change-F5Q2SXHD.mjs → passkey-changed-KEGNTIPE.mjs} +2 -2
- package/dist/passkey-changed-KEGNTIPE.mjs.map +1 -0
- package/dist/{email-template-reset-password-QTCQNXOD.mjs → reset-password-64VQEXBW.mjs} +2 -2
- package/dist/reset-password-64VQEXBW.mjs.map +1 -0
- package/dist/{schema-DzC5zdOq.d.mts → schema-BujGgvAy.d.mts} +35 -2
- package/dist/{schema-DzC5zdOq.d.ts → schema-BujGgvAy.d.ts} +35 -2
- package/dist/sessions/queries.js +61 -12
- package/dist/sessions/queries.js.map +1 -1
- package/dist/sessions/queries.mjs +3 -3
- package/dist/sessions/queries.mjs.map +1 -1
- package/dist/settings/queries.d.mts +11 -2
- package/dist/settings/queries.d.ts +11 -2
- package/dist/settings/queries.js +84 -13
- package/dist/settings/queries.js.map +1 -1
- package/dist/settings/queries.mjs +4 -4
- package/dist/users/queries.d.mts +41 -21
- package/dist/users/queries.d.ts +41 -21
- package/dist/users/queries.js +117 -23
- package/dist/users/queries.js.map +1 -1
- package/dist/users/queries.mjs +57 -17
- package/dist/users/queries.mjs.map +1 -1
- package/dist/{email-template-verify-email-WZDCCAKK.mjs → verify-email-4KMNGDKN.mjs} +2 -2
- package/dist/verify-email-4KMNGDKN.mjs.map +1 -0
- package/lib/{auth-client.ts → auth/client.ts} +22 -2
- package/lib/push/client.ts +39 -0
- package/lib/security/activity-severity.ts +57 -0
- package/lib/{request-info.ts → utils/request-info.ts} +7 -3
- package/package.json +177 -75
- package/scripts/check-deps.mjs +68 -0
- package/components/dashboard/admin/adminActivityLogsTable.tsx +0 -323
- package/components/dashboard/admin/adminUserStatusCard.tsx +0 -57
- package/components/dashboard/admin/systemSettingsForm.tsx +0 -289
- package/dist/chunk-2BJ3B4FR.mjs.map +0 -1
- package/dist/chunk-653GF7OT.mjs.map +0 -1
- package/dist/chunk-6OAHCEDJ.mjs.map +0 -1
- package/dist/chunk-EIS4SCQW.mjs.map +0 -1
- package/dist/chunk-H3XZTZ5K.mjs.map +0 -1
- package/dist/chunk-HUEDEAY3.mjs.map +0 -1
- package/dist/chunk-K62JYJRR.mjs +0 -30
- package/dist/chunk-K62JYJRR.mjs.map +0 -1
- package/dist/chunk-L242CZ64.mjs.map +0 -1
- package/dist/chunk-NQELV53D.mjs.map +0 -1
- package/dist/chunk-O5EQYHNC.mjs.map +0 -1
- package/dist/chunk-TE5BEAQB.mjs.map +0 -1
- package/dist/email-template-passkey-change-F5Q2SXHD.mjs.map +0 -1
- package/dist/email-template-reset-password-QTCQNXOD.mjs.map +0 -1
- package/dist/email-template-verify-email-WZDCCAKK.mjs.map +0 -1
- /package/components/dashboard/{heartbeat.tsx → common/heartbeat.tsx} +0 -0
- /package/components/email/{email-template-reset-password.tsx → auth/reset-password.tsx} +0 -0
- /package/components/email/{email-template-verify-email.tsx → auth/verify-email.tsx} +0 -0
- /package/components/email/{email-template-welcome.tsx → auth/welcome.tsx} +0 -0
- /package/components/email/{email-template.tsx → layout/base-layout.tsx} +0 -0
- /package/components/email/{email-template-2.tsx → marketing/general-announcement.tsx} +0 -0
- /package/components/email/{email-template-banned.tsx → security/account-banned.tsx} +0 -0
- /package/components/email/{email-template-new-device.tsx → security/new-device-alert.tsx} +0 -0
- /package/components/email/{email-template-passkey-change.tsx → security/passkey-changed.tsx} +0 -0
- /package/lib/{maintenance.ts → config/maintenance.ts} +0 -0
- /package/lib/{cookie-consent.ts → security/cookie-consent.ts} +0 -0
- /package/lib/{cookie-names.ts → security/cookie-names.ts} +0 -0
- /package/lib/{device-fingerprint.ts → security/device-fingerprint.ts} +0 -0
- /package/lib/{formatters.ts → utils/formatters.ts} +0 -0
- /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 {
|
|
5
|
+
import { LogOut } from "lucide-react"
|
|
6
6
|
|
|
7
|
-
import { authClient } from "
|
|
8
|
-
import { cn } from "
|
|
9
|
-
import { Avatar, AvatarFallback, AvatarImage } from "
|
|
10
|
-
import { Button } from "
|
|
11
|
-
import { adminLinks, workspaceLinks, type AppSidebarProps } from "./
|
|
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
|
-
|
|
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 ? [...
|
|
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
|
-
<
|
|
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 '
|
|
6
|
-
import { Button } from '
|
|
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 "
|
|
2
|
-
import { Badge } from "
|
|
3
|
-
import { Separator } from "
|
|
4
|
-
import { formatDate } from "
|
|
5
|
-
import VerifyEmailButton from "
|
|
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 '
|
|
5
|
-
import { Badge } from '
|
|
6
|
-
import { Skeleton } from '
|
|
7
|
-
import { DataTable, type Column } from '
|
|
8
|
-
import { formatDateTime, actionBadgeVariant } from '
|
|
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 "./
|
|
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 "
|
|
4
|
-
import { Button } from "
|
|
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 '
|
|
6
|
-
import { Button } from '
|
|
7
|
-
import { Input } from '
|
|
8
|
-
import { PasswordInput } from '
|
|
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 '
|
|
18
|
-
import { authClient, useSession } from '
|
|
19
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '
|
|
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
|
/**
|
package/components/dashboard/{marketingUpdatesCard.tsx → settings/marketing-updates-card.tsx}
RENAMED
|
@@ -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 "
|
|
6
|
-
import { Switch } from "
|
|
7
|
-
import { Label } from "
|
|
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,
|
package/components/dashboard/{marketingUpdatesSection.tsx → settings/marketing-updates-section.tsx}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isSubscribed, MARKETING_SEGMENT_ID } from "@xk2800/nextjs-template/marketing"
|
|
2
|
-
import MarketingUpdatesCard from "./
|
|
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 '
|
|
6
|
-
import { Button } from '
|
|
7
|
-
import { Input } from '
|
|
8
|
-
import { Skeleton } from '
|
|
9
|
-
import { DataTable, type Column } from '
|
|
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 '
|
|
20
|
-
import { formatDateTime } from '
|
|
21
|
-
import { authClient } from '
|
|
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 "
|
|
2
|
-
import { Avatar, AvatarFallback, AvatarImage } from "
|
|
3
|
-
import { Badge } from "
|
|
4
|
-
import { getUserInitials } from "
|
|
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 "
|
|
4
|
-
import { Badge } from "
|
|
5
|
-
import { Button } from "
|
|
6
|
-
import { DataTable, type Column } from "
|
|
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 "
|
|
17
|
-
import { formatDateTime } from "
|
|
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 "./
|
|
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 "
|
|
2
|
-
import { Skeleton } from "
|
|
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 "
|
|
2
|
-
import { Skeleton } from "
|
|
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 '
|
|
8
|
-
import { Button } from '
|
|
9
|
-
import { Input } from '
|
|
10
|
-
import { Label } from '
|
|
11
|
-
import { PasswordInput } from '
|
|
12
|
-
import { Badge } from '
|
|
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 '
|
|
21
|
-
import { useSession, authClient } from '
|
|
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
|
+
}
|
|
@@ -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,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
|
+
}
|