Skip to content
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

Jerry - email verification admin accounts #1446

Merged
merged 3 commits into from
Jan 13, 2024
Merged
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
89 changes: 88 additions & 1 deletion src/components/UserProfile/AddNewUserProfile/UserProfileAdd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ class AddUserProfile extends Component {
showphone: true,
weeklySummaryOption: 'Required',
createdDate: nextDay,
actualEmail: '',
actualPassword: '',
},
formValid: {},
formErrors: {
firstName: 'First Name is required',
lastName: 'Last Name is required',
email: 'Email is required',
phoneNumber: 'Phone Number is required',
actualEmail: "Actual Email is required",
actualPassword: "Actual Password is required",
},
location: '',
timeZoneFilter: '',
Expand Down Expand Up @@ -118,7 +122,7 @@ class AddUserProfile extends Component {


render() {
const { firstName, email, lastName, phoneNumber, role, jobTitle } = this.state.userProfile;
const { firstName, email, lastName, phoneNumber, role, actualEmail, actualPassword, jobTitle } = this.state.userProfile;
const phoneNumberEntered =
this.state.userProfile.phoneNumber === null ||
this.state.userProfile.phoneNumber.length === 0;
Expand Down Expand Up @@ -280,6 +284,48 @@ class AddUserProfile extends Component {
</FormGroup>
</Col>
</Row>
{(role === 'Administrator' || role === 'Owner') && (
<>
<Row className="user-add-row">
<Col md={{ size: 2, offset: 2 }} className="text-md-right my-2">
<Label>Actual Email</Label>
</Col>
<Col md="6">
<FormGroup>
<Input
type="actualEmail"
name="actualEmail"
id="actualEmail"
value={actualEmail}
onChange={this.handleUserProfile}
placeholder="Actual Email"
invalid={this.state.formErrors.actualEmail}
/>
<FormFeedback>{this.state.formErrors.actualEmail}</FormFeedback>
</FormGroup>
</Col>
</Row>
<Row className="user-add-row">
<Col md={{ size: 4 }} className="text-md-right my-2">
<Label>Actual Password</Label>
</Col>
<Col md="6">
<FormGroup>
<Input
type="password"
name="actualPassword"
id="actualPassword"
value={actualPassword}
onChange={this.handleUserProfile}
placeholder="Actual Password"
invalid={this.state.formErrors.actualPassword}
/>
<FormFeedback>{this.state.formErrors.actualPassword}</FormFeedback>
</FormGroup>
</Col>
</Row>
</>
)}
<Row className="user-add-row">
<Col md={{ size: 4 }} className="text-md-right my-2">
<Label className="weeklySummaryOptionsLabel">Weekly Summary Options</Label>
Expand Down Expand Up @@ -587,6 +633,8 @@ class AddUserProfile extends Component {
location,
weeklySummaryOption,
createdDate,
actualEmail,
actualPassword
} = that.state.userProfile;

const userData = {
Expand All @@ -611,6 +659,8 @@ class AddUserProfile extends Component {
allowsDuplicateName: allowsDuplicateName,
createdDate: createdDate,
teamCode: this.state.teamCode,
actualEmail: actualEmail,
actualPassword: actualPassword
};

this.setState({ formSubmitted: true });
Expand Down Expand Up @@ -717,6 +767,19 @@ class AddUserProfile extends Component {
});
}
break;
case 'credentials':
this.setState({
formValid: {
...that.state.formValid,
email: false,
},
formErrors: {
...that.state.formErrors,
actualEmail: 'Actual email or password may be incorrect',
actualPassword: 'Actual email or password may be incorrect',
},
});
break;
}
}
toast.error(
Expand Down Expand Up @@ -981,6 +1044,30 @@ class AddUserProfile extends Component {
},
});
break;
case 'actualEmail':
this.setState({
userProfile: {
...userProfile,
actualEmail: event.target.value
},
formErrors: {
...formErrors,
actualEmail: event.target.value.match(patt) ? '' : 'Actual Email is not valid',
},
});
break;
case 'actualPassword':
this.setState({
userProfile: {
...userProfile,
actualPassword: event.target.value
},
formErrors: {
...formErrors,
actualPassword: event.target.value.length > 0 ? '' : 'Actual Password is required',
},
});
break;
default:
this.setState({
...userProfile,
Expand Down