-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/hospitalrun/hospitalrun-frontend/h01xotey0 |
src/patients/new/NewPatientForm.tsx
Outdated
@@ -274,7 +278,9 @@ const NewPatientForm = (props: Props) => { | |||
/> | |||
</div> | |||
</div> | |||
|
|||
{errorMessage && ( | |||
<div className="alert alert-danger" role="alert">{t(errorMessage)}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the Alert
component from @hospitalrun/component
.
src/patients/new/NewPatientForm.tsx
Outdated
@@ -37,6 +38,9 @@ const NewPatientForm = (props: Props) => { | |||
}) | |||
|
|||
const onSaveButtonClick = async () => { | |||
if (!patient.givenName && !patient.familyName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to support all different types of name formats, I think that we should require that ONE of these fields is present (doesn't matter which one). @fox1t @StefanoMiC @tehkapa @lauggh what do you all think here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you @jackcmeyer. For example we already found cases where familiy names are not used (Burkina Faso). I think that the best choice is to make this configurable: the admin can decide mandatory fields for "all" forms. What do you think?
src/patients/new/NewPatientForm.tsx
Outdated
@@ -19,6 +19,7 @@ const NewPatientForm = (props: Props) => { | |||
const [isEditable] = useState(true) | |||
const { onCancel, onSave } = props | |||
const [approximateAge, setApproximateAge] = useState(0) | |||
const [errorMessage, setError] = useState('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename setError
to setErrorMesssage
to keep the state variable and state update function consistent.
src/patients/new/NewPatientForm.tsx
Outdated
@@ -37,6 +38,9 @@ const NewPatientForm = (props: Props) => { | |||
}) | |||
|
|||
const onSaveButtonClick = async () => { | |||
if (!patient.givenName && !patient.familyName) { | |||
return setError("No patient name entered!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string needs to support internationalization.
To do that you can add a key and value to locales/en-US/translation.json
. I think a key in the patient
object called patientNameRequired
or something like that would work.
src/patients/new/NewPatientForm.tsx
Outdated
@@ -274,7 +278,9 @@ const NewPatientForm = (props: Props) => { | |||
/> | |||
</div> | |||
</div> | |||
|
|||
{errorMessage && ( | |||
<div className="alert alert-danger" role="alert">{t(errorMessage)}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the value passed to the t
function needs to exist in the translations file.
src/patients/new/NewPatientForm.tsx
Outdated
@@ -274,7 +278,9 @@ const NewPatientForm = (props: Props) => { | |||
/> | |||
</div> | |||
</div> | |||
|
|||
{errorMessage && ( | |||
<div className="alert alert-danger" role="alert">{t(errorMessage)}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that error messages should be above the form fields. @lauggh @StefanoMiC thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
It looks like the account you committed with is not a GitHub user. Either you'll need to create an account for those commits, or you can amend your commits to match the account you opened the pull request with: https://stackoverflow.com/questions/3042437/how-to-change-the-commit-author-for-one-specific-commit/28845565 |
Also, congratulations on your first ever pull request @M-BenAli 🎉🎉🎉!! |
🙏 Thanks for your contribution! We will guide you to make this PR merged! |
Hi all! Thank you for the feedback and the welcome messages, I'll be looking at the requested changes and adjust the code. |
This problem should be solved now in the latest commit, |
We need to investigate into this. Thanks for the feedback! |
I opened a new regression issue: #1775 |
LGTM |
Changes proposed in this pull request: