-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathAuthModePicker.tsx
More file actions
54 lines (51 loc) · 1.3 KB
/
AuthModePicker.tsx
File metadata and controls
54 lines (51 loc) · 1.3 KB
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
import { Select } from "@stellar/design-system";
import { AuthModeType } from "@/types/types";
const AUTH_MODE_OPTIONS: { id: string; label: string }[] = [
{ id: "record", label: "Record" },
{ id: "enforce", label: "Enforce" },
{ id: "record_allow_nonroot", label: "Record (allow non-root)" },
];
/**
* Reusable auth mode selector for simulation and validation steps.
*
* @param id - HTML id for the select element
* @param value - Currently selected auth mode
* @param onChange - Callback when the auth mode changes
* @param note - Optional note text (React node) displayed below the select
*
* @example
* <AuthModePicker
* id="simulate-auth-mode"
* value={authMode}
* onChange={(mode) => setAuthMode(mode)}
* note={<>Explanation text.</>}
* />
*/
export const AuthModePicker = ({
id,
value,
onChange,
note,
}: {
id: string;
value: AuthModeType | string;
onChange: (mode: AuthModeType) => void;
note?: React.ReactNode;
}) => (
<Select
id={id}
fieldSize="md"
label="Auth mode"
value={value}
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
onChange(e.target.value as AuthModeType);
}}
note={note}
>
{AUTH_MODE_OPTIONS.map((opt) => (
<option key={opt.id} value={opt.id}>
{opt.label}
</option>
))}
</Select>
);