Skip to content

feat: Add Confirm Password Field to Re-Enter or Confirm Password #1219

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 35 additions & 60 deletions frontend/src/forms/RegisterForm.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useLayoutEffect } from 'react';
import React from 'react';
import { Form, Input, Select } from 'antd';
import { UserOutlined, LockOutlined, MailOutlined } from '@ant-design/icons';

Expand All @@ -9,75 +9,26 @@ export default function RegisterForm({ userLocation }) {
const translate = useLanguage();

return (
<>
<Form>
<Form.Item
name="name"
label={translate('name')}
rules={[
{
required: true,
},
]}
rules={[{ required: true }]}
>
<Input prefix={<UserOutlined className="site-form-item-icon" />} size="large" />
</Form.Item>
<Form.Item
name="email"
label={translate('email')}
rules={[
{
required: true,
},
{
type: 'email',
},
]}
rules={[{ required: true }, { type: 'email' }]}
>
<Input
prefix={<MailOutlined className="site-form-item-icon" />}
type="email"
size="large"
/>
<Input prefix={<MailOutlined className="site-form-item-icon" />} type="email" size="large" />
</Form.Item>
<Form.Item
name="password"
label={translate('password')}
rules={[
{
required: true,
},
]}
>
<Input.Password prefix={<LockOutlined className="site-form-item-icon" />} size="large" />
</Form.Item>
{/* <Form.Item
name="confirm_password"
label={translate('confirm_password')}
rules={[
{
required: true,
},
({ getFieldValue }) => ({
validator(_, value) {
if (!value || getFieldValue('password') === value) {
return Promise.resolve();
}
return Promise.reject(new Error('The two passwords that you entered do not match!'));
},
}),
]}
hasFeedback
>
<Input.Password prefix={<LockOutlined className="site-form-item-icon" />} size="large" />
</Form.Item> */}

<Form.Item
label={translate('country')}
name="country"
rules={[
{
required: true,
},
]}
rules={[{ required: true }]}
initialValue={userLocation}
>
<Select
Expand All @@ -90,9 +41,7 @@ export default function RegisterForm({ userLocation }) {
filterSort={(optionA, optionB) =>
(optionA?.label ?? '').toLowerCase().startsWith((optionB?.label ?? '').toLowerCase())
}
style={{
width: '100%',
}}
style={{ width: '100%' }}
size="large"
>
{countryList.map((language) => (
Expand All @@ -107,6 +56,32 @@ export default function RegisterForm({ userLocation }) {
))}
</Select>
</Form.Item>
</>
<Form.Item
name="password"
label={translate('password')}
rules={[{ required: true }]}
>
<Input.Password prefix={<LockOutlined className="site-form-item-icon" />} size="large" />
</Form.Item>
<Form.Item
name="confirm_password"
label={translate('confirm_password')}
dependencies={['password']}
rules={[
{ required: true },
({ getFieldValue }) => ({
validator(_, value) {
if (!value || getFieldValue('password') === value) {
return Promise.resolve();
}
return Promise.reject(new Error('Password and confirm password should be same'));
},
}),
]}
hasFeedback
>
<Input.Password prefix={<LockOutlined className="site-form-item-icon" />} size="large" />
</Form.Item>
</Form>
);
}