diff --git a/packages/client/src/forms/user/fieldDefinitions/createUser.ts b/packages/client/src/forms/user/fieldDefinitions/createUser.ts index adb2b035721..d89a71dfc8b 100644 --- a/packages/client/src/forms/user/fieldDefinitions/createUser.ts +++ b/packages/client/src/forms/user/fieldDefinitions/createUser.ts @@ -96,9 +96,9 @@ export function userSectionFormType(): ISerializedFormSection { } }, { - name: 'firstNamesEng', + name: 'firstName', type: TEXT, - label: userFormMessages.firstNameEn, + label: userFormMessages.firstName, required: true, initialValue: '', validator: [{ operation: 'englishOnlyNameFormat' }], diff --git a/packages/client/src/i18n/messages/views/userForm.ts b/packages/client/src/i18n/messages/views/userForm.ts index 1453946f163..f4b46709183 100644 --- a/packages/client/src/i18n/messages/views/userForm.ts +++ b/packages/client/src/i18n/messages/views/userForm.ts @@ -49,15 +49,15 @@ export const messages = { description: 'User details section', id: 'form.section.userDetails' }, - firstNameEn: { + firstName: { defaultMessage: "User's first name", description: "User's English first name", - id: 'form.field.label.firstNameEN' + id: 'form.field.label.userFirstName' }, lastName: { defaultMessage: "User's surname", description: "User's English surname", - id: 'form.field.label.lastName' + id: 'form.field.label.userSurname' }, phoneNumber: { defaultMessage: 'Phone number', diff --git a/packages/client/src/tests/forms.json b/packages/client/src/tests/forms.json index 81437e72d29..07a7aefd20e 100644 --- a/packages/client/src/tests/forms.json +++ b/packages/client/src/tests/forms.json @@ -12203,7 +12203,7 @@ "label": { "defaultMessage": "Last name", "description": "English last name", - "id": "form.field.label.lastNameEN" + "id": "form.field.label.userSurname" }, "required": true, "initialValue": "", @@ -12528,7 +12528,7 @@ "label": { "defaultMessage": "Last name", "description": "English last name", - "id": "form.field.label.lastNameEN" + "id": "form.field.label.userSurname" }, "required": true, "initialValue": "", diff --git a/packages/client/src/tests/util.tsx b/packages/client/src/tests/util.tsx index 6c352dcd0df..4e49085df6e 100644 --- a/packages/client/src/tests/util.tsx +++ b/packages/client/src/tests/util.tsx @@ -1447,8 +1447,7 @@ export const mockCompleteFormData = { assignedRegistrationOffice: '', device: '', familyName: 'Hossain', - firstNames: 'Jeff', - firstNamesEng: 'Jeff', + firstName: 'Jeff', nid: '123456789', phoneNumber: '01662132132', email: 'jeff.hossain@gmail.com', @@ -1599,7 +1598,7 @@ export const mockUserGraphqlOperation = { } }, { - name: 'firstNamesEng', + name: 'firstNames', type: 'TEXT', label: { defaultMessage: 'English first name', @@ -1621,12 +1620,12 @@ export const mockUserGraphqlOperation = { } }, { - name: 'familyNameEng', + name: 'familyName', type: 'TEXT', label: { defaultMessage: 'English last name', description: 'English last name', - id: 'form.field.label.lastNameEN' + id: 'form.field.label.userSurname' }, required: true, initialValue: '', @@ -1795,8 +1794,7 @@ export const mockDataWithRegistarRoleSelected = { assignedRegistrationOffice: '', device: '', familyName: 'Hossain', - firstNames: 'Jeff', - firstNamesEng: 'Jeff', + firstName: 'Jeff', email: 'jeff@gmail.com', nid: '101488192', phoneNumber: '01662132132', diff --git a/packages/client/src/views/SysAdmin/Team/user/userCreation/CreateNewUser.test.tsx b/packages/client/src/views/SysAdmin/Team/user/userCreation/CreateNewUser.test.tsx index 3586c34ff0e..1c490b511c6 100644 --- a/packages/client/src/views/SysAdmin/Team/user/userCreation/CreateNewUser.test.tsx +++ b/packages/client/src/views/SysAdmin/Team/user/userCreation/CreateNewUser.test.tsx @@ -288,13 +288,13 @@ describe('create new user tests', () => { it('clicking change button on a field takes user back to form', async () => { testComponent - .find('#btn_change_firstNamesEng') + .find('#btn_change_firstName') .hostNodes() .first() .simulate('click') await flushPromises() expect(history.location.pathname).toBe('/createUser/user/user-view-group') - expect(history.location.hash).toBe('#firstNamesEng') + expect(history.location.hash).toBe('#firstName') }) it('clicking submit button submits the form data', async () => { diff --git a/packages/client/src/views/SysAdmin/Team/user/userCreation/UserForm.tsx b/packages/client/src/views/SysAdmin/Team/user/userCreation/UserForm.tsx index 0e35075c100..3b705c21c45 100644 --- a/packages/client/src/views/SysAdmin/Team/user/userCreation/UserForm.tsx +++ b/packages/client/src/views/SysAdmin/Team/user/userCreation/UserForm.tsx @@ -49,6 +49,7 @@ import { Content, ContentSize } from '@opencrvs/components/lib/Content' import { selectSystemRoleMap } from '@client/user/selectors' import { UserDetails } from '@client/utils/userUtils' import { getUserDetails } from '@client/profile/profileSelectors' +import { getValidationErrorsForForm } from '@client/forms/validation' export const Action = styled.div` margin-top: 32px; @@ -95,6 +96,18 @@ class UserFormComponent extends React.Component { const { formData, activeGroup, config, user } = this.props if (hasFormError(activeGroup.fields, formData, config, {}, user)) { this.showAllValidationErrors() + console.log('.................') + console.log( + 'form had errors', + getValidationErrorsForForm( + activeGroup.fields, + formData, + config, + {}, + user + ) + ) + console.log('.................') } else { this.props.userId ? this.props.goToUserReviewForm(