From 950b5407c3bc4387933876d7a6cdd3e43927cb2e Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Thu, 6 Apr 2023 03:08:51 +0200 Subject: [PATCH] feat(server): remove the phone number from users management --- .../Authentication/InviteAcceptForm.tsx | 22 +++--- .../InviteAcceptFormContent.tsx | 75 ++++++++++++------- .../Authentication/InviteAcceptProvider.tsx | 7 +- .../containers/Authentication/components.tsx | 71 ++++++++---------- .../src/containers/Authentication/utils.tsx | 4 - .../UserFormDialog/UserForm.schema.tsx | 4 - .../Dialogs/UserFormDialog/UserForm.tsx | 20 +++-- .../UserFormDialog/UserFormContent.tsx | 73 +++++------------- 8 files changed, 127 insertions(+), 149 deletions(-) diff --git a/packages/webapp/src/containers/Authentication/InviteAcceptForm.tsx b/packages/webapp/src/containers/Authentication/InviteAcceptForm.tsx index dd2603271..d4a000c4c 100644 --- a/packages/webapp/src/containers/Authentication/InviteAcceptForm.tsx +++ b/packages/webapp/src/containers/Authentication/InviteAcceptForm.tsx @@ -4,7 +4,6 @@ import intl from 'react-intl-universal'; import { Formik } from 'formik'; import { useHistory } from 'react-router-dom'; import { Intent, Position } from '@blueprintjs/core'; -import { FormattedMessage as T } from '@/components'; import { isEmpty } from 'lodash'; import { useInviteAcceptContext } from './InviteAcceptProvider'; @@ -13,6 +12,14 @@ import { InviteAcceptSchema } from './utils'; import InviteAcceptFormContent from './InviteAcceptFormContent'; import { AuthInsiderCard } from './_components'; +const initialValues = { + organization_name: '', + invited_email: '', + first_name: '', + last_name: '', + password: '', +}; + export default function InviteAcceptForm() { const history = useHistory(); @@ -20,9 +27,8 @@ export default function InviteAcceptForm() { const { inviteAcceptMutate, inviteMeta, token } = useInviteAcceptContext(); // Invite value. - const inviteValue = { - organization_name: '', - invited_email: '', + const inviteFormValue = { + ...initialValues, ...(!isEmpty(inviteMeta) ? { invited_email: inviteMeta.email, @@ -34,19 +40,17 @@ export default function InviteAcceptForm() { // Handle form submitting. const handleSubmit = (values, { setSubmitting, setErrors }) => { inviteAcceptMutate([values, token]) - .then((response) => { + .then(() => { AppToaster.show({ message: intl.getHTML( 'congrats_your_account_has_been_created_and_invited', { - organization_name: inviteValue.organization_name, + organization_name: inviteMeta.organizationName, }, ), - intent: Intent.SUCCESS, }); history.push('/auth/login'); - setSubmitting(false); }) .catch( ({ @@ -84,7 +88,7 @@ export default function InviteAcceptForm() { diff --git a/packages/webapp/src/containers/Authentication/InviteAcceptFormContent.tsx b/packages/webapp/src/containers/Authentication/InviteAcceptFormContent.tsx index c32823f07..7a517112e 100644 --- a/packages/webapp/src/containers/Authentication/InviteAcceptFormContent.tsx +++ b/packages/webapp/src/containers/Authentication/InviteAcceptFormContent.tsx @@ -1,34 +1,45 @@ // @ts-nocheck -import React from 'react'; +import React, { useState } from 'react'; import intl from 'react-intl-universal'; -import { InputGroup, Intent } from '@blueprintjs/core'; +import { Button, InputGroup, Intent } from '@blueprintjs/core'; import { Form, useFormikContext } from 'formik'; import { Link } from 'react-router-dom'; +import { Tooltip2 } from '@blueprintjs/popover2'; +import styled from 'styled-components'; -import { Col, FFormGroup, Row, FormattedMessage as T } from '@/components'; +import { + Col, + FFormGroup, + FInputGroup, + Row, + FormattedMessage as T, +} from '@/components'; import { useInviteAcceptContext } from './InviteAcceptProvider'; -import { PasswordRevealer } from './components'; import { AuthSubmitButton } from './_components'; /** * Invite user form. */ export default function InviteUserFormContent() { - // Invite accept context. - const { inviteMeta } = useInviteAcceptContext(); + const [showPassword, setShowPassword] = useState(false); - // Formik context. + const { inviteMeta } = useInviteAcceptContext(); const { isSubmitting } = useFormikContext(); - const [passwordType, setPasswordType] = React.useState('password'); - // Handle password revealer changing. - const handlePasswordRevealerChange = React.useCallback( - (shown) => { - const type = shown ? 'text' : 'password'; - setPasswordType(type); - }, - [setPasswordType], + const handleLockClick = () => { + setShowPassword(!showPassword); + }; + const lockButton = ( + + -