Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-993
Browse files Browse the repository at this point in the history
  • Loading branch information
noah-brunate authored Oct 18, 2024
2 parents 215b002 + 1695fb1 commit d8cfe7e
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 199 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Two new statuses of record are added: `Validated` and `Correction Requested` for advanced search parameters [#6365](https://github.com/opencrvs/opencrvs-core/issues/6365)
- A new field: `Time Period` is added to advanced search [#6365](https://github.com/opencrvs/opencrvs-core/issues/6365)
- Deploy UI-Kit Storybook to [opencrvs.pages.dev](https://opencrvs.pages.dev) to allow extending OpenCRVS using the component library
- Reoder the sytem user add/edit field for surname to be first, also change labels from `Last name` to `User's surname` and lastly remove the NID question from the form [#6830](https://github.com/opencrvs/opencrvs-core/issues/6830)

## Bug fixes

Expand Down
40 changes: 8 additions & 32 deletions packages/client/src/forms/user/fieldDefinitions/createUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
UserSection
} from '@client/forms/index'
import { messages as userFormMessages } from '@client/i18n/messages/views/userForm'
import { NATIONAL_ID } from '@client/utils/constants'

export function userSectionFormType(): ISerializedFormSection {
return {
Expand Down Expand Up @@ -79,38 +78,38 @@ export function userSectionFormType(): ISerializedFormSection {
title: userFormMessages.userDetails,
fields: [
{
name: 'firstNamesEng',
name: 'familyName',
type: TEXT,
label: userFormMessages.firstNameEn,
label: userFormMessages.lastName,
required: true,
initialValue: '',
validator: [{ operation: 'englishOnlyNameFormat' }],
mapping: {
mutation: {
operation: 'fieldToNameTransformer',
parameters: ['en', 'firstNames']
parameters: ['en', 'familyName']
},
query: {
operation: 'nameToFieldTransformer',
parameters: ['en', 'firstNames']
parameters: ['en', 'familyName']
}
}
},
{
name: 'familyNameEng',
name: 'firstName',
type: TEXT,
label: userFormMessages.lastNameEn,
label: userFormMessages.firstName,
required: true,
initialValue: '',
validator: [{ operation: 'englishOnlyNameFormat' }],
mapping: {
mutation: {
operation: 'fieldToNameTransformer',
parameters: ['en', 'familyName']
parameters: ['en', 'firstNames']
},
query: {
operation: 'nameToFieldTransformer',
parameters: ['en', 'familyName']
parameters: ['en', 'firstNames']
}
}
},
Expand Down Expand Up @@ -152,29 +151,6 @@ export function userSectionFormType(): ISerializedFormSection {
initialValue: '',
validator: [{ operation: 'emailAddressFormat' }]
},
{
name: 'nid',
type: TEXT,
label: userFormMessages.NID,
required: false,
initialValue: '',
validator: [
{
operation: 'validIDNumber',
parameters: [NATIONAL_ID]
}
],
mapping: {
mutation: {
operation: 'fieldToIdentifierWithTypeTransformer',
parameters: [NATIONAL_ID]
},
query: {
operation: 'identifierWithTypeToFieldTransformer',
parameters: [NATIONAL_ID]
}
}
},
{
name: 'seperator',
type: 'DIVIDER',
Expand Down
21 changes: 8 additions & 13 deletions packages/client/src/i18n/messages/views/userForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ export const messages = {
description: 'User details section',
id: 'form.section.userDetails'
},
firstNameEn: {
defaultMessage: 'First name',
description: 'English first name',
id: 'form.field.label.firstNameEN'
firstName: {
defaultMessage: "User's first name",
description: "User's English first name",
id: 'form.field.label.userFirstName'
},
lastNameEn: {
defaultMessage: 'Last name',
description: 'English last name',
id: 'form.field.label.lastNameEN'
lastName: {
defaultMessage: "User's surname",
description: "User's English surname",
id: 'form.field.label.userSurname'
},
phoneNumber: {
defaultMessage: 'Phone number',
Expand All @@ -69,11 +69,6 @@ export const messages = {
description: 'Input label for email address',
id: 'form.field.label.email'
},
NID: {
defaultMessage: 'NID',
description: 'National ID',
id: 'form.field.label.NID'
},
accountDetails: {
defaultMessage: 'Account details',
description: 'Account details section',
Expand Down
58 changes: 2 additions & 56 deletions packages/client/src/tests/forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -12264,33 +12264,6 @@
}
}
},
{
"name": "nid",
"type": "TEXT",
"label": {
"defaultMessage": "NID",
"description": "National ID",
"id": "form.field.label.NID"
},
"required": false,
"initialValue": "",
"validate": [
{
"operation": "validIDNumber",
"parameters": ["NATIONAL_ID"]
}
],
"mapping": {
"mutation": {
"operation": "fieldToIdentifierWithTypeTransformer",
"parameters": ["NATIONAL_ID"]
},
"query": {
"operation": "identifierWithTypeToFieldTransformer",
"parameters": ["NATIONAL_ID"]
}
}
},
{
"name": "seperator",
"type": "SUBSECTION",
Expand Down Expand Up @@ -12555,7 +12528,7 @@
"label": {
"defaultMessage": "Last name",
"description": "English last name",
"id": "form.field.label.lastNameEN"
"id": "form.field.label.userSurname"
},
"required": true,
"initialValue": "",
Expand Down Expand Up @@ -12616,33 +12589,6 @@
}
}
},
{
"name": "nid",
"type": "TEXT",
"label": {
"defaultMessage": "NID",
"description": "National ID",
"id": "form.field.label.NID"
},
"required": false,
"initialValue": "",
"validate": [
{
"operation": "validIDNumber",
"parameters": ["NATIONAL_ID"]
}
],
"mapping": {
"mutation": {
"operation": "fieldToIdentifierWithTypeTransformer",
"parameters": ["NATIONAL_ID"]
},
"query": {
"operation": "identifierWithTypeToFieldTransformer",
"parameters": ["NATIONAL_ID"]
}
}
},
{
"name": "seperator",
"type": "SUBSECTION",
Expand Down
45 changes: 7 additions & 38 deletions packages/client/src/tests/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1446,10 +1446,8 @@ export const mockCompleteFormData = {
accountDetails: '',
assignedRegistrationOffice: '',
device: '',
familyName: 'হোসেন',
familyNameEng: 'Hossain',
firstNames: 'Jeff',
firstNamesEng: 'Jeff',
familyName: 'Hossain',
firstName: 'Jeff',
nid: '123456789',
phoneNumber: '01662132132',
email: '[email protected]',
Expand Down Expand Up @@ -1600,7 +1598,7 @@ export const mockUserGraphqlOperation = {
}
},
{
name: 'firstNamesEng',
name: 'firstNames',
type: 'TEXT',
label: {
defaultMessage: 'English first name',
Expand All @@ -1622,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: '',
Expand Down Expand Up @@ -1665,33 +1663,6 @@ export const mockUserGraphqlOperation = {
}
}
},
{
name: 'nid',
type: 'TEXT',
label: {
defaultMessage: 'NID',
description: 'National ID',
id: 'form.field.label.NID'
},
required: true,
initialValue: '',
validator: [
{
operation: 'validIDNumber',
parameters: ['NATIONAL_ID']
}
],
mapping: {
mutation: {
operation: 'fieldToIdentifierWithTypeTransformer',
parameters: ['NATIONAL_ID']
},
query: {
operation: 'identifierWithTypeToFieldTransformer',
parameters: ['NATIONAL_ID']
}
}
},
{
name: 'accountDetails',
type: 'FIELD_GROUP_TITLE',
Expand Down Expand Up @@ -1822,10 +1793,8 @@ export const mockDataWithRegistarRoleSelected = {
accountDetails: '',
assignedRegistrationOffice: '',
device: '',
familyName: 'হোসেন',
familyNameEng: 'Hossain',
firstNames: 'Jeff',
firstNamesEng: 'Jeff',
familyName: 'Hossain',
firstName: 'Jeff',
email: '[email protected]',
nid: '101488192',
phoneNumber: '01662132132',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe('create new user tests', () => {
expect(
testComponent
.find(FormFieldGenerator)
.find('#familyNameEng_error')
.find('#familyName_error')
.hostNodes()
.text()
).toBe('Required to register a new user')
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -339,11 +339,6 @@ describe('edit user tests', () => {
username: 'shakib1',
mobile: '+8801662132163',
email: '[email protected]',
identifier: {
system: 'NATIONAL_ID',
value: '101488192',
__typename: 'Identifier'
},
systemRole: 'NATIONAL_REGISTRAR',
role: { _id: '63ef9466f708ea080777c27a' },
status: 'active',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class UserReviewFormComponent extends React.Component<
(field) => field.name === 'firstNamesEng'
) as IFormField
const familyNameEngField = fields.find(
(field) => field.name === 'familyNameEng'
(field) => field.name === 'familyName'
) as IFormField

return `${this.getValue(firstNamesEngField)} ${this.getValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const MOCK_USER: IUserModelData = {
}
],
username: 'd.bulaya',
identifiers: [],
email: '',
device: 'Samsung Galaxy S9',
emailForNotification: '[email protected]',
Expand Down
2 changes: 0 additions & 2 deletions packages/gateway/src/features/user/root-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
GQLHumanNameInput,
GQLResolver,
GQLSearchFieldAgentResponse,
GQLUserIdentifierInput,
GQLUserInput
} from '@gateway/graphql/schema'
import { logger, isBase64FileString } from '@opencrvs/commons'
Expand Down Expand Up @@ -640,7 +639,6 @@ function createOrUpdateUserPayload(user: GQLUserInput): IUserPayload {
role: user.role as string,
...(user.password && { password: user.password }),
...(user.status && { status: user.status }),
identifiers: (user.identifier as GQLUserIdentifierInput[]) || [],
primaryOfficeId: user.primaryOffice as string,
email: '',
...(user.email && { emailForNotification: user.email }), //instead of saving data in email, we want to store it in emailForNotification property
Expand Down
8 changes: 0 additions & 8 deletions packages/gateway/src/features/user/type-resolvers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe('User type resolvers', () => {
username: 'tamim.iqlbal',
mobile: '+8801711111111',
email: '[email protected]',
identifiers: [{ system: 'NATIONAL_ID', value: '1010101010' }],
systemRole: 'REGISTRATION_AGENT',
scope: ['certify'],
status: 'active',
Expand Down Expand Up @@ -90,13 +89,6 @@ describe('User type resolvers', () => {
const res = userTypeResolvers.User!.underInvestigation(mockResponse)
expect(res).toBeTruthy()
})
it('return user identifier', () => {
const res = userTypeResolvers.User!.identifier(mockResponse)
expect(res).toEqual({
system: mockResponse.identifiers[0].system,
value: mockResponse.identifiers[0].value
})
})
it('return primaryOffice type', async () => {
const mockOffice = {
resourceType: 'Location',
Expand Down
Loading

0 comments on commit d8cfe7e

Please sign in to comment.