Skip to content

Commit 28eef24

Browse files
authored
feat(ocrvs-10351): use the new age field (#1089)
* chore: update toolkit version * feat: use the new age field in birth form * chore: upgrade toolkit version * feat: use new AGE field * feat: add validations to age field * chore: upgrade toolkit version
2 parents b42ec25 + e394b24 commit 28eef24

File tree

11 files changed

+86
-18
lines changed

11 files changed

+86
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"@hapi/boom": "^9.1.1",
6969
"@hapi/hapi": "^20.0.1",
7070
"@hapi/inert": "^6.0.3",
71-
"@opencrvs/toolkit": "1.8.1-rc.a5eecfe",
71+
"@opencrvs/toolkit": "1.8.1-rc.4958667",
7272
"@types/chalk": "^2.2.0",
7373
"@types/csv2json": "^1.4.0",
7474
"@types/fhir": "^0.0.30",

src/api/certificates/source/v2.birth-certificate-certified-copy.svg

Lines changed: 3 additions & 3 deletions
Loading

src/api/notification/testData.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,13 @@ const RequestDeathDeclarationAction = {
297297
createdByRole: 'LOCAL_REGISTRAR',
298298
createdAtLocation: '9e069dda-0d83-4f67-a4f2-9adbf5658e2e' as unknown as UUID,
299299
declaration: {
300-
'spouse.age': '41',
300+
'spouse.age': { age: '41', asOfDate: '2025-08-19' },
301301
'spouse.name': {
302302
firstname: 'Toki',
303303
surname: 'Kozuki',
304304
middlename: ''
305305
},
306-
'deceased.age': '31',
306+
'deceased.age': { age: '31', asOfDate: '2025-08-19' },
307307
'deceased.name': {
308308
firstname: 'Oden',
309309
surname: 'Kozuki',
@@ -353,13 +353,13 @@ const DeathDeclarationAction = {
353353
createdByRole: 'LOCAL_REGISTRAR',
354354
createdAtLocation: '9e069dda-0d83-4f67-a4f2-9adbf5658e2e' as unknown as UUID,
355355
declaration: {
356-
'spouse.age': '41',
356+
'spouse.age': { age: '41', asOfDate: '2025-08-19' },
357357
'spouse.name': {
358358
firstname: 'Toki',
359359
surname: 'Kozuki',
360360
middlename: ''
361361
},
362-
'deceased.age': '31',
362+
'deceased.age': { age: '31', asOfDate: '2025-08-19' },
363363
'deceased.name': {
364364
firstname: 'Oden',
365365
surname: 'Kozuki',

src/form/v2/birth/forms/pages/father.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,15 @@ export const father = defineFormPage({
187187
},
188188
{
189189
id: 'father.age',
190-
type: FieldType.TEXT,
190+
type: FieldType.AGE,
191191
required: true,
192192
label: {
193193
defaultMessage: 'Age of father',
194194
description: 'This is the label for the field',
195195
id: 'event.birth.action.declare.form.section.father.field.age.label'
196196
},
197197
configuration: {
198+
asOfDate: field('child.dob'),
198199
postfix: {
199200
defaultMessage: 'years',
200201
description: 'This is the postfix for age field',
@@ -209,6 +210,16 @@ export const father = defineFormPage({
209210
requireFatherDetails
210211
)
211212
}
213+
],
214+
validation: [
215+
{
216+
validator: field('father.age').asAge().isBetween(12, 120),
217+
message: {
218+
defaultMessage: 'Age must be between 12 and 120',
219+
description: 'Error message for invalid age',
220+
id: 'event.action.declare.form.section.person.field.age.error'
221+
}
222+
}
212223
]
213224
},
214225
{

src/form/v2/birth/forms/pages/informant.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,15 @@ export const informant = defineFormPage({
225225
},
226226
{
227227
id: 'informant.age',
228-
type: FieldType.TEXT,
228+
type: FieldType.AGE,
229229
required: true,
230230
label: {
231231
defaultMessage: 'Age of informant',
232232
description: 'This is the label for the field',
233233
id: 'event.birth.action.declare.form.section.informant.field.age.label'
234234
},
235235
configuration: {
236+
asOfDate: field('child.dob'),
236237
postfix: {
237238
defaultMessage: 'years',
238239
description: 'This is the postfix for age field',
@@ -248,6 +249,16 @@ export const informant = defineFormPage({
248249
)
249250
}
250251
],
252+
validation: [
253+
{
254+
validator: field('informant.age').asAge().isBetween(12, 120),
255+
message: {
256+
defaultMessage: 'Age must be between 12 and 120',
257+
description: 'Error message for invalid age',
258+
id: 'event.action.declare.form.section.person.field.age.error'
259+
}
260+
}
261+
],
251262
parent: field('informant.relation')
252263
},
253264
{

src/form/v2/birth/forms/pages/mother.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,15 @@ export const mother = defineFormPage({
184184
},
185185
{
186186
id: 'mother.age',
187-
type: FieldType.TEXT,
187+
type: FieldType.AGE,
188188
required: true,
189189
label: {
190190
defaultMessage: 'Age of mother',
191191
description: 'This is the label for the field',
192192
id: 'event.birth.action.declare.form.section.mother.field.age.label'
193193
},
194194
configuration: {
195+
asOfDate: field('child.dob'),
195196
postfix: {
196197
defaultMessage: 'years',
197198
description: 'This is the postfix for age field',
@@ -206,6 +207,16 @@ export const mother = defineFormPage({
206207
requireMotherDetails
207208
)
208209
}
210+
],
211+
validation: [
212+
{
213+
validator: field('mother.age').asAge().isBetween(12, 120),
214+
message: {
215+
defaultMessage: 'Age must be between 12 and 120',
216+
description: 'Error message for invalid age',
217+
id: 'event.action.declare.form.section.person.field.age.error'
218+
}
219+
}
209220
]
210221
},
211222
{

src/form/v2/death/forms/pages/deceased.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@ export const deceased = defineFormPage({
151151
},
152152
{
153153
id: `deceased.age`,
154-
type: FieldType.TEXT,
154+
type: FieldType.AGE,
155155
required: true,
156156
label: {
157157
defaultMessage: `Age of deceased`,
158158
description: 'This is the label for the field',
159159
id: 'event.death.action.declare.form.section.deceased.field.age.label'
160160
},
161161
configuration: {
162+
asOfDate: field('eventDetails.date'),
162163
postfix: {
163164
defaultMessage: 'years',
164165
description: 'This is the postfix for age field',
@@ -170,6 +171,16 @@ export const deceased = defineFormPage({
170171
type: ConditionalType.SHOW,
171172
conditional: field(`deceased.dobUnknown`).isEqualTo(true)
172173
}
174+
],
175+
validation: [
176+
{
177+
validator: field('deceased.age').asAge().isBetween(0, 120),
178+
message: {
179+
defaultMessage: 'Age must be between 0 and 120',
180+
description: 'Error message for invalid age',
181+
id: 'event.death.action.declare.form.section.deceased.field.age.error'
182+
}
183+
}
173184
]
174185
},
175186
{

src/form/v2/death/forms/pages/informant.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,15 @@ export const informant = defineFormPage({
227227
},
228228
{
229229
id: 'informant.age',
230-
type: FieldType.TEXT,
230+
type: FieldType.AGE,
231231
required: true,
232232
label: {
233233
defaultMessage: 'Age of informant',
234234
description: 'This is the label for the field',
235235
id: 'event.death.action.declare.form.section.informant.field.age.label'
236236
},
237237
configuration: {
238+
asOfDate: field('eventDetails.date'),
238239
postfix: {
239240
defaultMessage: 'years',
240241
description: 'This is the postfix for age field',
@@ -250,6 +251,16 @@ export const informant = defineFormPage({
250251
)
251252
}
252253
],
254+
validation: [
255+
{
256+
validator: field('informant.age').asAge().isBetween(12, 120),
257+
message: {
258+
defaultMessage: 'Age must be between 12 and 120',
259+
description: 'Error message for invalid age',
260+
id: 'event.action.declare.form.section.person.field.age.error'
261+
}
262+
}
263+
],
253264
parent: field('informant.relation')
254265
},
255266
{

src/form/v2/death/forms/pages/spouse.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ export const spouse = defineFormPage({
174174
},
175175
{
176176
id: 'spouse.age',
177-
type: FieldType.TEXT,
177+
type: FieldType.AGE,
178178
required: true,
179179
label: {
180180
defaultMessage: 'Age of spouse',
181181
description: 'This is the label for the field',
182182
id: 'event.death.action.declare.form.section.spouse.field.age.label'
183183
},
184184
configuration: {
185+
asOfDate: field('eventDetails.date'),
185186
postfix: {
186187
defaultMessage: 'years',
187188
description: 'This is the postfix for age field',
@@ -196,6 +197,16 @@ export const spouse = defineFormPage({
196197
requireSpouseDetails
197198
)
198199
}
200+
],
201+
validation: [
202+
{
203+
validator: field('spouse.age').asAge().isBetween(12, 120),
204+
message: {
205+
defaultMessage: 'Age must be between 12 and 120',
206+
description: 'Error message for invalid age',
207+
id: 'event.action.declare.form.section.person.field.age.error'
208+
}
209+
}
199210
]
200211
},
201212
{

src/translations/client.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ error.userListError,Error message when user list loads fails,Failed to load user
792792
error.weAreTryingToFixThisError,Error description,This page could not be found,"Ce n'est pas vous, c'est nous. C'est notre faute."
793793
errors.notAssigned,User not assigned error toast message,You've been unassigned from the event,Vous avez été désassigné de l'événement
794794
errors.somethingWentWrong,Error toast message for general errors,Something went wrong. Please try again,Une erreur s'est produite. Veuillez réessayer
795+
event.action.declare.form.section.person.field.age.error,Error message for invalid age,Age must be between 12 and 120,L'auteur doit avoir entre 12 et 120 ans
795796
event.action.notAvailableForEvent,Shown when user tries to perform an action that is not available for the event,The action you're trying to perform is not available for this event anymore,L'action que vous essayez d'effectuer n'est plus disponible pour cet événement
796797
event.action.outbox-retry.label,Label for retry button for outbox,Retry,Réessayer
797798
event.action.review-correction.label,Label for review correction button in dropdown menu,Review,Revoir
@@ -939,6 +940,7 @@ event.death.action.declare.form.review.title,Title of the form to show in review
939940
event.death.action.declare.form.section.deceased.field.address.label,This is the label for the field,Usual place of residence,Lieu de résidence habituel
940941
event.death.action.declare.form.section.deceased.field.addressHelper.label,This is the label for the field,Usual place of residence,Lieu de résidence habituel
941942
event.death.action.declare.form.section.deceased.field.age.checkbox.label,This is the label for the field,Exact date of birth unknown,Date exacte de naissance inconnue
943+
event.death.action.declare.form.section.deceased.field.age.error,Error message for invalid age,Age must be between 0 and 120,L'auteur doit avoir entre 0 et 120 ans
942944
event.death.action.declare.form.section.deceased.field.age.label,This is the label for the field,Age of deceased,Âge du défunt
943945
event.death.action.declare.form.section.deceased.field.age.postfix,This is the postfix for age field,years,ans
944946
event.death.action.declare.form.section.deceased.field.deathLocation.label,This is the label for the field,Health Institution,Établissement de santé

0 commit comments

Comments
 (0)