Skip to content

Commit

Permalink
fix(dashbboard): cant create a person with no name; (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudambro authored Apr 1, 2022
1 parent 2bc8d36 commit 99df48c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dashboard/src/scenes/person/CreatePerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ const CreatePerson = ({ refreshable }) => {
<Formik
initialValues={{ name: '', assignedTeams: [currentTeam?._id] }}
onSubmit={async (body, actions) => {
if (!body.name?.trim()?.length) return toastr.error('Une personne doit avoir un nom');
const existingPerson = persons.find((p) => p.name === body.name);
if (existingPerson) return toastr.error('Un utilisateur existe déjà à ce nom');
if (existingPerson) return toastr.error('Une personne existe déjà à ce nom');
body.followedSince = new Date();
const response = await API.post({
path: '/person',
Expand Down Expand Up @@ -100,7 +101,7 @@ const CreatePerson = ({ refreshable }) => {
<ButtonCustom
color="info"
onClick={() => !isSubmitting && handleSubmit()}
disabled={!!isSubmitting}
disabled={!!isSubmitting || !values.name?.trim()?.length}
title={isSubmitting ? 'Sauvegarde...' : 'Sauvegarder'}
/>
</React.Fragment>
Expand Down

0 comments on commit 99df48c

Please sign in to comment.