From a124bb6a67ffa6745dde96429f96d7ef9858a357 Mon Sep 17 00:00:00 2001 From: Siyasanga Date: Fri, 4 Oct 2024 09:43:25 +0200 Subject: [PATCH] Remove NID field from the user details form Remove the question that asks the user for a national ID number in this form as it is not required https://github.com/opencrvs/opencrvs-core/issues/6830 --- .../forms/user/fieldDefinitions/createUser.ts | 24 --------- packages/client/src/tests/forms.json | 54 ------------------- packages/client/src/tests/util.tsx | 27 ---------- .../registration/type-resolvers.test.ts | 1 - .../src/features/user/root-resolvers.ts | 2 - .../src/features/user/type-resolvers.test.ts | 8 --- .../src/features/user/type-resolvers.ts | 12 +---- .../src/features/createUser/service.ts | 2 - .../src/features/updateUser/handler.test.ts | 4 -- .../src/features/updateUser/handler.ts | 1 - packages/user-mgnt/src/model/user.ts | 6 --- 11 files changed, 1 insertion(+), 140 deletions(-) diff --git a/packages/client/src/forms/user/fieldDefinitions/createUser.ts b/packages/client/src/forms/user/fieldDefinitions/createUser.ts index 2fc6c9ee9d..5111556449 100644 --- a/packages/client/src/forms/user/fieldDefinitions/createUser.ts +++ b/packages/client/src/forms/user/fieldDefinitions/createUser.ts @@ -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 { @@ -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', diff --git a/packages/client/src/tests/forms.json b/packages/client/src/tests/forms.json index c716177a3f..81437e72d2 100644 --- a/packages/client/src/tests/forms.json +++ b/packages/client/src/tests/forms.json @@ -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", @@ -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", diff --git a/packages/client/src/tests/util.tsx b/packages/client/src/tests/util.tsx index b74eeb33b5..4165ce75bd 100644 --- a/packages/client/src/tests/util.tsx +++ b/packages/client/src/tests/util.tsx @@ -1665,33 +1665,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', diff --git a/packages/gateway/src/features/registration/type-resolvers.test.ts b/packages/gateway/src/features/registration/type-resolvers.test.ts index 26e6f987f2..19277f1367 100644 --- a/packages/gateway/src/features/registration/type-resolvers.test.ts +++ b/packages/gateway/src/features/registration/type-resolvers.test.ts @@ -51,7 +51,6 @@ const MOCK_USER: IUserModelData = { } ], username: 'd.bulaya', - identifiers: [], email: '', device: 'Samsung Galaxy S9', emailForNotification: 'kalushabw.alya17@gmail.com', diff --git a/packages/gateway/src/features/user/root-resolvers.ts b/packages/gateway/src/features/user/root-resolvers.ts index 08497c6b00..4b3e213f3c 100644 --- a/packages/gateway/src/features/user/root-resolvers.ts +++ b/packages/gateway/src/features/user/root-resolvers.ts @@ -26,7 +26,6 @@ import { GQLHumanNameInput, GQLResolver, GQLSearchFieldAgentResponse, - GQLUserIdentifierInput, GQLUserInput } from '@gateway/graphql/schema' import { logger, isBase64FileString } from '@opencrvs/commons' @@ -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 diff --git a/packages/gateway/src/features/user/type-resolvers.test.ts b/packages/gateway/src/features/user/type-resolvers.test.ts index f6e6bce9a5..e7223b6933 100644 --- a/packages/gateway/src/features/user/type-resolvers.test.ts +++ b/packages/gateway/src/features/user/type-resolvers.test.ts @@ -51,7 +51,6 @@ describe('User type resolvers', () => { username: 'tamim.iqlbal', mobile: '+8801711111111', email: 'test@test.org', - identifiers: [{ system: 'NATIONAL_ID', value: '1010101010' }], systemRole: 'REGISTRATION_AGENT', scope: ['certify'], status: 'active', @@ -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', diff --git a/packages/gateway/src/features/user/type-resolvers.ts b/packages/gateway/src/features/user/type-resolvers.ts index 20d222b96b..854552168e 100644 --- a/packages/gateway/src/features/user/type-resolvers.ts +++ b/packages/gateway/src/features/user/type-resolvers.ts @@ -11,12 +11,7 @@ import { IAuthHeader, UUID } from '@opencrvs/commons' -import { - GQLIdentifier, - GQLResolver, - GQLSignatureInput, - GQLUserIdentifierInput -} from '@gateway/graphql/schema' +import { GQLResolver, GQLSignatureInput } from '@gateway/graphql/schema' import { Bundle, Extension, @@ -67,7 +62,6 @@ export interface IUserModelData { creationDate?: string practitionerId: string primaryOfficeId: string - identifiers: GQLIdentifier[] device: string auditHistory?: IAuditHistory[] avatar?: IAvatar @@ -100,7 +94,6 @@ export interface IUserPayload '_id' | 'status' | 'practitionerId' | 'username' | 'identifiers' | 'role' > { id?: string - identifiers: GQLUserIdentifierInput[] systemRole: string status?: string username?: string @@ -178,9 +171,6 @@ export const userTypeResolvers: GQLResolver = { 'SUSPICIOUS' ) }, - identifier(userModel: IUserModelData) { - return userModel.identifiers && userModel.identifiers[0] - }, email(userModel: IUserModelData) { return userModel.emailForNotification }, diff --git a/packages/user-mgnt/src/features/createUser/service.ts b/packages/user-mgnt/src/features/createUser/service.ts index d83d93b29b..5cb8c2e074 100644 --- a/packages/user-mgnt/src/features/createUser/service.ts +++ b/packages/user-mgnt/src/features/createUser/service.ts @@ -37,7 +37,6 @@ export const createFhirPractitioner = ( if (system) { return { resourceType: 'Practitioner', - identifier: user.identifiers, telecom: [ { system: 'phone', value: user.mobile }, { system: 'email', value: user.emailForNotification } @@ -53,7 +52,6 @@ export const createFhirPractitioner = ( } else { return { resourceType: 'Practitioner', - identifier: user.identifiers, telecom: [ { system: 'phone', value: user.mobile }, { system: 'email', value: user.emailForNotification } diff --git a/packages/user-mgnt/src/features/updateUser/handler.test.ts b/packages/user-mgnt/src/features/updateUser/handler.test.ts index ae2b0daa82..e97929231e 100644 --- a/packages/user-mgnt/src/features/updateUser/handler.test.ts +++ b/packages/user-mgnt/src/features/updateUser/handler.test.ts @@ -37,7 +37,6 @@ const mockUser = { } ], username: 'jw.doe', - identifiers: [{ system: 'NID', value: '1234' }], email: 'j.doe@gmail.com', mobile: '+880123445568', systemRole: 'LOCAL_REGISTRAR', @@ -193,7 +192,6 @@ describe('updateUser handler', () => { family: 'Doe' } ], - identifiers: [{ system: 'NID', value: '1234' }], email: 'j.doe@gmail.com', mobile: '+880123445568', systemRole: 'REGISTRATION_AGENT', @@ -237,7 +235,6 @@ describe('updateUser handler', () => { family: 'Doe' } ], - identifiers: [{ system: 'NID', value: '1234' }], email: 'j.doe@gmail.com', mobile: '+880123111111', systemRole: 'FIELD_AGENT', @@ -352,7 +349,6 @@ describe('updateUser handler', () => { family: 'Doe' } ], - identifiers: [{ system: 'NID', value: '1234' }], email: 'j.doe@gmail.com', mobile: '+880123445568', systemRole: 'FIELD_AGENT', diff --git a/packages/user-mgnt/src/features/updateUser/handler.ts b/packages/user-mgnt/src/features/updateUser/handler.ts index 3358814cf4..5b9632cb94 100644 --- a/packages/user-mgnt/src/features/updateUser/handler.ts +++ b/packages/user-mgnt/src/features/updateUser/handler.ts @@ -63,7 +63,6 @@ export default async function updateUser( } // Update existing user's fields existingUser.name = user.name - existingUser.identifiers = user.identifiers existingUser.email = user.email existingUser.mobile = user.mobile existingUser.emailForNotification = user.emailForNotification diff --git a/packages/user-mgnt/src/model/user.ts b/packages/user-mgnt/src/model/user.ts index 2acc300948..3b9fbdd1e8 100644 --- a/packages/user-mgnt/src/model/user.ts +++ b/packages/user-mgnt/src/model/user.ts @@ -36,11 +36,6 @@ export interface IUserName { family: string given: string[] } - -interface IIdentifier { - system: string - value: string -} export interface ISecurityQuestionAnswer { questionKey: string answerHash: string @@ -132,7 +127,6 @@ export interface IAvatar { export interface IUser { name: IUserName[] username: string - identifiers: IIdentifier[] email: string mobile?: string emailForNotification?: string