Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | 3x 3x 3x 50x 50x 3x 103x 3x 102x | import React from "react";
import { APP_ROUTES } from "@/routes/const";
import {
CircleUserRound,
CreditCard,
Fingerprint,
FlaskConical,
Palette,
Database,
ShieldCheck,
} from "lucide-react";
import { TabGroups, TabLinkGroup } from "@/components/page/TabGroups/TabGroups";
import { useCurrentUser } from "@/context/AuthContext";
import { hasPlatformRole } from "@/util/platformRoles";
export type SettingsTab =
| "profile"
| "subscription"
| "security"
| "appearance"
| "data"
| "privacy"
| "scenarios";
const TAB_GROUPS: TabLinkGroup<SettingsTab>[] = [
{
label: "Account",
tabs: [
{
key: "profile",
label: "Profile",
icon: CircleUserRound,
to: APP_ROUTES.USER.SETTINGS.profile,
},
{
key: "subscription",
label: "Subscription",
icon: CreditCard,
to: APP_ROUTES.USER.SETTINGS.subscription,
},
{
key: "security",
label: "Security",
icon: Fingerprint,
to: APP_ROUTES.USER.SETTINGS.security,
},
],
},
{
label: "Preferences",
tabs: [
{
key: "appearance",
label: "Appearance",
icon: Palette,
to: APP_ROUTES.USER.SETTINGS.appearance,
},
],
},
{
label: "Data & privacy",
tabs: [
{
key: "data",
label: "Data",
icon: Database,
to: APP_ROUTES.USER.SETTINGS.data,
},
{
key: "privacy",
label: "Privacy",
icon: ShieldCheck,
to: APP_ROUTES.USER.SETTINGS.privacy,
},
],
},
];
/** Developer tools, for the `developer` platform role only (assigned in
* Auth0; `util/platformRoles.ts`). svc-core refuses everyone else
* regardless. */
const DEVELOPER_GROUP: TabLinkGroup<SettingsTab> = {
label: "Developer",
tabs: [
{
key: "scenarios",
label: "Scenario runs",
icon: FlaskConical,
to: APP_ROUTES.USER.SETTINGS.scenarios,
},
],
};
/** Personal's account settings tabs, with the developer tools for those who
* hold the role. */
export const SettingsTabs: React.FC<{ active: SettingsTab }> = ({ active }) => {
const developer = hasPlatformRole(useCurrentUser(), "developer");
return (
<TabGroups
groups={developer ? [...TAB_GROUPS, DEVELOPER_GROUP] : TAB_GROUPS}
active={active}
/>
);
};
// ─── Shared primitives ────────────────────────────────────────────────────────
export const SettingsSection: React.FC<{
title: string;
description?: string;
children: React.ReactNode;
}> = ({ title, description, children }) => (
<div className="rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm overflow-hidden">
<div className="px-5 py-4 border-b border-gray-100 dark:border-gray-700">
<h3 className="text-sm font-semibold text-gray-700 dark:text-gray-300">
{title}
</h3>
{description && (
<p className="text-xs text-gray-400 dark:text-gray-500 mt-0.5">
{description}
</p>
)}
</div>
<div className="divide-y divide-gray-100 dark:divide-gray-700">{children}</div>
</div>
);
/** A row that states a fact rather than offering a choice: what the platform
* does, with the value on the right. For the settings that are properties of
* the deployment, not of the user — a toggle there would control nothing. */
export const InfoRow: React.FC<{
label: string;
description?: React.ReactNode;
value?: React.ReactNode;
}> = ({ label, description, value }) => (
<div className="flex items-start justify-between gap-6 px-5 py-4">
<div className="flex-1 min-w-0">
<div className="text-sm font-medium text-gray-800 dark:text-gray-200">
{label}
</div>
{description && (
<div className="text-xs text-gray-400 dark:text-gray-500 mt-0.5">
{description}
</div>
)}
</div>
{value !== undefined && (
<div className="shrink-0 max-w-[50%] text-right text-sm text-gray-700 dark:text-gray-300">
{value}
</div>
)}
</div>
);
|