-
Notifications
You must be signed in to change notification settings - Fork 29
Accept terms of Service at signup #8193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a44f782
b62721f
94716a7
5607fcc
05eed1c
ae61dc6
5340755
ce2396f
4ea0446
77e2a59
b1bb0b8
a4817e4
f52c528
2602e5b
e5d5f19
db456d0
377d289
8d618c4
6c819e3
1d2ecb2
94be416
d60afaa
ca427bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { Checkbox, Form } from "antd"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import messages from "messages"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const FormItem = Form.Item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type TOSProps = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
terms: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
enabled: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export function TOSCheckFormItem({ terms }: TOSProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return terms == null || terms.enabled ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FormItem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name="tos_check" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
valuePropName="checked" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rules={[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
validator: (_, value) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
? Promise.resolve() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
: Promise.reject(new Error(messages["auth.tos_check_required"])), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+15
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add test attributes and error boundary The form item should have test attributes and error handling. <FormItem
name="tos_check"
valuePropName="checked"
+ data-testid="tos-form-item"
+ validateTrigger={["onChange", "onBlur"]}
rules={[
{
validator: (_, value) =>
value
? Promise.resolve()
: Promise.reject(new Error(messages["auth.tos_check_required"])),
},
]}
+ validateFirst={true}
> 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Checkbox disabled={terms == null}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I agree to the{" "} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{terms == null ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"terms of service" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<a target="_blank" href={terms.url} rel="noopener noreferrer"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
terms of service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</a> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</Checkbox> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+27
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve accessibility and security The checkbox and link need better accessibility support and security enhancements. - <Checkbox disabled={terms == null}>
+ <Checkbox
+ disabled={terms == null || loading}
+ aria-label="Terms of Service Agreement"
+ role="checkbox"
+ >
I agree to the{" "}
{terms == null ? (
- "terms of service"
+ <span aria-label="Terms of service link loading">terms of service</span>
) : (
<a
target="_blank"
href={terms.url}
- rel="noopener noreferrer"
+ rel="noopener noreferrer nofollow"
+ aria-label="Open terms of service in new tab"
+ data-testid="tos-link"
>
terms of service
</a>
)}
.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</FormItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.