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

feat: Id reader #26

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Changes from all 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
123 changes: 115 additions & 8 deletions packages/country-config/src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
*/
export const popupButton = ({
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
url,
url
}: {
url: string;
}) => {
return {
name: "INFORMANT_AUTHENTICATION_POPUP_BUTTON",
type: "POPUP_BUTTON",
url,
name: 'INFORMANT_AUTHENTICATION_POPUP_BUTTON',
type: 'POPUP_BUTTON',
url
};
};

export const hidden = () => {
return {
name: "INFORMANT_PSUT_TOKEN",
type: "HIDDEN",
name: 'INFORMANT_PSUT_TOKEN',
type: 'HIDDEN'
};
};

Expand All @@ -33,9 +33,116 @@ export const hidden = () => {
* ]
* ```
*/

/**
*
* @description ID reader field definition (this field may not be supported in the latest release of OpenCRVS yet)
*
*/
export const idReader = (
event: string,
sectionId: string,
conditionals: any[],
readers: any[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to have types for this/these to help when importing?

) => {
const fieldName: string = 'idReader';
const fieldId: string = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
return {
name: fieldName,
customQuestionMappingId: fieldId,
custom: true,
required: false,
type: 'ID_READER',
label: {
id: 'form.field.label.empty',
defaultMessage: ''
},
hideInPreview: true,
initialValue: '',
validator: [],
conditionals,
dividerLabel: {
id: 'views.idReader.label.or',
defaultMessage: 'Or'
},
manualInputInstructionLabel: {
id: 'views.idReader.label.manualInput',
defaultMessage: 'Complete fields below'
},
readers
};
};

/**
*
* @description QR reader type definition (this field may not be supported in the latest release of OpenCRVS yet)
*
*/
export const qr = () => ({
type: 'QR'
});

/**
*
* @description esignet reader type definition (this field may not be supported in the latest release of OpenCRVS yet)
*
*/
export const esignet = ({
url,
callbackFieldName
}: {
/** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
url: string;
}) => [popupButton({ url }), hidden()];
callbackFieldName: string;
}) => ({
name: 'redirect',
validator: [],
icon: {
desktop: 'Globe',
mobile: 'Fingerprint'
},
type: 'REDIRECT',
label: {
id: 'views.idReader.label.eSignet',
defaultMessage: 'E-signet'
},
options: {
url,
callback: {
params: {
authorized: 'true'
},
trigger: callbackFieldName
}
}
});

export const esignetCallback = ({
fieldName,
url
}: {
fieldName: string;
url: string;
}) => ({
name: fieldName,
type: 'HTTP',
custom: true,
label: {
id: 'form.field.label.empty',
defaultMessage: ''
},
validator: [],
options: {
url,
headers: {
'Content-type': 'application/json'
},
method: 'GET'
}
});

// export const esignet = ({
// url
// }: {
// /** URL to OpenCRVS-MOSIP gateway (e.g. https://opencrvs-mosip-gateway.farajaland.opencrvs.org) */
// url: string;
// }) => [popupButton({ url }), hidden()];
Loading