Skip to content

Commit

Permalink
feat: add validation to qr (#45)
Browse files Browse the repository at this point in the history
* chore: pass validation to QR component

* chore: bump version

* chore: add more verification banners
tahmidrahman-dsi authored Jan 28, 2025

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 9f862f6 commit 01a5aea
Showing 6 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"private": true,
"packageManager": "yarn@1.22.13",
2 changes: 1 addition & 1 deletion packages/country-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"main": "./build/index.js",
"exports": {
41 changes: 29 additions & 12 deletions packages/country-config/src/forms.ts
Original file line number Diff line number Diff line change
@@ -34,10 +34,7 @@ export const esignet = (
url.searchParams.append("acr_values", "mosip:idp:acr:static-code");
url.searchParams.append("claims", openIdProviderClaims);
url.searchParams.append("state", "fetch-on-mount");
url.searchParams.append(
"redirect_uri",
'${window.location.href}',
);
url.searchParams.append("redirect_uri", "${window.location.href}");

return {
name: fieldName,
@@ -115,8 +112,7 @@ export const esignetCallback = ({
},
body: {
clientId: openIdProviderClientId,
redirectUri:
'${window.location.href}',
redirectUri: "${window.location.href}",
},

method: "POST",
@@ -170,8 +166,22 @@ export const idReader = (
};
};

export const qr = () => ({
type MessageDescriptor = {
id: string;
defaultMessage: string;
description?: string;
};

export const qr = ({
validation,
}: {
validation: {
rule: Record<string, unknown>;
errorMessage: MessageDescriptor;
};
}) => ({
type: "QR",
validation,
});

export const verified = (event: string, sectionId: string) => {
@@ -195,19 +205,24 @@ export const verified = (event: string, sectionId: string) => {
};
};

export const idPendingVerificationBanner = (
function capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}

export const idVerificationBanner = (
event: string,
sectionId: string,
status: "pending" | "verified" | "failed",
) => {
const fieldName = "verified";
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
return {
name: "idPending",
name: `id${capitalize(status)}.`,
type: "ID_VERIFICATION_BANNER",
fieldId,
hideInPreview: true,
custom: true,
bannerType: "pending",
bannerType: status,
idFieldName: "idReader",
label: {
id: "form.field.label.empty",
@@ -217,7 +232,7 @@ export const idPendingVerificationBanner = (
conditionals: [
{
action: "hide",
expression: '$form?.verified !== "pending"',
expression: `$form?.verified !== "${status}"`,
},
],
};
@@ -226,6 +241,8 @@ export const idPendingVerificationBanner = (
export const idVerificationFields = (event: string, sectionId: string) => {
return [
verified(event, sectionId),
idPendingVerificationBanner(event, sectionId),
idVerificationBanner(event, sectionId, "pending"),
idVerificationBanner(event, sectionId, "verified"),
idVerificationBanner(event, sectionId, "failed"),
];
};
2 changes: 1 addition & 1 deletion packages/esignet-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opencrvs/esignet-mock",
"license": "MPL-2.0",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"main": "index.js",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
2 changes: 1 addition & 1 deletion packages/mosip-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip-api",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
2 changes: 1 addition & 1 deletion packages/mosip-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip-mock",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",

0 comments on commit 01a5aea

Please sign in to comment.