Watcha op650 update onboarding process (#50)

* feat: change type of admin payload attribute

* feat: update payload attributes on user registration

* feat: delete displayname from UserModal
develop
KevICO 4 years ago committed by GitHub
parent b053da753d
commit 90a56149e4
  1. 3
      public/locales/en/usersTab.json
  2. 3
      public/locales/fr/usersTab.json
  3. 42
      src/NewUserForm.js
  4. 18
      src/NewUserModal.js

@ -2,16 +2,13 @@
"title": "Users",
"searchBoxPlaceholder": "Filter users",
"button": "New user",
"fullName": "Full name",
"emailAddress": "Email address",
"synapseAdminCheckbox": "Assign the administrator role to this user",
"requiered": {
"fullName": "$t(fullName) is requiered",
"emailAddress": "$t(emailAddress) is requiered"
},
"invalid": "Please provide {{field}}",
"invalidField": {
"fullName": "valid alphabetic characters",
"emailAddress": "a valid email address"
},
"unavailableEmailAddress": "This email address is already bound to another account",

@ -2,16 +2,13 @@
"title": "Utilisateurs",
"searchBoxPlaceholder": "Filtrer les utilisateurs",
"button": "Nouvel utilisateur",
"fullName": "Nom complet",
"emailAddress": "Adresse électronique",
"synapseAdminCheckbox": "Attribuer le rôle d'administrateur à cet utilisateur",
"requiered": {
"fullName": "Le nom complet est requis",
"emailAddress": "L'adresse électronique est requise"
},
"invalid": "Veuillez entrer {{field}}",
"invalidField": {
"fullName": "des caractères alphabétiques valides",
"emailAddress": "une adresse électronique valide"
},
"unavailableEmailAddress": "Cette adresse électronique est déjà liée à un autre compte",

@ -25,16 +25,6 @@ export default ({ userList, onSubmit, bindSubmitForm, feedback }) => {
}, [feedback]);
const schema = yup.object({
fullName: yup
.string()
.required(t("requiered.fullName"))
.matches(
// https://stackoverflow.com/a/39134560
// https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
// https://en.wikipedia.org/wiki/Latin_Extended-A
new RegExp("^[ a-z\u00C0-\u017F]{2,}$", "i"),
t("invalid", { field: "$t(invalidField.fullName)" })
),
emailAddress: yup
.string()
.required(t("requiered.emailAddress"))
@ -52,7 +42,6 @@ export default ({ userList, onSubmit, bindSubmitForm, feedback }) => {
return (
<Formik
initialValues={{
fullName: "",
emailAddress: "",
isSynapseAdministrator: false,
}}
@ -72,37 +61,6 @@ export default ({ userList, onSubmit, bindSubmitForm, feedback }) => {
bindResetForm(resetForm);
return (
<Form noValidate onSubmit={handleSubmit}>
<Form.Group>
<InputGroup>
<InputGroup.Prepend>
<InputGroup.Text>
<FontAwesomeIcon
icon={faUser}
fixedWidth
/>
</InputGroup.Text>
</InputGroup.Prepend>
<Form.Control
className="rightRoundedInput"
type="text"
name="fullName"
placeholder={t("fullName")}
value={values.fullName}
onChange={handleChange}
isValid={
values.fullName && !errors.fullName
}
isInvalid={
touched.fullName && !!errors.fullName
}
readOnly={feedback}
/>
<Form.Control.Feedback type="invalid">
{errors.fullName}
</Form.Control.Feedback>
</InputGroup>
</Form.Group>
<Form.Group>
<InputGroup>
<InputGroup.Prepend>

@ -54,27 +54,17 @@ export default ({ modalShow, setModalShow, userList, newUserLocalEcho }) => {
};
const makePayload = data => ({
admin: data.isSynapseAdministrator ? "admin" : false,
admin: data.isSynapseAdministrator,
email: data.emailAddress,
full_name: _pruneSpace(data.fullName),
user: _computeUserIdFromEmailAddress(data.emailAddress),
});
const makeUser = data => ({
userId: _computeUserIdFromEmailAddress(data.emailAddress),
displayName: _pruneSpace(data.fullName),
userId: _genRandomString(),
displayName: "",
emailAddress: data.emailAddress,
lastSeen: null,
role: data.isSynapseAdministrator ? "administrator" : "collaborator",
status: "active",
});
const _pruneSpace = string => string.replace(/ {2,}/g, " ").trim();
const _computeUserIdFromEmailAddress = emailAddress =>
emailAddress
.replace("@", "/")
.normalize("NFKD")
.replace(/[\u0300-\u036F]/g, "")
.toLowerCase()
.replace(/[^\w=\-./]/g, "");
const _genRandomString = () => Math.floor(Math.random() * 1000000).toString();

Loading…
Cancel
Save