-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathcustom-consent-scope-checkbox.tsx
More file actions
68 lines (64 loc) · 2.12 KB
/
custom-consent-scope-checkbox.tsx
File metadata and controls
68 lines (64 loc) · 2.12 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright © 2024 Ory Corp
// SPDX-License-Identifier: Apache-2.0
import { OryNodeConsentScopeCheckboxProps } from "@ory/elements-react"
const scopeLabels: Record<string, { title: string; description: string }> = {
openid: {
title: "Identity",
description: "Allows the application to verify your identity.",
},
offline_access: {
title: "Offline Access",
description: "Allows the application to keep you signed in.",
},
profile: {
title: "Profile Information",
description: "Allows access to your basic profile details.",
},
email: {
title: "Email Address",
description: "Retrieve your email address and its verification status.",
},
phone: {
title: "Phone Number",
description: "Retrieve your phone number.",
},
}
export function MyCustomConsentScopeCheckbox({
attributes,
onCheckedChange,
inputProps,
}: OryNodeConsentScopeCheckboxProps) {
const scope = attributes.value as string
const label = scopeLabels[scope] ?? { title: scope, description: "" }
return (
<label className="flex items-center justify-between p-3 border rounded-lg cursor-pointer hover:bg-gray-50">
<div className="flex-1">
<p className="font-medium text-gray-900">{label.title}</p>
{label.description && (
<p className="text-sm text-gray-500">{label.description}</p>
)}
</div>
<div className="ml-4">
<button
type="button"
role="switch"
aria-checked={inputProps.checked}
onClick={() => onCheckedChange(!inputProps.checked)}
disabled={inputProps.disabled}
className={`
relative inline-flex h-6 w-11 items-center rounded-full transition-colors
${inputProps.checked ? "bg-blue-600" : "bg-gray-300"}
${inputProps.disabled ? "opacity-50 cursor-not-allowed" : ""}
`}
>
<span
className={`
inline-block h-4 w-4 transform rounded-full bg-white transition-transform
${inputProps.checked ? "translate-x-6" : "translate-x-1"}
`}
/>
</button>
</div>
</label>
)
}