|
|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
// Copyright (C) 2020-2022 Intel Corporation
|
|
|
|
|
// Copyright (C) 2022 CVAT.ai Corporation
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { UserAddOutlined, MailOutlined, LockOutlined } from '@ant-design/icons';
|
|
|
|
|
import Form, { RuleRender, RuleObject } from 'antd/lib/form';
|
|
|
|
|
import Button from 'antd/lib/button';
|
|
|
|
|
@ -98,8 +99,11 @@ const validateAgreement: ((userAgreements: UserAgreement[]) => RuleRender) = (
|
|
|
|
|
|
|
|
|
|
function RegisterFormComponent(props: Props): JSX.Element {
|
|
|
|
|
const { fetching, userAgreements, onSubmit } = props;
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const [usernameEdited, setUsernameEdited] = useState(false);
|
|
|
|
|
return (
|
|
|
|
|
<Form
|
|
|
|
|
form={form}
|
|
|
|
|
onFinish={(values: Record<string, string | boolean>) => {
|
|
|
|
|
const agreements = Object.keys(values)
|
|
|
|
|
.filter((key: string):boolean => key.startsWith('agreement:'));
|
|
|
|
|
@ -155,44 +159,50 @@ function RegisterFormComponent(props: Props): JSX.Element {
|
|
|
|
|
</Row>
|
|
|
|
|
<Form.Item
|
|
|
|
|
hasFeedback
|
|
|
|
|
name='username'
|
|
|
|
|
name='email'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please specify a username',
|
|
|
|
|
type: 'email',
|
|
|
|
|
message: 'The input is not valid E-mail!',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
validator: validateUsername,
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please specify an email address',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input
|
|
|
|
|
prefix={<UserAddOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} />}
|
|
|
|
|
placeholder='Username'
|
|
|
|
|
autoComplete='email'
|
|
|
|
|
prefix={<MailOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} />}
|
|
|
|
|
placeholder='Email address'
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
const { value } = event.target;
|
|
|
|
|
if (!usernameEdited) {
|
|
|
|
|
const [username] = value.split('@');
|
|
|
|
|
form.setFieldsValue({ username });
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
hasFeedback
|
|
|
|
|
name='email'
|
|
|
|
|
name='username'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
type: 'email',
|
|
|
|
|
message: 'The input is not valid E-mail!',
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please specify a username',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: 'Please specify an email address',
|
|
|
|
|
validator: validateUsername,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input
|
|
|
|
|
autoComplete='email'
|
|
|
|
|
prefix={<MailOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} />}
|
|
|
|
|
placeholder='Email address'
|
|
|
|
|
prefix={<UserAddOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} />}
|
|
|
|
|
placeholder='Username'
|
|
|
|
|
onChange={() => setUsernameEdited(true)}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
hasFeedback
|
|
|
|
|
name='password1'
|
|
|
|
|
|