-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathupdate-password-fields.jsx
More file actions
58 lines (52 loc) · 2.06 KB
/
update-password-fields.jsx
File metadata and controls
58 lines (52 loc) · 2.06 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
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import PropTypes from 'prop-types'
import {FormattedMessage} from 'react-intl'
import {
Box,
Button,
Stack,
StackDivider
} from '@salesforce/retail-react-app/app/components/shared/ui'
import useUpdatePasswordFields from '@salesforce/retail-react-app/app/components/forms/useUpdatePasswordFields'
import Field from '@salesforce/retail-react-app/app/components/field'
import PasswordRequirements from '@salesforce/retail-react-app/app/components/forms/password-requirements'
const UpdatePasswordFields = ({form, prefix = '', handleForgotPasswordClick}) => {
const fields = useUpdatePasswordFields({form, prefix})
const password = form.watch('password')
return (
<Stack spacing={5} divider={<StackDivider borderColor="gray.100" />}>
<Stack>
<Field {...fields.currentPassword} />
{handleForgotPasswordClick && (
<Box>
<Button variant="link" size="sm" onClick={handleForgotPasswordClick}>
<FormattedMessage
defaultMessage="Forgot Password?"
id="update_password_fields.button.forgot_password"
/>
</Button>
</Box>
)}
</Stack>
<Stack spacing={3} pb={2}>
<Field {...fields.password} />
<Field {...fields.confirmPassword} />
<PasswordRequirements value={password} />
</Stack>
</Stack>
)
}
UpdatePasswordFields.propTypes = {
handleForgotPasswordClick: PropTypes.func,
/** Object returned from `useForm` */
form: PropTypes.object.isRequired,
/** Optional prefix for field names */
prefix: PropTypes.string
}
export default UpdatePasswordFields