@xk2800/nextjs-template 0.7.2-beta.2 → 0.7.2-beta.4
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/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} +8 -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} +4 -6
- 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/{navStyleToggle.tsx → layout/nav-style-toggle.tsx} +1 -1
- package/components/dashboard/{topNav.tsx → layout/top-nav.tsx} +5 -5
- 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} +5 -5
- 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/tabs.tsx +52 -0
- package/dist/activity/logger.js +2 -2
- package/dist/activity/logger.js.map +1 -1
- package/dist/activity/logger.mjs +3 -3
- package/dist/activity/queries.d.mts +7 -3
- package/dist/activity/queries.d.ts +7 -3
- package/dist/activity/queries.js +16 -5
- package/dist/activity/queries.js.map +1 -1
- package/dist/activity/queries.mjs +18 -7
- package/dist/activity/queries.mjs.map +1 -1
- package/dist/admin/queries.js +4 -4
- package/dist/admin/queries.js.map +1 -1
- package/dist/admin/queries.mjs +5 -5
- package/dist/admin/queries.mjs.map +1 -1
- package/dist/api/feedback.js +25 -24
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +8 -8
- package/dist/api/feedback.mjs.map +1 -1
- package/dist/api/marketing.js +28 -27
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +12 -12
- package/dist/api/marketing.mjs.map +1 -1
- package/dist/auth/helpers.d.mts +22 -22
- package/dist/auth/helpers.d.ts +22 -22
- package/dist/auth/helpers.js +26 -25
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +8 -8
- package/dist/auth/index.js +24 -23
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +7 -7
- package/dist/auth-client/index.js +1 -1
- package/dist/auth-client/index.js.map +1 -1
- package/dist/auth-client/index.mjs.map +1 -1
- package/dist/{chunk-VVXYKVFJ.mjs → chunk-2BKXG4MG.mjs} +8 -7
- package/dist/chunk-2BKXG4MG.mjs.map +1 -0
- package/dist/{chunk-653GF7OT.mjs → chunk-AOSJUQQG.mjs} +4 -4
- package/dist/chunk-AOSJUQQG.mjs.map +1 -0
- package/dist/{chunk-L242CZ64.mjs → chunk-CRDC62BU.mjs} +2 -2
- package/dist/chunk-CRDC62BU.mjs.map +1 -0
- package/dist/{chunk-NQELV53D.mjs → chunk-J5XRJ2GW.mjs} +3 -3
- package/dist/chunk-J5XRJ2GW.mjs.map +1 -0
- package/dist/{chunk-6OAHCEDJ.mjs → chunk-JRDMU6I2.mjs} +4 -4
- package/dist/chunk-JRDMU6I2.mjs.map +1 -0
- package/dist/{chunk-O5EQYHNC.mjs → chunk-JSB36AY6.mjs} +4 -4
- package/dist/chunk-JSB36AY6.mjs.map +1 -0
- package/dist/{chunk-TE5BEAQB.mjs → chunk-M6Y2XNJC.mjs} +3 -3
- package/dist/chunk-M6Y2XNJC.mjs.map +1 -0
- package/dist/{chunk-K2GCSLRJ.mjs → chunk-NOFQCVHC.mjs} +14 -13
- package/dist/chunk-NOFQCVHC.mjs.map +1 -0
- package/dist/{chunk-K62JYJRR.mjs → chunk-RLZ7F7ZY.mjs} +3 -3
- package/dist/{chunk-K62JYJRR.mjs.map → chunk-RLZ7F7ZY.mjs.map} +1 -1
- package/dist/{chunk-2BJ3B4FR.mjs → chunk-TMANA7KL.mjs} +41 -5
- package/dist/chunk-TMANA7KL.mjs.map +1 -0
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +2 -2
- package/dist/db/schema.js +1 -1
- package/dist/db/schema.js.map +1 -1
- package/dist/db/schema.mjs +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +3 -3
- package/dist/marketing/index.js +2 -2
- package/dist/marketing/index.js.map +1 -1
- package/dist/marketing/index.mjs +2 -2
- 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/sessions/queries.js +1 -1
- package/dist/sessions/queries.js.map +1 -1
- package/dist/sessions/queries.mjs +2 -2
- package/dist/sessions/queries.mjs.map +1 -1
- package/dist/settings/queries.d.mts +9 -1
- package/dist/settings/queries.d.ts +9 -1
- package/dist/settings/queries.js +38 -1
- package/dist/settings/queries.js.map +1 -1
- package/dist/settings/queries.mjs +3 -3
- package/dist/users/queries.d.mts +18 -3
- package/dist/users/queries.d.ts +18 -3
- package/dist/users/queries.js +70 -11
- package/dist/users/queries.js.map +1 -1
- package/dist/users/queries.mjs +53 -15
- 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/push/client.ts +39 -0
- package/lib/security/activity-severity.ts +57 -0
- package/package.json +113 -18
- 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-K2GCSLRJ.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/chunk-VVXYKVFJ.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/{auth-client.ts → auth/client.ts} +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
- /package/lib/{request-info.ts → utils/request-info.ts} +0 -0
|
@@ -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
|
+
}
|
|
@@ -5,18 +5,18 @@ import { useEffect, useState } from "react"
|
|
|
5
5
|
|
|
6
6
|
// Relative imports: this file ships raw in the npm package, where `@/` would
|
|
7
7
|
// resolve against the consuming project instead.
|
|
8
|
-
import { Button } from "
|
|
9
|
-
import { Checkbox } from "
|
|
10
|
-
import { Label } from "
|
|
8
|
+
import { Button } from "../../ui/button"
|
|
9
|
+
import { Checkbox } from "../../ui/checkbox"
|
|
10
|
+
import { Label } from "../../ui/label"
|
|
11
11
|
import {
|
|
12
12
|
readConsent,
|
|
13
13
|
setCookieConsent,
|
|
14
14
|
useConsentRequired,
|
|
15
15
|
useCookieConsent,
|
|
16
16
|
type ConsentPurpose,
|
|
17
|
-
} from "
|
|
18
|
-
import { CONSENT_VERSION } from "
|
|
19
|
-
import { useSession } from "
|
|
17
|
+
} from "../../../lib/security/cookie-consent"
|
|
18
|
+
import { CONSENT_VERSION } from "../../../lib/security/cookie-names"
|
|
19
|
+
import { useSession } from "../../../lib/auth/client"
|
|
20
20
|
|
|
21
21
|
// Last choice sent to app/api/consent from this browser, as
|
|
22
22
|
// "userId|choice|version", so each choice is recorded once, not on every load.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
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'
|
|
8
|
+
import { Button } from '../../ui/button'
|
|
9
|
+
import {
|
|
10
|
+
PUSH_FLAG,
|
|
11
|
+
getRegistration,
|
|
12
|
+
pushSupported,
|
|
13
|
+
saveSubscription,
|
|
14
|
+
subscribe,
|
|
15
|
+
} from '../../../lib/push/client'
|
|
16
|
+
|
|
17
|
+
type State = 'loading' | 'unsupported' | 'no-worker' | 'denied' | 'off' | 'on'
|
|
18
|
+
|
|
19
|
+
// Example: turn push notifications on or off for this device and send a test.
|
|
20
|
+
// Hidden unless the VAPID keys are set (see .env.development.example).
|
|
21
|
+
export default function PushNotificationsCard() {
|
|
22
|
+
const [publicKey, setPublicKey] = useState('')
|
|
23
|
+
const [state, setState] = useState<State>('loading')
|
|
24
|
+
const [busy, setBusy] = useState(false)
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
; (async () => {
|
|
28
|
+
const res = await fetch('/api/push')
|
|
29
|
+
if (res.ok) setPublicKey((await res.json()).publicKey ?? '')
|
|
30
|
+
if (!pushSupported()) return setState('unsupported')
|
|
31
|
+
const reg = await getRegistration()
|
|
32
|
+
if (!reg) return setState('no-worker')
|
|
33
|
+
if (Notification.permission === 'denied') return setState('denied')
|
|
34
|
+
setState((await reg.pushManager.getSubscription()) ? 'on' : 'off')
|
|
35
|
+
})().catch(() => setState('unsupported'))
|
|
36
|
+
}, [])
|
|
37
|
+
|
|
38
|
+
if (!publicKey) return null
|
|
39
|
+
|
|
40
|
+
async function toggle(next: boolean) {
|
|
41
|
+
setBusy(true)
|
|
42
|
+
try {
|
|
43
|
+
const reg = await getRegistration()
|
|
44
|
+
if (!reg) throw new Error('Service worker not registered')
|
|
45
|
+
if (next) {
|
|
46
|
+
if ((await Notification.requestPermission()) !== 'granted') return setState('denied')
|
|
47
|
+
const res = await saveSubscription(await subscribe(reg, publicKey))
|
|
48
|
+
if (!res.ok) throw new Error((await res.json()).error || 'Failed to save subscription')
|
|
49
|
+
localStorage.setItem(PUSH_FLAG, '1')
|
|
50
|
+
setState('on')
|
|
51
|
+
} else {
|
|
52
|
+
localStorage.removeItem(PUSH_FLAG)
|
|
53
|
+
const sub = await reg.pushManager.getSubscription()
|
|
54
|
+
if (sub) {
|
|
55
|
+
await fetch('/api/push', {
|
|
56
|
+
method: 'DELETE',
|
|
57
|
+
headers: { 'Content-Type': 'application/json' },
|
|
58
|
+
body: JSON.stringify({ endpoint: sub.endpoint }),
|
|
59
|
+
})
|
|
60
|
+
await sub.unsubscribe()
|
|
61
|
+
}
|
|
62
|
+
setState('off')
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
toast.error(e instanceof Error ? e.message : 'Something went wrong')
|
|
66
|
+
} finally {
|
|
67
|
+
setBusy(false)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function sendTest() {
|
|
72
|
+
setBusy(true)
|
|
73
|
+
try {
|
|
74
|
+
const res = await fetch('/api/push/test', { method: 'POST' })
|
|
75
|
+
const data = await res.json()
|
|
76
|
+
if (!res.ok) throw new Error(data.error || 'Failed to send')
|
|
77
|
+
if (!data.sent) toast.error('No active device found. Turn notifications off and on again.')
|
|
78
|
+
} catch (e) {
|
|
79
|
+
toast.error(e instanceof Error ? e.message : 'Failed to send')
|
|
80
|
+
} finally {
|
|
81
|
+
setBusy(false)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const note: Partial<Record<State, string>> = {
|
|
86
|
+
unsupported:
|
|
87
|
+
"This browser can't receive push notifications. On iPhone and iPad, install the app to your Home Screen first (see below), then open it from there.",
|
|
88
|
+
'no-worker': 'Notifications are only available in production builds (bun run build && bun run start).',
|
|
89
|
+
denied: 'Notifications are blocked for this site. Allow them in your browser or system settings, then reload.',
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Card>
|
|
94
|
+
<CardHeader>
|
|
95
|
+
<CardTitle>Push notifications</CardTitle>
|
|
96
|
+
<CardDescription>Get notified on this device, even when the app is closed.</CardDescription>
|
|
97
|
+
</CardHeader>
|
|
98
|
+
<CardContent className="space-y-3">
|
|
99
|
+
<div className="flex items-center justify-between gap-4">
|
|
100
|
+
<Label htmlFor="push-notifications">Notify me on this device</Label>
|
|
101
|
+
<Switch
|
|
102
|
+
id="push-notifications"
|
|
103
|
+
checked={state === 'on'}
|
|
104
|
+
disabled={busy || (state !== 'on' && state !== 'off')}
|
|
105
|
+
onCheckedChange={toggle}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
{note[state] && <p className="text-sm text-muted-foreground">{note[state]}</p>}
|
|
109
|
+
{state === 'on' && (
|
|
110
|
+
<Button variant="outline" size="sm" disabled={busy} onClick={sendTest}>
|
|
111
|
+
Send test notification
|
|
112
|
+
</Button>
|
|
113
|
+
)}
|
|
114
|
+
</CardContent>
|
|
115
|
+
</Card>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Collapsible as CollapsiblePrimitive } from "radix-ui"
|
|
4
|
+
|
|
5
|
+
const Collapsible = CollapsiblePrimitive.Root
|
|
6
|
+
const CollapsibleTrigger = CollapsiblePrimitive.Trigger
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.Content
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
DropdownMenuSeparator,
|
|
14
14
|
DropdownMenuTrigger,
|
|
15
15
|
} from "./dropdown-menu"
|
|
16
|
-
import type { Column } from "../../lib/recalculate-columns"
|
|
16
|
+
import type { Column } from "../../lib/utils/recalculate-columns"
|
|
17
17
|
|
|
18
18
|
// Lets an app switch every table's "Columns" menu on/off in one place (e.g. from a feature flag).
|
|
19
19
|
const ColumnPickerContext = React.createContext(true)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Tabs as TabsPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
const Tabs = TabsPrimitive.Root
|
|
9
|
+
|
|
10
|
+
const TabsList = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
13
|
+
>(({ className, ...props }, ref) => (
|
|
14
|
+
<TabsPrimitive.List
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={cn(
|
|
17
|
+
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
))
|
|
23
|
+
TabsList.displayName = TabsPrimitive.List.displayName
|
|
24
|
+
|
|
25
|
+
const TabsTrigger = React.forwardRef<
|
|
26
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
27
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
28
|
+
>(({ className, ...props }, ref) => (
|
|
29
|
+
<TabsPrimitive.Trigger
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn(
|
|
32
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
))
|
|
38
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
39
|
+
|
|
40
|
+
const TabsContent = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
<TabsPrimitive.Content
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn("mt-4 focus-visible:outline-none", className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
))
|
|
50
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
51
|
+
|
|
52
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|