Skip to content

Commit 01a5aea

Browse files
feat: add validation to qr (#45)
* chore: pass validation to QR component * chore: bump version * chore: add more verification banners
1 parent 9f862f6 commit 01a5aea

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip",
3-
"version": "1.7.0-alpha.13",
3+
"version": "1.7.0-alpha.14",
44
"license": "MPL-2.0",
55
"private": true,
66
"packageManager": "yarn@1.22.13",

packages/country-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip",
3-
"version": "1.7.0-alpha.13",
3+
"version": "1.7.0-alpha.14",
44
"license": "MPL-2.0",
55
"main": "./build/index.js",
66
"exports": {

packages/country-config/src/forms.ts

+29-12
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ export const esignet = (
3434
url.searchParams.append("acr_values", "mosip:idp:acr:static-code");
3535
url.searchParams.append("claims", openIdProviderClaims);
3636
url.searchParams.append("state", "fetch-on-mount");
37-
url.searchParams.append(
38-
"redirect_uri",
39-
'${window.location.href}',
40-
);
37+
url.searchParams.append("redirect_uri", "${window.location.href}");
4138

4239
return {
4340
name: fieldName,
@@ -115,8 +112,7 @@ export const esignetCallback = ({
115112
},
116113
body: {
117114
clientId: openIdProviderClientId,
118-
redirectUri:
119-
'${window.location.href}',
115+
redirectUri: "${window.location.href}",
120116
},
121117

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

173-
export const qr = () => ({
169+
type MessageDescriptor = {
170+
id: string;
171+
defaultMessage: string;
172+
description?: string;
173+
};
174+
175+
export const qr = ({
176+
validation,
177+
}: {
178+
validation: {
179+
rule: Record<string, unknown>;
180+
errorMessage: MessageDescriptor;
181+
};
182+
}) => ({
174183
type: "QR",
184+
validation,
175185
});
176186

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

198-
export const idPendingVerificationBanner = (
208+
function capitalize(str: string) {
209+
return str.charAt(0).toUpperCase() + str.slice(1);
210+
}
211+
212+
export const idVerificationBanner = (
199213
event: string,
200214
sectionId: string,
215+
status: "pending" | "verified" | "failed",
201216
) => {
202217
const fieldName = "verified";
203218
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
204219
return {
205-
name: "idPending",
220+
name: `id${capitalize(status)}.`,
206221
type: "ID_VERIFICATION_BANNER",
207222
fieldId,
208223
hideInPreview: true,
209224
custom: true,
210-
bannerType: "pending",
225+
bannerType: status,
211226
idFieldName: "idReader",
212227
label: {
213228
id: "form.field.label.empty",
@@ -217,7 +232,7 @@ export const idPendingVerificationBanner = (
217232
conditionals: [
218233
{
219234
action: "hide",
220-
expression: '$form?.verified !== "pending"',
235+
expression: `$form?.verified !== "${status}"`,
221236
},
222237
],
223238
};
@@ -226,6 +241,8 @@ export const idPendingVerificationBanner = (
226241
export const idVerificationFields = (event: string, sectionId: string) => {
227242
return [
228243
verified(event, sectionId),
229-
idPendingVerificationBanner(event, sectionId),
244+
idVerificationBanner(event, sectionId, "pending"),
245+
idVerificationBanner(event, sectionId, "verified"),
246+
idVerificationBanner(event, sectionId, "failed"),
230247
];
231248
};

packages/esignet-mock/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@opencrvs/esignet-mock",
33
"license": "MPL-2.0",
4-
"version": "1.7.0-alpha.13",
4+
"version": "1.7.0-alpha.14",
55
"main": "index.js",
66
"scripts": {
77
"dev": "NODE_ENV=development tsx watch src/index.ts",

packages/mosip-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip-api",
3-
"version": "1.7.0-alpha.13",
3+
"version": "1.7.0-alpha.14",
44
"license": "MPL-2.0",
55
"scripts": {
66
"dev": "NODE_ENV=development tsx watch src/index.ts",

packages/mosip-mock/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencrvs/mosip-mock",
3-
"version": "1.7.0-alpha.13",
3+
"version": "1.7.0-alpha.14",
44
"license": "MPL-2.0",
55
"scripts": {
66
"dev": "NODE_ENV=development tsx watch src/index.ts",

0 commit comments

Comments
 (0)