Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up MOSIP code #7879

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions packages/client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15140,18 +15140,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mosipAid",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "otherInformantType",
"description": null,
Expand Down Expand Up @@ -15523,18 +15511,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mosipAid",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "otherInformantType",
"description": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export function setBirthRegistrationSectionTransformer(
draftData[sectionId].registrationNumber
}

if (draftData[sectionId].mosipAid) {
transformedData[sectionId].mosipAid = draftData[sectionId].mosipAid
}

if (!transformedData[sectionId].status) {
transformedData[sectionId].status = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,3 @@ export function getBirthRegistrationSectionTransformer(
transformStatusData(transformedData, queryData[sectionId].status, sectionId)
}
}

export function mosipAidTransformer(
transformedData: IFormData,
queryData: any,
sectionId: string,
targetSectionId?: string,
targetFieldName?: string
) {
if (queryData[sectionId].mosipAid) {
transformedData[targetSectionId || sectionId][
targetFieldName || 'mosipAid'
] = queryData[sectionId].mosipAid
}
}

export function mosipAidLabelTransformer(
transformedData: IFormData,
queryData: any,
sectionId: string,
targetSectionId?: string,
targetFieldName?: string
) {
if (queryData[sectionId].mosipAid) {
transformedData[targetSectionId || sectionId][
targetFieldName || 'mosipAIDLabel'
] = 'MOSIP Application ID'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,6 @@ export const fieldToIdentityTransformer =
return transformedData
}

export const nidVerificationFieldToIdentityTransformer = (
transformedData: TransformedData,
draftData: IFormData,
sectionId: string,
field: IFormField
) => {
fieldToIdentityTransformer('id', 'MOSIP_PSUT_TOKEN_ID')(
transformedData,
draftData,
sectionId,
field
)
const sectionData = transformedData[sectionId]
const existingIdentity = sectionData.identifier.find(
(identifier: IdentityType) =>
identifier.type && identifier.type === 'MOSIP_PSUT_TOKEN_ID'
)
if (existingIdentity) {
const modifiedFields = draftData[sectionId][
'fieldsModifiedByNidUserInfo'
] as string[] | undefined
existingIdentity['fieldsModifiedByIdentity'] =
modifiedFields?.join(',') ?? ''
}
return transformedData
}

interface IAddress {
[key: string]: any
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
DeathRegistration,
MarriageRegistration,
Address,
IdentityType,
EventRegistration
} from '@client/utils/gateway'
import {
Expand Down Expand Up @@ -241,36 +240,6 @@ export const identityToFieldTransformer =
return transformedData
}

export const identityToNidVerificationFieldTransformer = (
transformedData: IFormData,
queryData: QueryData,
sectionId: SectionId,
field: IFormField
) => {
identityToFieldTransformer('id', 'MOSIP_PSUT_TOKEN_ID')(
transformedData,
queryData,
sectionId,
field
)
const existingIdentity = queryData[sectionId]?.identifier?.find(
(identity: IdentityType) =>
(identity.type as string) === 'MOSIP_PSUT_TOKEN_ID'
)
if (!transformedData[sectionId]) {
transformedData[sectionId] = {}
}

if (existingIdentity) {
const modifiedFields = existingIdentity[
'fieldsModifiedByIdentity'
] as string[]
transformedData[sectionId].fieldsModifiedByNidUserInfo = modifiedFields
}

return transformedData
}

export const addressQueryTransformer =
(config: {
useCase: string
Expand Down Expand Up @@ -625,52 +594,6 @@ export const nestedValueToFieldTransformer =
return transformedData
}

export const nestedIdentityValueToFieldTransformer =
(nestedField: SectionId) =>
(
transformedData: IFormData,
queryData: QueryData,
sectionId: SectionId,
field: IFormField
) => {
if (!queryData[sectionId] || !queryData[sectionId][nestedField]) {
return transformedData
}
const clonedData = cloneDeep(transformedData)
if (!clonedData[nestedField]) {
clonedData[nestedField] = {}
}

identityToFieldTransformer('id', 'MOSIP_PSUT_TOKEN_ID')(
clonedData,
queryData[sectionId],
nestedField,
field
)

if (clonedData[nestedField][field.name] === undefined) {
return transformedData
}
transformedData[sectionId][field.name] = clonedData[nestedField][field.name]

const existingIdentity = queryData[sectionId][nestedField].identifier?.find(
(identity: IdentityType) =>
(identity.type as string) === 'MOSIP_PSUT_TOKEN_ID'
)
if (!transformedData[sectionId]) {
transformedData[sectionId] = {}
}

if (existingIdentity) {
const modifiedFields = existingIdentity[
'fieldsModifiedByIdentity'
] as string[]
transformedData[sectionId].fieldsModifiedByNidUserInfo = modifiedFields
}

return transformedData
}

export const booleanTransformer = (
transformedData: IFormData,
queryData: QueryData,
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/tests/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,6 @@ type Registration {
_fhirID: ID
draftId: String
trackingId: String
mosipAid: String
registrationNumber: String
paperFormID: String
page: String
Expand Down Expand Up @@ -1490,7 +1489,6 @@ input RegistrationInput {
_fhirID: ID
draftId: String
trackingId: String
mosipAid: String
registrationNumber: String
paperFormID: String
page: String
Expand Down
9 changes: 0 additions & 9 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,6 @@ export type Registration = {
inCompleteFields?: Maybe<Scalars['String']>
informantType?: Maybe<Scalars['String']>
informantsSignature?: Maybe<Scalars['String']>
mosipAid?: Maybe<Scalars['String']>
otherInformantType?: Maybe<Scalars['String']>
page?: Maybe<Scalars['String']>
paperFormID?: Maybe<Scalars['String']>
Expand Down Expand Up @@ -1736,7 +1735,6 @@ export type RegistrationInput = {
informantType?: InputMaybe<Scalars['String']>
informantsSignature?: InputMaybe<Scalars['String']>
location?: InputMaybe<LocationInput>
mosipAid?: InputMaybe<Scalars['String']>
otherInformantType?: InputMaybe<Scalars['String']>
page?: InputMaybe<Scalars['String']>
paperFormID?: InputMaybe<Scalars['String']>
Expand Down Expand Up @@ -3234,7 +3232,6 @@ export type FetchBirthRegistrationForReviewQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -3581,7 +3578,6 @@ export type FetchBirthRegistrationForCertificateQuery = {
informantsSignature?: string | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
status?: Array<{
__typename?: 'RegWorkflow'
type?: RegStatus | null
Expand Down Expand Up @@ -4761,7 +4757,6 @@ export type FetchMarriageRegistrationForReviewQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -5116,7 +5111,6 @@ export type FetchMarriageRegistrationForCertificateQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -7838,7 +7832,6 @@ export type FetchViewRecordByCompositionQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -8224,7 +8217,6 @@ export type FetchViewRecordByCompositionQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down Expand Up @@ -8542,7 +8534,6 @@ export type FetchViewRecordByCompositionQuery = {
type?: RegistrationType | null
trackingId?: string | null
registrationNumber?: string | null
mosipAid?: string | null
duplicates?: Array<{
__typename?: 'DuplicatesInfo'
compositionId?: string | null
Expand Down
68 changes: 0 additions & 68 deletions packages/client/src/utils/referenceApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,65 +513,6 @@ const parsedFacilities = {
}
}

const statuses = {
PENDING: 'pending',
ACTIVE: 'active',
DISABLED: 'disabled',
DEACTIVATED: 'deactivated'
}

const mockFetchConfig = {
config: {
API_GATEWAY_URL: 'http://localhost:7070/',
CONFIG_API_URL: 'http://localhost:2021',
LOGIN_URL: 'http://localhost:3020',
AUTH_URL: 'http://localhost:4040',
RESOURCES_URL: 'http://localhost:3040',
APPLICATION_NAME: 'Farajaland CRVS',
FIELD_AGENT_AUDIT_LOCATIONS: 'DISTRICT',
DECLARATION_AUDIT_LOCATIONS: 'DISTRICT',
EXTERNAL_VALIDATION_WORKQUEUE: false,
PHONE_NUMBER_PATTERN: '/^0(7|9)[0-9]{1}[0-9]{7}$/',
SENTRY: 'https://[email protected]/1774604',
NID_NUMBER_PATTERN: '/^[0-9]{9}$/',
COUNTRY: 'zmb',
CURRENCY: {
isoCode: 'ZMW',
languagesAndCountry: ['en-ZM']
},
LANGUAGES: 'en',
INTEGRATIONS: [
{
name: 'MOSIP',
status: statuses.ACTIVE
}
]
},
certificates: [
{
svgCode: '<svg></svg>'
},
{
svgCode: '<svg></svg>'
}
],
systems: [
{
name: 'MOSIP',
status: statuses.ACTIVE
}
]
}

const certificates = [
{
svgCode: '<svg></svg>'
},
{
svgCode: '<svg></svg>'
}
]

describe('referenceApi', () => {
beforeEach(() => {
fetch.resetMocks()
Expand All @@ -593,13 +534,4 @@ describe('referenceApi', () => {
const data = await referenceApi.loadFacilities()
expect(data).toEqual(parsedFacilities)
})

it('retrieves the config from the server', async () => {
fetch.mockResponseOnce(JSON.stringify(mockFetchConfig))
const data = await referenceApi.loadConfig()
expect(data).toEqual({
...mockFetchConfig,
certificates
})
})
})
2 changes: 0 additions & 2 deletions packages/client/src/views/DataProvider/birth/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export const GET_BIRTH_REGISTRATION_FOR_REVIEW = gql`
type
trackingId
registrationNumber
mosipAid
}
attendantAtBirth
weightAtBirth
Expand Down Expand Up @@ -474,7 +473,6 @@ export const GET_BIRTH_REGISTRATION_FOR_CERTIFICATE = gql`
}
trackingId
registrationNumber
mosipAid
}
attendantAtBirth
weightAtBirth
Expand Down
Loading
Loading