diff --git a/knip.json b/knip.json new file mode 100644 index 00000000000..0e6b37a04b2 --- /dev/null +++ b/knip.json @@ -0,0 +1,3 @@ +{ + "ignore": ["packages/client/src/utils/gateway.ts"] +} diff --git a/packages/client/graphql.schema.json b/packages/client/graphql.schema.json index 4eaf4b8853f..55c72656d55 100644 --- a/packages/client/graphql.schema.json +++ b/packages/client/graphql.schema.json @@ -8,6 +8,37 @@ }, "subscriptionType": null, "types": [ + { + "kind": "UNION", + "name": "Action", + "description": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": [ + { + "kind": "OBJECT", + "name": "CreateAction", + "ofType": null + }, + { + "kind": "OBJECT", + "name": "DeclareAction", + "ofType": null + }, + { + "kind": "OBJECT", + "name": "NotifyAction", + "ofType": null + }, + { + "kind": "OBJECT", + "name": "RegisterAction", + "ofType": null + } + ] + }, { "kind": "OBJECT", "name": "AdditionalIdWithCompositionId", @@ -804,7 +835,7 @@ "args": [], "type": { "kind": "ENUM", - "name": "Event", + "name": "EventType", "ofType": null }, "isDeprecated": false, @@ -1591,7 +1622,7 @@ "description": null, "type": { "kind": "ENUM", - "name": "Event", + "name": "EventType", "ofType": null }, "defaultValue": null, @@ -2063,6 +2094,41 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "ApproveCorrectionActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "AssignmentData", @@ -3733,6 +3799,41 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "CertifyActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "Comment", @@ -3966,6 +4067,65 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "ConfirmRegistrationInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "error", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "identifiers", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "IdentifierInput", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "registrationNumber", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "ContactPoint", @@ -4511,6 +4671,89 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "CreateAction", + "description": null, + "fields": [ + { + "name": "createdAt", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "createdBy", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "fields", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Field", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "type", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "CreatedIds", @@ -4568,6 +4811,16 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "SCALAR", + "name": "DateTime", + "description": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "DeathEventSearchSet", @@ -5336,11 +5589,11 @@ }, { "kind": "OBJECT", - "name": "Dummy", + "name": "DeclareAction", "description": null, "fields": [ { - "name": "dummy", + "name": "createdAt", "description": null, "args": [], "type": { @@ -5348,32 +5601,166 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "DateTime", "ofType": null } }, "isDeprecated": false, "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "DuplicatesInfo", - "description": null, - "fields": [ + }, { - "name": "compositionId", + "name": "createdBy", "description": null, "args": [], "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "fields", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Field", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "identifiers", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Identifiers", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "type", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "DeclareActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "Dummy", + "description": null, + "fields": [ + { + "name": "dummy", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "DuplicatesInfo", + "description": null, + "fields": [ + { + "name": "compositionId", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null }, "isDeprecated": false, "deprecationReason": null @@ -5488,32 +5875,129 @@ "possibleTypes": null }, { - "kind": "ENUM", + "kind": "OBJECT", "name": "Event", "description": null, - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ + "fields": [ { - "name": "birth", + "name": "actions", "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "UNION", + "name": "Action", + "ofType": null + } + } + } + }, "isDeprecated": false, "deprecationReason": null }, { - "name": "death", + "name": "createdAt", "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + } + }, "isDeprecated": false, "deprecationReason": null }, { - "name": "marriage", + "name": "id", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "type", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "updatedAt", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "EventInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "type", "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, "isDeprecated": false, "deprecationReason": null } ], + "interfaces": null, + "enumValues": null, "possibleTypes": null }, { @@ -6363,12 +6847,41 @@ ] }, { - "kind": "INPUT_OBJECT", - "name": "FHIRIDMap", + "kind": "ENUM", + "name": "EventType", "description": null, "fields": null, - "inputFields": [ - { + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "birth", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "death", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "marriage", + "description": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "FHIRIDMap", + "description": null, + "fields": null, + "inputFields": [ + { "name": "composition", "description": null, "type": { @@ -6433,6 +6946,92 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "Field", + "description": null, + "fields": [ + { + "name": "id", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "value", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "FieldValue", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "value", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "FieldValue", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "SCALAR", "name": "FieldValue", @@ -7034,6 +7633,92 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "IdentifierInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "type", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "value", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "Identifiers", + "description": null, + "fields": [ + { + "name": "registrationNumber", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "trackingId", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "IdentityInput", @@ -7299,6 +7984,41 @@ ], "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "IssueActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "LabelInput", @@ -8875,18 +9595,18 @@ "deprecationReason": null }, { - "name": "approveDeathRegistrationCorrection", + "name": "approveCorrectionEvent", "description": null, "args": [ { - "name": "details", + "name": "eventId", "description": null, "type": { "kind": "NON_NULL", "name": null, "ofType": { - "kind": "INPUT_OBJECT", - "name": "DeathRegistrationInput", + "kind": "SCALAR", + "name": "ID", "ofType": null } }, @@ -8895,14 +9615,14 @@ "deprecationReason": null }, { - "name": "id", + "name": "input", "description": null, "type": { "kind": "NON_NULL", "name": null, "ofType": { - "kind": "SCALAR", - "name": "ID", + "kind": "INPUT_OBJECT", + "name": "ApproveCorrectionActionInput", "ofType": null } }, @@ -8915,8 +9635,8 @@ "kind": "NON_NULL", "name": null, "ofType": { - "kind": "SCALAR", - "name": "ID", + "kind": "OBJECT", + "name": "Event", "ofType": null } }, @@ -8924,7 +9644,7 @@ "deprecationReason": null }, { - "name": "approveMarriageRegistrationCorrection", + "name": "approveDeathRegistrationCorrection", "description": null, "args": [ { @@ -8935,7 +9655,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "MarriageRegistrationInput", + "name": "DeathRegistrationInput", "ofType": null } }, @@ -8973,19 +9693,68 @@ "deprecationReason": null }, { - "name": "auditUser", + "name": "approveMarriageRegistrationCorrection", "description": null, "args": [ { - "name": "action", + "name": "details", "description": null, "type": { "kind": "NON_NULL", "name": null, "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "INPUT_OBJECT", + "name": "MarriageRegistrationInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "auditUser", + "description": null, + "args": [ + { + "name": "action", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null } }, "defaultValue": null, @@ -9074,6 +9843,55 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "certifyEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "CertifyActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "changeAvatar", "description": null, @@ -9338,6 +10156,22 @@ "name": "confirmRegistration", "description": null, "args": [ + { + "name": "details", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "ConfirmRegistrationInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "id", "description": null, @@ -9531,6 +10365,39 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "createEvent", + "description": null, + "args": [ + { + "name": "event", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "EventInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createMarriageRegistration", "description": null, @@ -9675,6 +10542,55 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "declareEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "DeclareActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deleteSystem", "description": null, @@ -9704,6 +10620,55 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "issueEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "IssueActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "markBirthAsCertified", "description": null, @@ -10653,11 +11618,11 @@ "deprecationReason": null }, { - "name": "reactivateSystem", + "name": "notifyEvent", "description": null, "args": [ { - "name": "clientId", + "name": "eventId", "description": null, "type": { "kind": "NON_NULL", @@ -10671,18 +11636,67 @@ "defaultValue": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "NotifyActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "type": { - "kind": "OBJECT", - "name": "System", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null }, { - "name": "refreshSystemSecret", + "name": "reactivateSystem", + "description": null, + "args": [ + { + "name": "clientId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "System", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "refreshSystemSecret", "description": null, "args": [ { @@ -10710,6 +11724,55 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "registerEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "RegisterActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "registerSystem", "description": null, @@ -10735,6 +11798,153 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "reinstateEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "ReinstateActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "rejectCorrectionEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "RejectCorrectionActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "rejectRegistration", + "description": null, + "args": [ + { + "name": "details", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "RejectRegistrationInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "rejectRegistrationCorrection", "description": null, @@ -10813,6 +12023,55 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "requestCorrectionEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "RequestCorrectionActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "requestRegistrationCorrection", "description": null, @@ -10920,6 +12179,104 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "revokeCorrectionEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "RevokeCorrectionActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "revokeEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "RevokeActionInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "updateDeathRegistration", "description": null, @@ -11014,13 +12371,135 @@ "isDeprecated": false, "deprecationReason": null } - ], + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Response", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "usernameReminder", + "description": null, + "args": [ + { + "name": "userId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "NotificationResult", + "description": null, + "fields": [ + { + "name": "success", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "ENUM", + "name": "NotificationType", + "description": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "EMAIL", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SMS", + "description": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "NotifyAction", + "description": null, + "fields": [ + { + "name": "createdAt", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "createdBy", + "description": null, + "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { - "kind": "OBJECT", - "name": "Response", + "kind": "SCALAR", + "name": "String", "ofType": null } }, @@ -11028,47 +12507,31 @@ "deprecationReason": null }, { - "name": "usernameReminder", + "name": "fields", "description": null, - "args": [ - { - "name": "userId", - "description": null, - "type": { + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { "kind": "NON_NULL", "name": null, "ofType": { - "kind": "SCALAR", - "name": "String", + "kind": "OBJECT", + "name": "Field", "ofType": null } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null + } } - ], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null }, "isDeprecated": false, "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "NotificationResult", - "description": null, - "fields": [ + }, { - "name": "success", + "name": "type", "description": null, "args": [], "type": { @@ -11076,7 +12539,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "Boolean", + "name": "String", "ofType": null } }, @@ -11090,26 +12553,38 @@ "possibleTypes": null }, { - "kind": "ENUM", - "name": "NotificationType", + "kind": "INPUT_OBJECT", + "name": "NotifyActionInput", "description": null, "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "EMAIL", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, + "inputFields": [ { - "name": "SMS", + "name": "fields", "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, "isDeprecated": false, "deprecationReason": null } ], + "interfaces": null, + "enumValues": null, "possibleTypes": null }, { @@ -12790,6 +14265,39 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "getEvent", + "description": null, + "args": [ + { + "name": "eventId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Event", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "getEventsWithProgress", "description": null, @@ -13446,9 +14954,13 @@ "name": "userId", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, @@ -13552,9 +15064,13 @@ "name": "email", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, @@ -13577,9 +15093,13 @@ "name": "mobile", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, @@ -14886,29 +16406,163 @@ "name": "Date", "ofType": null }, - "defaultValue": null, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "type", + "description": null, + "type": { + "kind": "ENUM", + "name": "RegStatus", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "user", + "description": null, + "type": { + "kind": "INPUT_OBJECT", + "name": "UserInput", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "RegisterAction", + "description": null, + "fields": [ + { + "name": "createdAt", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "createdBy", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "fields", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Field", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "identifiers", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Identifiers", + "ofType": null + } + }, "isDeprecated": false, "deprecationReason": null }, { "name": "type", "description": null, + "args": [], "type": { - "kind": "ENUM", - "name": "RegStatus", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, - "defaultValue": null, "isDeprecated": false, "deprecationReason": null - }, + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "RegisterActionInput", + "description": null, + "fields": null, + "inputFields": [ { - "name": "user", + "name": "fields", "description": null, "type": { - "kind": "INPUT_OBJECT", - "name": "UserInput", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } }, "defaultValue": null, "isDeprecated": false, @@ -15852,6 +17506,41 @@ ], "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "ReinstateActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "Reinstated", @@ -15891,6 +17580,80 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "RejectCorrectionActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "RejectRegistrationInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "comment", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "reason", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "RelatedPerson", @@ -16620,6 +18383,41 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "RequestCorrectionActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "Response", @@ -16647,6 +18445,76 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "RevokeActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "RevokeCorrectionActionInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "fields", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "FieldInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "Role", @@ -20309,6 +22177,15 @@ } ] }, + { + "name": "oneOf", + "description": "Indicates exactly one field must be supplied and this field must not be `null`.", + "isRepeatable": false, + "locations": [ + "INPUT_OBJECT" + ], + "args": [] + }, { "name": "skip", "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", @@ -20339,7 +22216,7 @@ }, { "name": "specifiedBy", - "description": "Exposes a URL that specifies the behaviour of this scalar.", + "description": "Exposes a URL that specifies the behavior of this scalar.", "isRepeatable": false, "locations": [ "SCALAR" @@ -20347,7 +22224,7 @@ "args": [ { "name": "url", - "description": "The URL that specifies the behaviour of this scalar.", + "description": "The URL that specifies the behavior of this scalar.", "type": { "kind": "NON_NULL", "name": null, diff --git a/packages/client/knip.json b/packages/client/knip.json new file mode 100644 index 00000000000..e4c0a08efce --- /dev/null +++ b/packages/client/knip.json @@ -0,0 +1,3 @@ +{ + "ignore": ["./src/utils/gateway.ts"] +} diff --git a/packages/client/package.json b/packages/client/package.json index db986d963e9..770846101f1 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -34,8 +34,8 @@ "dependencies": { "@apollo/client": "^3.7.0", "@craco/craco": "^6.4.3", - "@opencrvs/components": "^1.3.0", "@opencrvs/commons": "^1.5.0", + "@opencrvs/components": "^1.3.0", "@reduxjs/toolkit": "^1.8.3", "@sentry/react": "^7.12.1", "@sentry/tracing": "^7.12.1", @@ -108,7 +108,6 @@ "xregexp": "^4.2.0" }, "devDependencies": { - "@opencrvs/gateway": "^1.5.0", "@graphql-codegen/add": "^5.0.0", "@graphql-codegen/cli": "^5.0.0", "@graphql-codegen/introspection": "^3.0.0", @@ -121,6 +120,7 @@ "@types/fhir": "^0.0.30", "@types/google-libphonenumber": "^7.4.23", "@types/handlebars": "^4.1.0", + "@types/jsonwebtoken": "^9.0.7", "@types/jwt-decode": "^2.2.1", "@types/lodash": "^4.14.149", "@types/node": "^20.12.7", diff --git a/packages/client/src/App.tsx b/packages/client/src/App.tsx index ce82f7c167e..b4b84ef792a 100644 --- a/packages/client/src/App.tsx +++ b/packages/client/src/App.tsx @@ -16,7 +16,6 @@ import { ProtectedRoute } from '@client/components/ProtectedRoute' import ScrollToTop from '@client/components/ScrollToTop' import { SessionExpireConfirmation } from '@client/components/SessionExpireConfirmation' import { StyledErrorBoundary } from '@client/components/StyledErrorBoundary' -import TransitionWrapper from '@client/components/TransitionWrapper' import { I18nContainer } from '@client/i18n/components/I18nContainer' import * as routes from '@client/navigation/routes' import styled, { createGlobalStyle, ThemeProvider } from 'styled-components' @@ -70,8 +69,9 @@ import { ReviewCorrection } from './views/ReviewCorrection/ReviewCorrection' import { ReviewCertificate } from './views/PrintCertificate/ReviewCertificateAction' import AllUserEmail from './views/SysAdmin/Communications/AllUserEmail/AllUserEmail' import { ReloadModal } from './views/Modals/ReloadModal' -import { Workqueues } from './v2-events/workqueues' -import { V2_ROOT_ROUTE } from './v2-events/routes' +import { V2_EVENT_ROUTE, V2_ROOT_ROUTE } from './v2-events/routes/routes' +import { Workqueues } from './v2-events/features/workqueues' +import { PublishEvent } from './v2-events/features/events/PublishEvent' interface IAppProps { client?: ApolloClient @@ -127,425 +127,412 @@ export function App(props: IAppProps) { }) => { return ( <> - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) }} diff --git a/packages/client/src/components/TransitionWrapper.tsx b/packages/client/src/components/TransitionWrapper.tsx deleted file mode 100644 index a93294b0ac2..00000000000 --- a/packages/client/src/components/TransitionWrapper.tsx +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import * as React from 'react' -import { TransitionGroup, CSSTransition } from 'react-transition-group' -import { - PAGE_TRANSITIONS_ENTER_TIME, - PAGE_TRANSITIONS_CLASSNAME, - PAGE_TRANSITIONS_EXIT_TIME -} from '@client/utils/constants' -import * as routes from '@client/navigation/routes' -import { matchPath } from 'react-router-dom' -import { Location } from 'history' - -function isPathExactmatch(pathname: string, routesPath: string): boolean { - const match = matchPath(pathname, routesPath) - if (match) { - return match.isExact - } - - return false -} - -function isUserHome(pathname: string): boolean { - if ( - isPathExactmatch(pathname, routes.HOME) || - isPathExactmatch(pathname, routes.REGISTRAR_HOME) || - isPathExactmatch(pathname, routes.REGISTRAR_HOME_TAB) - ) { - return true - } - - return false -} - -function isFormPage(pathname: string): boolean { - if ( - isPathExactmatch(pathname, routes.DRAFT_BIRTH_PARENT_FORM) || - isPathExactmatch(pathname, routes.DRAFT_BIRTH_PARENT_FORM_PAGE) || - isPathExactmatch(pathname, routes.DRAFT_BIRTH_PARENT_FORM_PAGE_GROUP) || - isPathExactmatch(pathname, routes.DRAFT_DEATH_FORM) || - isPathExactmatch(pathname, routes.DRAFT_DEATH_FORM_PAGE) || - isPathExactmatch(pathname, routes.DRAFT_DEATH_FORM_PAGE_GROUP) || - isPathExactmatch(pathname, routes.REVIEW_EVENT_PARENT_FORM_PAGE) || - isPathExactmatch(pathname, routes.REVIEW_EVENT_PARENT_FORM_PAGE_GROUP) - ) { - return true - } - - return false -} - -let locationKey = 'locationkey' - -function setLocationKey(currLocation: Location, prevLocation: Location) { - const prevLocPathname = prevLocation.pathname - const currLocPathname = currLocation.pathname - - if (currLocPathname === routes.SELECT_VITAL_EVENT) { - if (isUserHome(prevLocPathname)) { - locationKey = currLocation.key as string - } - } else if (isUserHome(currLocPathname)) { - if (isFormPage(prevLocPathname)) { - locationKey = currLocation.key as string - } - } -} -interface IProps { - location: Location - children: React.ReactNode -} -interface IState { - locations: Location[] -} -export default class TransitionWrapper extends React.Component { - constructor(props: IProps) { - super(props) - - this.state = { - locations: [this.props.location, this.props.location] - } - } - - static getDerivedStateFromProps( - { location: currLocation }: IProps, - { locations: [prevLocation] }: IState - ) { - return { locations: [currLocation, prevLocation] } - } - - render() { - const { children } = this.props - const { - locations: [currLocation, prevLocation] - } = this.state - - setLocationKey(currLocation, prevLocation) - - return ( - - - {children} - - - ) - } -} diff --git a/packages/client/src/components/charts/RegRatesLineChart.tsx b/packages/client/src/components/charts/RegRatesLineChart.tsx index 2f5ad7462e5..b487a501e56 100644 --- a/packages/client/src/components/charts/RegRatesLineChart.tsx +++ b/packages/client/src/components/charts/RegRatesLineChart.tsx @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { constantsMessages } from '@client/i18n/messages' import { LineChart } from '@opencrvs/components/lib/LineChart' import { ITheme } from '@opencrvs/components/lib/theme' @@ -23,7 +23,7 @@ interface IProps extends WrappedComponentProps { theme: ITheme data?: ILineDataPoint[] loading?: boolean - eventType?: Event + eventType?: EventType completenessRateTime?: CompletenessRateTime } @@ -277,7 +277,7 @@ const RegRatesLineChartComponent = (props: IProps) => { messages.performanceWithinTargetDaysLabel, { target: - eventType === Event.Birth + eventType === EventType.Birth ? window.config.BIRTH.REGISTRATION_TARGET : window.config.DEATH.REGISTRATION_TARGET, withPrefix: false diff --git a/packages/client/src/components/form/FormFieldGenerator.test.tsx b/packages/client/src/components/form/FormFieldGenerator.test.tsx index 7ad2585cc15..b15f46ad29e 100644 --- a/packages/client/src/components/form/FormFieldGenerator.test.tsx +++ b/packages/client/src/components/form/FormFieldGenerator.test.tsx @@ -29,7 +29,7 @@ import { DATE, NUMBER } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { countries } from '@client/utils/countries' import { OFFLINE_LOCATIONS_KEY } from '@client/offline/reducer' import { formMessages } from '@client/i18n/messages' @@ -42,7 +42,7 @@ describe('form component', () => { beforeEach(async () => { const { store, history } = createStore() - const draft = createDeclaration(Event.Birth) + const draft = createDeclaration(EventType.Birth) store.dispatch(storeDeclaration(draft)) const modifyDraft = vi.fn() component = await createTestComponent( @@ -216,7 +216,7 @@ describe('when user is in the register section', () => { let component: ReactWrapper<{}, {}> beforeEach(async () => { const { store, history } = createStore() - const draft = createDeclaration(Event.Birth) + const draft = createDeclaration(EventType.Birth) store.dispatch(storeDeclaration(draft)) const modifyDraft = vi.fn() component = await createTestComponent( @@ -258,7 +258,7 @@ describe('when field definition has nested fields', () => { beforeEach(async () => { const { store, history } = createStore() - const draft = createDeclaration(Event.Birth) + const draft = createDeclaration(EventType.Birth) store.dispatch(storeDeclaration(draft)) const modifyDraft = vi.fn() component = await createTestComponent( diff --git a/packages/client/src/components/interface/DownloadButton.tsx b/packages/client/src/components/interface/DownloadButton.tsx index 6ef4dc87c7d..6a6fdac853c 100644 --- a/packages/client/src/components/interface/DownloadButton.tsx +++ b/packages/client/src/components/interface/DownloadButton.tsx @@ -8,42 +8,42 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as React from 'react' -import styled from 'styled-components' -import { ResponsiveModal } from '@opencrvs/components/lib/ResponsiveModal' -import { Spinner } from '@opencrvs/components/lib/Spinner' -import { IActionObject } from '@opencrvs/components/lib/Workqueue' -import { Download } from '@opencrvs/components/lib/icons' -import { Button } from '@opencrvs/components/lib/Button' -import { connect } from 'react-redux' -import { - downloadDeclaration, - DOWNLOAD_STATUS, - unassignDeclaration, - deleteDeclaration as deleteDeclarationAction -} from '@client/declarations' -import { Action } from '@client/forms' -import { Event, SystemRoleType } from '@client/utils/gateway' import { ApolloClient, InternalRefetchQueriesInclude, useApolloClient } from '@apollo/client' -import { Downloaded } from '@opencrvs/components/lib/icons/Downloaded' -import type { AssignmentData } from '@client/utils/gateway' -import { IStoreState } from '@client/store' import { AvatarSmall } from '@client/components/Avatar' +import { + deleteDeclaration as deleteDeclarationAction, + DOWNLOAD_STATUS, + downloadDeclaration, + unassignDeclaration +} from '@client/declarations' +import { Action } from '@client/forms' +import { buttonMessages, constantsMessages } from '@client/i18n/messages' +import { conflictsMessages } from '@client/i18n/messages/views/conflicts' +import { IStoreState } from '@client/store' +import { useOnlineStatus } from '@client/utils' import { FIELD_AGENT_ROLES, ROLE_REGISTRATION_AGENT } from '@client/utils/constants' -import { Dispatch } from 'redux' -import { useIntl, IntlShape, MessageDescriptor } from 'react-intl' -import { buttonMessages, constantsMessages } from '@client/i18n/messages' -import { conflictsMessages } from '@client/i18n/messages/views/conflicts' +import type { AssignmentData } from '@client/utils/gateway' +import { EventType, SystemRoleType } from '@client/utils/gateway' +import { Button } from '@opencrvs/components/lib/Button' +import { ResponsiveModal } from '@opencrvs/components/lib/ResponsiveModal' +import { Spinner } from '@opencrvs/components/lib/Spinner' +import { IActionObject } from '@opencrvs/components/lib/Workqueue' +import { Download } from '@opencrvs/components/lib/icons' import { ConnectionError } from '@opencrvs/components/lib/icons/ConnectionError' -import { useOnlineStatus } from '@client/utils' +import { Downloaded } from '@opencrvs/components/lib/icons/Downloaded' +import * as React from 'react' +import { IntlShape, MessageDescriptor, useIntl } from 'react-intl' +import { connect } from 'react-redux' import ReactTooltip from 'react-tooltip' +import { Dispatch } from 'redux' +import styled from 'styled-components' const { useState, useCallback, useMemo } = React interface IDownloadConfig { @@ -229,7 +229,7 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) { const download = useCallback(() => { const { event, compositionId, action } = downloadConfigs downloadDeclaration( - event.toLowerCase() as unknown as Event, + event.toLowerCase() as unknown as EventType, compositionId, action, client @@ -388,7 +388,7 @@ const mapDispatchToProps = ( ownProps: DownloadButtonProps ): IDispatchProps => ({ downloadDeclaration: ( - event: Event, + event: EventType, compositionId: string, action: Action, client: ApolloClient diff --git a/packages/client/src/components/interface/Navigation.tsx b/packages/client/src/components/interface/Navigation.tsx index 5e6c286848c..962cab318f9 100644 --- a/packages/client/src/components/interface/Navigation.tsx +++ b/packages/client/src/components/interface/Navigation.tsx @@ -45,7 +45,7 @@ import { INPROGRESS_STATUS } from '@client/SubmissionController' import { isDeclarationInReadyToReviewStatus } from '@client/utils/draftUtils' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { UserDetails } from '@client/utils/userUtils' import { IWorkqueue, updateRegistrarWorkqueue } from '@client/workqueue' import { IStoreState } from '@opencrvs/client/src/store' @@ -337,10 +337,12 @@ const NavigationView = (props: IFullProps) => { ) const runningVer = String(localStorage.getItem('running-version')) - const isOnePrintInAdvanceOn = Object.values(Event).some((event: Event) => { - const upperCaseEvent = event.toUpperCase() as Uppercase - return offlineCountryConfiguration.config[upperCaseEvent].PRINT_IN_ADVANCE - }) + const isOnePrintInAdvanceOn = Object.values(EventType).some( + (event: EventType) => { + const upperCaseEvent = event.toUpperCase() as Uppercase + return offlineCountryConfiguration.config[upperCaseEvent].PRINT_IN_ADVANCE + } + ) const showRegDashboard = !IS_PROD_ENVIRONMENT || (IS_PROD_ENVIRONMENT && window.config.REGISTRATIONS_DASHBOARD_URL) diff --git a/packages/client/src/components/review/RejectRegistrationForm.test.tsx b/packages/client/src/components/review/RejectRegistrationForm.test.tsx index 09c7c059d2b..ceb832787db 100644 --- a/packages/client/src/components/review/RejectRegistrationForm.test.tsx +++ b/packages/client/src/components/review/RejectRegistrationForm.test.tsx @@ -13,7 +13,7 @@ import { ReactWrapper } from 'enzyme' import { createStore } from '@client/store' import { createTestComponent } from '@client/tests/util' import { RejectRegistrationForm } from '@opencrvs/client/src/components/review/RejectRegistrationForm' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { createDeclaration } from '@client/declarations' import { vi } from 'vitest' @@ -22,7 +22,7 @@ const mockHandler = vi.fn() describe('reject registration form', () => { let component: ReactWrapper<{}, {}> - const draftDeclaration = createDeclaration(Event.Birth) + const draftDeclaration = createDeclaration(EventType.Birth) beforeEach(async () => { component = await createTestComponent( { confirmRejectionEvent={mockHandler} declaration={draftDeclaration} draftId="04ba2b0e-ba38-4049-ad74-332e4ee9fbfe" - event={Event.Birth} + event={EventType.Birth} />, { store, history } ) diff --git a/packages/client/src/components/review/RejectRegistrationForm.tsx b/packages/client/src/components/review/RejectRegistrationForm.tsx index 3de96f8e47e..80a07b7b75b 100644 --- a/packages/client/src/components/review/RejectRegistrationForm.tsx +++ b/packages/client/src/components/review/RejectRegistrationForm.tsx @@ -10,17 +10,21 @@ */ import { FormFieldGenerator } from '@client/components/form' import { + archiveDeclaration, IDeclaration, IPayload, - SUBMISSION_STATUS, - archiveDeclaration + SUBMISSION_STATUS } from '@client/declarations' import { IFormSectionData, SubmissionAction } from '@client/forms' import { hasFormError } from '@client/forms/utils' import { buttonMessages } from '@client/i18n/messages' import { messages } from '@client/i18n/messages/views/reject' -import styled from 'styled-components' -import { Event } from '@client/utils/gateway' +import { goToHome } from '@client/navigation' +import { IOfflineData } from '@client/offline/reducer' +import { getOfflineData } from '@client/offline/selectors' +import { getUserDetails } from '@client/profile/profileSelectors' +import { EventType } from '@client/utils/gateway' +import { UserDetails } from '@client/utils/userUtils' import { IRejectRegistrationForm, rejectRegistration @@ -28,15 +32,11 @@ import { import { IStoreState } from '@opencrvs/client/src/store' import { Button } from '@opencrvs/components/lib/Button' import { ResponsiveModal } from '@opencrvs/components/lib/ResponsiveModal' +import { isEmpty } from 'lodash' import * as React from 'react' import { injectIntl, WrappedComponentProps as IntlShapeProps } from 'react-intl' import { connect } from 'react-redux' -import { isEmpty } from 'lodash' -import { goToHome } from '@client/navigation' -import { getOfflineData } from '@client/offline/selectors' -import { IOfflineData } from '@client/offline/reducer' -import { getUserDetails } from '@client/profile/profileSelectors' -import { UserDetails } from '@client/utils/userUtils' +import styled from 'styled-components' const Instruction = styled.div` margin-bottom: 28px; @@ -51,7 +51,7 @@ interface IProps { config: IOfflineData user: UserDetails | null declaration: IDeclaration - event: Event + event: EventType duplicate?: boolean onClose: () => void archiveDeclaration: typeof archiveDeclaration diff --git a/packages/client/src/declarations/index.test.ts b/packages/client/src/declarations/index.test.ts index 85794d7855f..5a861bab80c 100644 --- a/packages/client/src/declarations/index.test.ts +++ b/packages/client/src/declarations/index.test.ts @@ -17,7 +17,7 @@ import { filterProcessingDeclarations, filterProcessingDeclarationsFromQuery } from '.' -import { Event, SystemRoleType, Status } from '@client/utils/gateway' +import { EventType, SystemRoleType, Status } from '@client/utils/gateway' import { AppStore, createStore } from '@client/store' import { mockDeclarationData, flushPromises } from '@client/tests/util' import { storage } from '@client/storage' @@ -277,13 +277,13 @@ describe('Utilty functions', () => { { id: '1', data: {}, - event: Event.Birth, + event: EventType.Birth, compositionId: '1' }, { id: '2', data: {}, - event: Event.Death, + event: EventType.Death, compositionId: '2' } ] @@ -304,7 +304,7 @@ describe('Utilty functions', () => { describe('archiveDeclaration tests', () => { let store: AppStore - const declaration = createDeclaration(Event.Birth, mockDeclarationData) + const declaration = createDeclaration(EventType.Birth, mockDeclarationData) let indexedDB: { USER_DATA: string; USER_DETAILS: string } beforeEach(() => { diff --git a/packages/client/src/declarations/index.ts b/packages/client/src/declarations/index.ts index 9b8186070d0..3860e2838a4 100644 --- a/packages/client/src/declarations/index.ts +++ b/packages/client/src/declarations/index.ts @@ -21,7 +21,7 @@ import { } from '@client/forms' import { Attachment, - Event, + EventType, History, Query, RegStatus, @@ -226,7 +226,7 @@ export interface IDeclaration { modifiedOn?: number eventType?: string review?: boolean - event: Event + event: EventType registrationStatus?: RegStatus submissionStatus?: string downloadStatus?: DOWNLOAD_STATUS @@ -410,7 +410,7 @@ interface IDownloadDeclarationSuccess { payload: { queryData: any form: { - [key in Event]: IForm + [key in EventType]: IForm } client: ApolloClient<{}> offlineData?: IOfflineData @@ -504,15 +504,15 @@ const initialState: IDeclarationsState = { /* Need to add mappings for events here */ const QueryMapper = { - [Event.Birth]: getBirthQueryMappings, - [Event.Death]: getDeathQueryMappings, - [Event.Marriage]: getMarriageQueryMappings + [EventType.Birth]: getBirthQueryMappings, + [EventType.Death]: getDeathQueryMappings, + [EventType.Marriage]: getMarriageQueryMappings } -const getQueryMapping = (event: Event, action: DeclarationAction) => { +const getQueryMapping = (event: EventType, action: DeclarationAction) => { return QueryMapper[event] && QueryMapper[event](action) } -export function createDeclaration(event: Event, initialData?: IFormData) { +export function createDeclaration(event: EventType, initialData?: IFormData) { return { id: uuid(), data: initialData || {}, @@ -522,7 +522,7 @@ export function createDeclaration(event: Event, initialData?: IFormData) { } export function makeDeclarationReadyToDownload( - event: Event, + event: EventType, compositionId: string, action: DeclarationAction ): IDeclaration { @@ -538,7 +538,7 @@ export function makeDeclarationReadyToDownload( export function createReviewDeclaration( declarationId: string, formData: IFormData, - event: Event, + event: EventType, status?: RegStatus, duplicates?: IDuplicates[] ): IDeclaration { @@ -1029,7 +1029,7 @@ export async function deleteDeclarationByUser( } export function downloadDeclaration( - event: Event, + event: EventType, compositionId: string, action: DeclarationAction, client: ApolloClient<{}> diff --git a/packages/client/src/declarations/submissionMiddleware.test.ts b/packages/client/src/declarations/submissionMiddleware.test.ts index a74b063b0a9..7a2372f2e6d 100644 --- a/packages/client/src/declarations/submissionMiddleware.test.ts +++ b/packages/client/src/declarations/submissionMiddleware.test.ts @@ -10,13 +10,15 @@ */ import { ApolloError } from '@apollo/client' import { SubmissionAction } from '@client/forms' +import { offlineDataReady } from '@client/offline/actions' +import { createStore } from '@client/store' import { ACTION_STATUS_MAP, mockDeclarationData, mockOfflineDataDispatch } from '@client/tests/util' import { createClient } from '@client/utils/apolloClient' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { GraphQLError } from 'graphql' import { SpyInstance, vi } from 'vitest' import { SUBMISSION_STATUS } from '.' @@ -24,8 +26,6 @@ import { declarationReadyForStatusChange, submissionMiddleware } from './submissionMiddleware' -import { createStore } from '@client/store' -import { offlineDataReady } from '@client/offline/actions' describe('Submission middleware', () => { const dispatch = vi.fn() @@ -63,7 +63,7 @@ describe('Submission middleware', () => { const action = declarationReadyForStatusChange({ id: 'mockDeclaration', data: mockDeclarationData, - event: Event.Birth, + event: EventType.Birth, action: SubmissionAction.SUBMIT_FOR_REVIEW, submissionStatus: SUBMISSION_STATUS.READY_TO_SUBMIT }) @@ -82,7 +82,7 @@ describe('Submission middleware', () => { const action = declarationReadyForStatusChange({ id: 'mockDeclaration', data: mockDeclarationData, - event: Event.Birth, + event: EventType.Birth, action: SubmissionAction.REJECT_DECLARATION, submissionStatus: SUBMISSION_STATUS.READY_TO_REJECT }) @@ -112,7 +112,7 @@ describe('Submission middleware', () => { const action = declarationReadyForStatusChange({ id: 'mockDeclaration', data: mockDeclarationData, - event: Event.Birth, + event: EventType.Birth, action: SubmissionAction.SUBMIT_FOR_REVIEW, submissionStatus: SUBMISSION_STATUS.READY_TO_SUBMIT }) @@ -125,10 +125,10 @@ describe('Submission middleware', () => { ) }) - Object.values(Event).forEach((event) => { + Object.values(EventType).forEach((event) => { Object.values(SubmissionAction).forEach((submissionAction) => { if ( - event === Event.Marriage && + event === EventType.Marriage && [ SubmissionAction.APPROVE_CORRECTION, SubmissionAction.REJECT_CORRECTION, diff --git a/packages/client/src/declarations/submissionMiddleware.ts b/packages/client/src/declarations/submissionMiddleware.ts index 9322d0cda31..879d84267e4 100644 --- a/packages/client/src/declarations/submissionMiddleware.ts +++ b/packages/client/src/declarations/submissionMiddleware.ts @@ -32,7 +32,7 @@ import { } from '@client/transformer' import { client } from '@client/utils/apolloClient' import { FIELD_AGENT_ROLES } from '@client/utils/constants' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { MARK_EVENT_AS_DUPLICATE, getBirthMutation @@ -44,12 +44,13 @@ import { updateRegistrarWorkqueue } from '@client/workqueue' import { Action, Middleware, createAction } from '@reduxjs/toolkit' import { Dispatch } from 'redux' // eslint-disable-next-line no-restricted-imports -import { captureException } from '@sentry/browser' -import { getOfflineData } from '@client/offline/selectors' +import { getReviewForm } from '@client/forms/register/review-selectors' import { IOfflineData } from '@client/offline/reducer' +import { getOfflineData } from '@client/offline/selectors' import type { MutationToRequestRegistrationCorrectionArgs } from '@client/utils/gateway-deprecated-do-not-use' import { UserDetails } from '@client/utils/userUtils' -import { getReviewForm } from '@client/forms/register/review-selectors' +// eslint-disable-next-line no-restricted-imports +import { captureException } from '@sentry/browser' type IReadyDeclaration = IDeclaration & { action: SubmissionAction @@ -222,9 +223,9 @@ export const submissionMiddleware: Middleware<{}, IStoreState> = } const mutation = - event === Event.Birth + event === EventType.Birth ? getBirthMutation(submissionAction) - : event === Event.Death + : event === EventType.Death ? getDeathMutation(submissionAction) : getMarriageMutation(submissionAction) diff --git a/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts b/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts index d306f3df5be..a41156755f8 100644 --- a/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts +++ b/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts @@ -33,7 +33,7 @@ import { validIDNumber } from '@client/utils/validate' import { RadioSize } from '@opencrvs/components/lib/Radio' import { BIRTH_REGISTRATION_NUMBER, NATIONAL_ID } from '@client/utils/constants' import { identityHelperTextMapper, identityNameMapper } from './messages' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { IDeclaration } from '@client/declarations' import { issueMessages } from '@client/i18n/messages/issueCertificate' @@ -808,11 +808,11 @@ export const collectMarriageCertificateFormSection: IFormSection = { ] } -const otherCertCollectorFormGroup = (event: Event): IFormSectionGroup => { +const otherCertCollectorFormGroup = (event: EventType): IFormSectionGroup => { const labelMap = { - [Event.Birth]: formMessages.informantsRelationWithChild, - [Event.Death]: formMessages.informantsRelationWithDeceased, - [Event.Marriage]: formMessages.relationshipToSpouses + [EventType.Birth]: formMessages.informantsRelationWithChild, + [EventType.Death]: formMessages.informantsRelationWithDeceased, + [EventType.Marriage]: formMessages.relationshipToSpouses } const fields: IFormField[] = [ @@ -1125,7 +1125,7 @@ export function getFilteredRadioOptions( birthForm: IRadioOption[], marriageForm?: IRadioOption[] ): IRadioOption[] { - if (declaration.event === Event.Birth) { + if (declaration.event === EventType.Birth) { options.splice(1, 0, ...birthForm) const rolesToCheck = ['MOTHER', 'FATHER'] @@ -1134,7 +1134,7 @@ export function getFilteredRadioOptions( options = options.filter((opt) => opt.value !== role) } } - } else if (declaration.event === Event.Marriage && marriageForm) { + } else if (declaration.event === EventType.Marriage && marriageForm) { options.splice(1, 0, ...marriageForm) } diff --git a/packages/client/src/forms/correction/corrector.ts b/packages/client/src/forms/correction/corrector.ts index acd1cb1f236..ebc6719864a 100644 --- a/packages/client/src/forms/correction/corrector.ts +++ b/packages/client/src/forms/correction/corrector.ts @@ -16,12 +16,12 @@ import { IRadioOption, RADIO_GROUP_WITH_NESTED_FIELDS } from '@client/forms' +import { getFilteredRadioOptions } from '@client/forms/certificate/fieldDefinitions/collectorSection' import { fieldValueSectionExchangeTransformer } from '@client/forms/register/mappings/mutation' -import { formMessages, constantsMessages } from '@client/i18n/messages' +import { constantsMessages, formMessages } from '@client/i18n/messages' import { messages } from '@client/i18n/messages/views/correction' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { RadioSize } from '@opencrvs/components/lib/Radio' -import { getFilteredRadioOptions } from '@client/forms/certificate/fieldDefinitions/collectorSection' export enum CorrectorRelationship { //death @@ -174,7 +174,7 @@ export const getCorrectorSection = ( name: 'otherRelationship', type: 'TEXT', label: - declaration.event === Event.Birth + declaration.event === EventType.Birth ? formMessages.informantsRelationWithChild : formMessages.informantsRelationWithDeceased, placeholder: { diff --git a/packages/client/src/forms/correction/verifyCorrector.ts b/packages/client/src/forms/correction/verifyCorrector.ts index a3a3cd05d27..82f52053809 100644 --- a/packages/client/src/forms/correction/verifyCorrector.ts +++ b/packages/client/src/forms/correction/verifyCorrector.ts @@ -1,5 +1,5 @@ import { ICertificateCorrectorDefinition } from '@client/views/CorrectionForm/VerifyCorrector' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' /* * This Source Code Form is subject to the terms of the Mozilla Public @@ -86,5 +86,5 @@ const verifyDeathCorrector: ICertificateCorrectorDefinition = { } } -export const getVerifyCorrectorDefinition = (event: Event) => - event === Event.Birth ? verifyBirthCorrector : verifyDeathCorrector +export const getVerifyCorrectorDefinition = (event: EventType) => + event === EventType.Birth ? verifyBirthCorrector : verifyDeathCorrector diff --git a/packages/client/src/forms/register/declaration-selectors.ts b/packages/client/src/forms/register/declaration-selectors.ts index 151c0d8cff5..43a29fcb77a 100644 --- a/packages/client/src/forms/register/declaration-selectors.ts +++ b/packages/client/src/forms/register/declaration-selectors.ts @@ -11,7 +11,7 @@ import { IRegisterFormState } from '@client/forms/register/reducer' import { IStoreState } from '@opencrvs/client/src/store' import { Section, IFormSection } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' const getPartialState = (state: IStoreState): IRegisterFormState => state.registerForm @@ -39,14 +39,14 @@ export const isRegisterFormReady = (state: IStoreState) => { return Boolean(form) } -export const getEventRegisterForm = (state: IStoreState, event: Event) => { +export const getEventRegisterForm = (state: IStoreState, event: EventType) => { return getRegisterForm(state)[event] } const getRegisterFormSection = ( state: IStoreState, key: Section | string, - event: Event + event: EventType ): IFormSection => { const eventRegisterForm = getEventRegisterForm(state, event) @@ -67,12 +67,12 @@ export const getBirthSection = ( state: IStoreState, section: Section | string ) => { - return getRegisterFormSection(state, section, Event.Birth) + return getRegisterFormSection(state, section, EventType.Birth) } export const getDeathSection = ( state: IStoreState, section: Section | string ) => { - return getRegisterFormSection(state, section, Event.Death) + return getRegisterFormSection(state, section, EventType.Death) } diff --git a/packages/client/src/forms/register/mappings/event-specific-fields/birth/query/registration-mappings.ts b/packages/client/src/forms/register/mappings/event-specific-fields/birth/query/registration-mappings.ts index 31f290ae004..b4b14187824 100644 --- a/packages/client/src/forms/register/mappings/event-specific-fields/birth/query/registration-mappings.ts +++ b/packages/client/src/forms/register/mappings/event-specific-fields/birth/query/registration-mappings.ts @@ -9,8 +9,8 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { IFormData } from '@client/forms' -import { Event } from '@client/utils/gateway' import { transformStatusData } from '@client/forms/register/mappings/query/utils' +import { EventType } from '@client/utils/gateway' export function getBirthRegistrationSectionTransformer( transformedData: IFormData, @@ -27,7 +27,7 @@ export function getBirthRegistrationSectionTransformer( } if (queryData[sectionId].type && queryData[sectionId].type === 'BIRTH') { - transformedData[sectionId].type = Event.Birth + transformedData[sectionId].type = EventType.Birth } if (queryData[sectionId].status) { diff --git a/packages/client/src/forms/register/mappings/event-specific-fields/death/query/registration-mappings.ts b/packages/client/src/forms/register/mappings/event-specific-fields/death/query/registration-mappings.ts index acd0fb058fd..8985caaf19c 100644 --- a/packages/client/src/forms/register/mappings/event-specific-fields/death/query/registration-mappings.ts +++ b/packages/client/src/forms/register/mappings/event-specific-fields/death/query/registration-mappings.ts @@ -9,9 +9,9 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { IFormData } from '@client/forms' -import { Event } from '@client/utils/gateway' -import type { GQLRegWorkflow } from '@client/utils/gateway-deprecated-do-not-use' import { transformStatusData } from '@client/forms/register/mappings/query/utils' +import { EventType } from '@client/utils/gateway' +import type { GQLRegWorkflow } from '@client/utils/gateway-deprecated-do-not-use' export function getDeathRegistrationSectionTransformer( transformedData: IFormData, @@ -39,7 +39,7 @@ export function getDeathRegistrationSectionTransformer( queryData['registration'].type && queryData['registration'].type === 'DEATH' ) { - transformedData['registration'].type = Event.Death + transformedData['registration'].type = EventType.Death } if (queryData['registration'].status) { diff --git a/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/registration-mappings.ts b/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/registration-mappings.ts index 0995b1b5a61..b729f08150f 100644 --- a/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/registration-mappings.ts +++ b/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/registration-mappings.ts @@ -10,7 +10,7 @@ */ import { IFormData } from '@client/forms' import { transformStatusData } from '@client/forms/register/mappings/query/utils' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import type { GQLRegWorkflow } from '@client/utils/gateway-deprecated-do-not-use' export function getMarriageRegistrationSectionTransformer( @@ -32,7 +32,7 @@ export function getMarriageRegistrationSectionTransformer( } if (queryData[sectionId].type && queryData[sectionId].type === 'MARRIAGE') { - transformedData[sectionId].type = Event.Marriage + transformedData[sectionId].type = EventType.Marriage } if (queryData[sectionId].status) { diff --git a/packages/client/src/forms/register/review-selectors.ts b/packages/client/src/forms/register/review-selectors.ts index 5a4382c5e78..6c694eaaf79 100644 --- a/packages/client/src/forms/register/review-selectors.ts +++ b/packages/client/src/forms/register/review-selectors.ts @@ -10,7 +10,7 @@ */ import { IReviewFormState } from '@client/forms/register/reviewReducer' import { IStoreState } from '@client/store' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' const getPartialState = (store: IStoreState): IReviewFormState => store.reviewForm @@ -30,6 +30,6 @@ export const getReviewForm = (store: IStoreState) => { return form } -export const getEventReviewForm = (store: IStoreState, event: Event) => { +export const getEventReviewForm = (store: IStoreState, event: EventType) => { return getReviewForm(store)[event] } diff --git a/packages/client/src/navigation/index.ts b/packages/client/src/navigation/index.ts index 4dc272f1a92..39940b73094 100644 --- a/packages/client/src/navigation/index.ts +++ b/packages/client/src/navigation/index.ts @@ -9,21 +9,37 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { UserSection, CorrectionSection } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { IWORKQUEUE_TABS } from '@client/components/interface/Navigation' +import { CorrectionSection, UserSection } from '@client/forms' import { + ADVANCED_SEARCH, + ADVANCED_SEARCH_RESULT, + ALL_USER_EMAIL, CERTIFICATE_COLLECTOR, + CERTIFICATE_CORRECTION, CREATE_USER, CREATE_USER_ON_LOCATION, CREATE_USER_SECTION, + DECLARATION_RECORD_AUDIT, + DRAFT_BIRTH_PARENT_FORM, DRAFT_DEATH_FORM, + DRAFT_MARRIAGE_FORM, EVENT_COMPLETENESS_RATES, HOME, + ISSUE_CERTIFICATE_PAYMENT, + ISSUE_COLLECTOR, + ISSUE_VERIFY_COLLECTOR, + ORGANISATIONS_INDEX, + PERFORMANCE_DASHBOARD, PERFORMANCE_FIELD_AGENT_LIST, PERFORMANCE_HOME, - ADVANCED_SEARCH, + PERFORMANCE_LEADER_BOARDS, + PERFORMANCE_REGISTRATIONS_LIST, + PERFORMANCE_STATISTICS, PRINT_CERTIFICATE_PAYMENT, + PRINT_RECORD, REGISTRAR_HOME_TAB, + REGISTRAR_HOME_TAB_PAGE, REVIEW_CERTIFICATE, REVIEW_USER_DETAILS, REVIEW_USER_FORM, @@ -31,55 +47,39 @@ import { SEARCH_RESULT, SELECT_VITAL_EVENT, SETTINGS, + SYSTEM_LIST, TEAM_SEARCH, - VERIFY_COLLECTOR, - WORKFLOW_STATUS, TEAM_USER_LIST, USER_PROFILE, - CERTIFICATE_CORRECTION, + VERIFY_COLLECTOR, VERIFY_CORRECTOR, - DECLARATION_RECORD_AUDIT, - REGISTRAR_HOME_TAB_PAGE, - SYSTEM_LIST, - VS_EXPORTS, VIEW_RECORD, - ADVANCED_SEARCH_RESULT, - PERFORMANCE_REGISTRATIONS_LIST, - PERFORMANCE_LEADER_BOARDS, - PERFORMANCE_STATISTICS, - PERFORMANCE_DASHBOARD, - ORGANISATIONS_INDEX, - ISSUE_COLLECTOR, - ISSUE_VERIFY_COLLECTOR, - ISSUE_CERTIFICATE_PAYMENT, - DRAFT_BIRTH_PARENT_FORM, - DRAFT_MARRIAGE_FORM, - ALL_USER_EMAIL, - PRINT_RECORD + VS_EXPORTS, + WORKFLOW_STATUS } from '@client/navigation/routes' import { - NATL_ADMIN_ROLES, NATIONAL_REGISTRAR_ROLES, + NATL_ADMIN_ROLES, PERFORMANCE_MANAGEMENT_ROLES, REGISTRAR_ROLES, SYS_ADMIN_ROLES } from '@client/utils/constants' +import { EventType } from '@client/utils/gateway' +import { UserDetails } from '@client/utils/userUtils' +import { IRecordAuditTabs } from '@client/views/RecordAudit/RecordAudit' import { IStatusMapping } from '@client/views/SysAdmin/Performance/reports/operational/StatusWiseDeclarationCountView' import { CompletenessRateTime } from '@client/views/SysAdmin/Performance/utils' import { ISearchLocation } from '@opencrvs/components/lib/LocationSearch' import { goBack as back, + goForward as forward, push, - replace, - goForward as forward + replace } from 'connected-react-router' -import { stringify } from 'query-string' -import { Cmd, loop } from 'redux-loop' -import { IRecordAuditTabs } from '@client/views/RecordAudit/RecordAudit' -import { IWORKQUEUE_TABS } from '@client/components/interface/Navigation' import startOfMonth from 'date-fns/startOfMonth' import subMonths from 'date-fns/subMonths' -import { UserDetails } from '@client/utils/userUtils' +import { stringify } from 'query-string' +import { Cmd, loop } from 'redux-loop' export interface IDynamicValues { [key: string]: any @@ -215,7 +215,7 @@ export function goToPerformanceHome( startOfMonth(subMonths(new Date(Date.now()), 11)).setHours(0, 0, 0, 0) ), timeEnd: Date = new Date(new Date(Date.now()).setHours(23, 59, 59, 999)), - event?: Event, + event?: EventType, locationId?: string ) { return push({ @@ -360,7 +360,10 @@ export function goToVerifyCorrector(declarationId: string, corrector: string) { ) } -export function goToReviewCertificate(registrationId: string, event: Event) { +export function goToReviewCertificate( + registrationId: string, + event: EventType +) { return push( formatUrl(REVIEW_CERTIFICATE, { registrationId: registrationId.toString(), @@ -386,7 +389,7 @@ export function goToVerifyCollector( export function goToPrintCertificatePayment( registrationId: string, - event: Event + event: EventType ) { return push( formatUrl(PRINT_CERTIFICATE_PAYMENT, { @@ -398,7 +401,7 @@ export function goToPrintCertificatePayment( export function goToIssueCertificatePayment( registrationId: string, - event: Event + event: EventType ) { return push( formatUrl(ISSUE_CERTIFICATE_PAYMENT, { @@ -421,7 +424,7 @@ export function goToCreateNewUserWithLocationId(locationId: string) { } export function goToCompletenessRates( - eventType: Event, + eventType: EventType, locationId: string | undefined, timeStart: Date, timeEnd: Date, @@ -489,7 +492,7 @@ export function goToWorkflowStatus( timeStart: Date, timeEnd: Date, status?: keyof IStatusMapping, - event?: Event + event?: EventType ) { return push({ pathname: WORKFLOW_STATUS, diff --git a/packages/client/src/navigation/routes.ts b/packages/client/src/navigation/routes.ts index 35395667abe..de16c90b131 100644 --- a/packages/client/src/navigation/routes.ts +++ b/packages/client/src/navigation/routes.ts @@ -8,22 +8,22 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' export const HOME = '/' export const SELECT_VITAL_EVENT = '/events' -export const DRAFT_BIRTH_PARENT_FORM = `/drafts/:declarationId/events/${Event.Birth}` -export const DRAFT_BIRTH_PARENT_FORM_PAGE = `/drafts/:declarationId/events/${Event.Birth}/:pageId` -export const DRAFT_BIRTH_PARENT_FORM_PAGE_GROUP = `/drafts/:declarationId/events/${Event.Birth}/:pageId/group/:groupId` -export const SELECT_DEATH_INFORMANT = `/drafts/:declarationId/events/${Event.Death}/registration/informantType` -export const DRAFT_DEATH_FORM = `/drafts/:declarationId/events/${Event.Death}` -export const DRAFT_DEATH_FORM_PAGE = `/drafts/:declarationId/events/${Event.Death}/:pageId` -export const DRAFT_DEATH_FORM_PAGE_GROUP = `/drafts/:declarationId/events/${Event.Death}/:pageId/group/:groupId` -export const SELECT_MARRIAGE_INFORMANT = `/drafts/:declarationId/events/${Event.Marriage}/registration/informantType` -export const DRAFT_MARRIAGE_FORM = `/drafts/:declarationId/events/${Event.Marriage}` -export const DRAFT_MARRIAGE_FORM_PAGE = `/drafts/:declarationId/events/${Event.Marriage}/:pageId` -export const DRAFT_MARRIAGE_FORM_PAGE_GROUP = `/drafts/:declarationId/events/${Event.Marriage}/:pageId/group/:groupId` +export const DRAFT_BIRTH_PARENT_FORM = `/drafts/:declarationId/events/${EventType.Birth}` +export const DRAFT_BIRTH_PARENT_FORM_PAGE = `/drafts/:declarationId/events/${EventType.Birth}/:pageId` +export const DRAFT_BIRTH_PARENT_FORM_PAGE_GROUP = `/drafts/:declarationId/events/${EventType.Birth}/:pageId/group/:groupId` +export const SELECT_DEATH_INFORMANT = `/drafts/:declarationId/events/${EventType.Death}/registration/informantType` +export const DRAFT_DEATH_FORM = `/drafts/:declarationId/events/${EventType.Death}` +export const DRAFT_DEATH_FORM_PAGE = `/drafts/:declarationId/events/${EventType.Death}/:pageId` +export const DRAFT_DEATH_FORM_PAGE_GROUP = `/drafts/:declarationId/events/${EventType.Death}/:pageId/group/:groupId` +export const SELECT_MARRIAGE_INFORMANT = `/drafts/:declarationId/events/${EventType.Marriage}/registration/informantType` +export const DRAFT_MARRIAGE_FORM = `/drafts/:declarationId/events/${EventType.Marriage}` +export const DRAFT_MARRIAGE_FORM_PAGE = `/drafts/:declarationId/events/${EventType.Marriage}/:pageId` +export const DRAFT_MARRIAGE_FORM_PAGE_GROUP = `/drafts/:declarationId/events/${EventType.Marriage}/:pageId/group/:groupId` export const REVIEW_EVENT_PARENT_FORM_PAGE = '/reviews/:declarationId/events/:event/parent/:pageId' diff --git a/packages/client/src/offline/actions.ts b/packages/client/src/offline/actions.ts index 14b5e8b9e0b..6dec4c81459 100644 --- a/packages/client/src/offline/actions.ts +++ b/packages/client/src/offline/actions.ts @@ -8,6 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import { ILanguageState } from '@client/i18n/reducer' import { AdminStructure, CRVSOffice, @@ -15,21 +16,20 @@ import { ILocation, IOfflineData } from '@client/offline/reducer' -import { ILanguageState } from '@client/i18n/reducer' +import { System } from '@client/utils/gateway' import { - ILocationDataResponse, - IFacilitiesDataResponse, - IContentResponse, - IApplicationConfigResponse, + CertificateConfiguration, IApplicationConfig, IApplicationConfigAnonymous, - LoadFormsResponse, - LoadValidatorsResponse, + IApplicationConfigResponse, + IContentResponse, + IFacilitiesDataResponse, + ILocationDataResponse, LoadConditionalsResponse, + LoadFormsResponse, LoadHandlebarHelpersResponse, - CertificateConfiguration + LoadValidatorsResponse } from '@client/utils/referenceApi' -import { System } from '@client/utils/gateway' import { UserDetails } from '@client/utils/userUtils' const GET_LOCATIONS = 'OFFLINE/GET_LOCATIONS' diff --git a/packages/client/src/offline/reducer.ts b/packages/client/src/offline/reducer.ts index af5d8ca3ccc..e9897ce4708 100644 --- a/packages/client/src/offline/reducer.ts +++ b/packages/client/src/offline/reducer.ts @@ -8,43 +8,43 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import { ISerializedForm } from '@client/forms' +import { initConditionals } from '@client/forms/conditionals' +import { initHandlebarHelpers } from '@client/forms/handlebarHelpers' +import { initValidators } from '@client/forms/validators' +import { ILanguage } from '@client/i18n/reducer' import { - loop, - Cmd, - Loop, - liftState, - getModel, - getCmd, - RunCmd -} from 'redux-loop' + Action as NotificationAction, + configurationErrorNotification +} from '@client/notification/actions' import * as actions from '@client/offline/actions' +import { ISVGTemplate } from '@client/pdfRenderer' import * as profileActions from '@client/profile/profileActions' import { storage } from '@client/storage' +import { isNavigatorOnline } from '@client/utils' +import { EventType, System } from '@client/utils/gateway' +import { filterLocations } from '@client/utils/locationUtils' import { + CertificateConfiguration, IApplicationConfig, IApplicationConfigAnonymous, - ILocationDataResponse, - referenceApi, - CertificateConfiguration, IFacilitiesDataResponse, - IOfficesDataResponse + ILocationDataResponse, + IOfficesDataResponse, + referenceApi } from '@client/utils/referenceApi' -import { ILanguage } from '@client/i18n/reducer' -import { filterLocations } from '@client/utils/locationUtils' -import { Event, System } from '@client/utils/gateway' import { UserDetails } from '@client/utils/userUtils' -import { isOfflineDataLoaded } from './selectors' -import { ISVGTemplate } from '@client/pdfRenderer' import { merge } from 'lodash' -import { isNavigatorOnline } from '@client/utils' -import { ISerializedForm } from '@client/forms' -import { initConditionals } from '@client/forms/conditionals' -import { initValidators } from '@client/forms/validators' import { - Action as NotificationAction, - configurationErrorNotification -} from '@client/notification/actions' -import { initHandlebarHelpers } from '@client/forms/handlebarHelpers' + Cmd, + Loop, + RunCmd, + getCmd, + getModel, + liftState, + loop +} from 'redux-loop' +import { isOfflineDataLoaded } from './selectors' export const OFFLINE_LOCATIONS_KEY = 'locations' export const OFFLINE_FACILITIES_KEY = 'facilities' @@ -369,15 +369,15 @@ function reducer( const { certificates, config, systems } = action.payload merge(window.config, config) const birthCertificateTemplate = certificates.find( - ({ event }) => event === Event.Birth + ({ event }) => event === EventType.Birth ) const deathCertificateTemplate = certificates.find( - ({ event }) => event === Event.Death + ({ event }) => event === EventType.Death ) const marriageCertificateTemplate = certificates.find( - ({ event }) => event === Event.Marriage + ({ event }) => event === EventType.Marriage ) let newOfflineData: Partial diff --git a/packages/client/src/search/transformer.ts b/packages/client/src/search/transformer.ts index 59b8c55f93f..70c7b21813f 100644 --- a/packages/client/src/search/transformer.ts +++ b/packages/client/src/search/transformer.ts @@ -8,6 +8,16 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import { ITaskHistory } from '@client/declarations' +import { EMPTY_STRING, LANG_EN } from '@client/utils/constants' +import { createNamesMap } from '@client/utils/data-formatting' +import { formatLongDate } from '@client/utils/date-formatting' +import { + EventSearchSet, + EventType, + HumanName, + SearchEventsQuery +} from '@client/utils/gateway' import type { GQLBirthEventSearchSet, GQLDeathEventSearchSet, @@ -16,33 +26,23 @@ import type { GQLRegStatus } from '@client/utils/gateway-deprecated-do-not-use' import { IntlShape } from 'react-intl' -import { createNamesMap } from '@client/utils/data-formatting' -import { formatLongDate } from '@client/utils/date-formatting' -import { - HumanName, - EventSearchSet, - SearchEventsQuery, - Event -} from '@client/utils/gateway' -import { EMPTY_STRING, LANG_EN } from '@client/utils/constants' -import { ITaskHistory } from '@client/declarations' export const isBirthEvent = ( req: EventSearchSet ): req is GQLBirthEventSearchSet => { - return req.type === Event.Birth + return req.type === EventType.Birth } export const isDeathEvent = ( req: EventSearchSet ): req is GQLDeathEventSearchSet => { - return req.type === Event.Death + return req.type === EventType.Death } export const isMarriageEvent = ( reg: EventSearchSet ): reg is GQLMarriageEventSearchSet => { - return reg.type === Event.Marriage + return reg.type === EventType.Marriage } export const transformData = ( @@ -105,7 +105,7 @@ export const transformData = ( return { id: assignedReg.id, name: - assignedReg.type === Event.Marriage + assignedReg.type === EventType.Marriage ? mergedMarriageName : (createNamesMap(names as HumanName[])[locale] as string) || (createNamesMap(names as HumanName[])[LANG_EN] as string) || diff --git a/packages/client/src/tests/util.tsx b/packages/client/src/tests/util.tsx index ef2df7cb08f..5c26f38330c 100644 --- a/packages/client/src/tests/util.tsx +++ b/packages/client/src/tests/util.tsx @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { App } from '@client/App' -import { Event, SystemRoleType, Status } from '@client/utils/gateway' +import { EventType, SystemRoleType, Status } from '@client/utils/gateway' import { UserDetails } from '@client/utils/userUtils' import { getRegisterForm } from '@client/forms/register/declaration-selectors' import { getReviewForm } from '@client/forms/register/review-selectors' @@ -803,7 +803,7 @@ export const mockDeathRegistrationSectionData = { const mockFetchCertificatesTemplatesDefinition = [ { id: '12313546', - event: Event.Birth, + event: EventType.Birth, status: 'ACTIVE', svgCode: '\n\n\n\n{registrarName}
({role}) \n \n \nThis event was registered at {registrationLocation} \n{eventDate} \nDied on \nPlace of death \n \n{placeOfDeath} \n{informantName} \nThis is to certify that \n{registrationNumber} \nDeath Registration No \nDate of issuance of certificate: {certificateDate}\n\n\n\n\n\n\n\n\n\n\n', @@ -814,7 +814,7 @@ const mockFetchCertificatesTemplatesDefinition = [ }, { id: '25313546', - event: Event.Death, + event: EventType.Death, status: 'ACTIVE', svgCode: '\n\n\n\n{registrarName}
({role}) \n \n \nThis event was registered at {registrationLocation} \n{eventDate} \nWas born on \nPlace of birth \n \n{placeOfBirth} \n{informantName} \nThis is to certify that \n{registrationNumber} \nBirth Registration No \nDate of issuance of certificate: {certificateDate}\n\n\n\n\n\n\n\n\n\n\n', @@ -963,7 +963,7 @@ export async function goToMotherSection(component: ReactWrapper) { export async function getRegisterFormFromStore( store: Store, - event: Event + event: EventType ) { await store.dispatch(setOfflineData(userDetails)) const state = store.getState() @@ -972,7 +972,7 @@ export async function getRegisterFormFromStore( export async function getReviewFormFromStore( store: Store, - event: Event + event: EventType ) { await store.dispatch(setOfflineData(userDetails)) const state = store.getState() diff --git a/packages/client/src/transformer/transformer.test.tsx b/packages/client/src/transformer/transformer.test.tsx index 2f060d7563c..6d293c251df 100644 --- a/packages/client/src/transformer/transformer.test.tsx +++ b/packages/client/src/transformer/transformer.test.tsx @@ -31,7 +31,7 @@ import { draftToGqlTransformer } from '@client/transformer' import { getRegisterForm } from '@opencrvs/client/src/forms/register/declaration-selectors' import { getOfflineDataSuccess } from '@client/offline/actions' import { IForm } from '@opencrvs/client/src/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { clone } from 'lodash' import { birthDraftData } from '@client/tests/mock-drafts' import createFetchMock from 'vitest-fetch-mock' @@ -66,11 +66,11 @@ describe('when draft data is transformed to graphql', () => { customDraft = { id: uuid(), data: birthDraftData, - event: Event.Birth, + event: EventType.Birth, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] } store.dispatch(storeDeclaration(customDraft)) - form = getRegisterForm(store.getState())[Event.Birth] + form = getRegisterForm(store.getState())[EventType.Birth] history.replace( DRAFT_BIRTH_PARENT_FORM.replace( ':declarationId', diff --git a/packages/client/src/user/queries.ts b/packages/client/src/user/queries.ts index e91e4c42438..ac4227a3e43 100644 --- a/packages/client/src/user/queries.ts +++ b/packages/client/src/user/queries.ts @@ -81,7 +81,7 @@ export const GET_USER_AUDIT_LOG = gql` ` export const GET_USER = gql` - query getUser($userId: String) { + query getUser($userId: String!) { getUser(userId: $userId) { id name { diff --git a/packages/client/src/utils/constants.ts b/packages/client/src/utils/constants.ts index f6bcaff1375..a982a362e35 100644 --- a/packages/client/src/utils/constants.ts +++ b/packages/client/src/utils/constants.ts @@ -62,10 +62,7 @@ export const SIGNATURE_KEYS = [ 'informantsSignature' ] as const -export const PAGE_TRANSITIONS_CLASSNAME = 'page-transition' -export const PAGE_TRANSITIONS_ENTER_TIME = 500 -export const PAGE_TRANSITIONS_EXIT_TIME = PAGE_TRANSITIONS_ENTER_TIME - 10 - +export const SYNC_WORKQUEUE_TIME = 500 export const REFRESH_TOKEN_CHECK_MILLIS = 4 * 60 * 1000 // 4 minutes export const TOKEN_EXPIRE_MILLIS = 10 * 60 * 1000 // 10 minutes diff --git a/packages/client/src/utils/draftUtils.test.ts b/packages/client/src/utils/draftUtils.test.ts index b7be4734d51..d924be70e3c 100644 --- a/packages/client/src/utils/draftUtils.test.ts +++ b/packages/client/src/utils/draftUtils.test.ts @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { getDeclarationFullName, transformSearchQueryDataToDraft @@ -33,7 +33,7 @@ describe('draftUtils tests', () => { familyNameEng: 'Hoque' } }, - event: Event.Birth, + event: EventType.Birth, savedOn: 1558037863335, modifiedOn: 1558037867987 }) @@ -51,7 +51,7 @@ describe('draftUtils tests', () => { familyNameEng: 'Hoque' } }, - event: Event.Birth, + event: EventType.Birth, savedOn: 1558037863335, modifiedOn: 1558037867987 }, @@ -72,7 +72,7 @@ describe('draftUtils tests', () => { familyNameEng: 'Hoque' } }, - event: Event.Death, + event: EventType.Death, savedOn: 1558037863335, modifiedOn: 1558037867987 }) @@ -91,7 +91,7 @@ describe('draftUtils tests', () => { familyNameEng: 'Hoque' } }, - event: Event.Death, + event: EventType.Death, savedOn: 1558037863335, modifiedOn: 1558037867987 }, diff --git a/packages/client/src/utils/draftUtils.ts b/packages/client/src/utils/draftUtils.ts index 47dfe4dbe57..3b5a701dee0 100644 --- a/packages/client/src/utils/draftUtils.ts +++ b/packages/client/src/utils/draftUtils.ts @@ -10,11 +10,12 @@ */ import { IDeclaration, - SUBMISSION_STATUS, - IPrintableDeclaration + IPrintableDeclaration, + SUBMISSION_STATUS } from '@client/declarations' import { IFormSectionData } from '@client/forms' -import { Event, History, RegStatus } from '@client/utils/gateway' +import { EMPTY_STRING } from '@client/utils/constants' +import { EventType, History, RegStatus } from '@client/utils/gateway' import type { GQLBirthEventSearchSet, GQLDeathEventSearchSet, @@ -23,7 +24,6 @@ import type { } from '@client/utils/gateway-deprecated-do-not-use' import { getEvent } from '@client/views/PrintCertificate/utils' import { includes } from 'lodash' -import { EMPTY_STRING } from '@client/utils/constants' const getEngName = ( sectionData: IFormSectionData, @@ -78,11 +78,11 @@ export const getDeclarationFullName = ( lastNameFirst?: boolean ) => { switch (draft.event) { - case Event.Birth: + case EventType.Birth: return getFullName(draft.data.child, language, lastNameFirst) - case Event.Death: + case EventType.Death: return getFullName(draft.data.deceased, language, lastNameFirst) - case Event.Marriage: + case EventType.Marriage: const brideName = getFullName(draft.data.bride, language, lastNameFirst) const groomName = getFullName(draft.data.groom, language, lastNameFirst) if (brideName && groomName) { @@ -262,14 +262,14 @@ export const transformSearchQueryDataToDraft = ( data.registration?.createdAt && data.registration.createdAt switch (eventType) { - case Event.Birth: + case EventType.Birth: default: transformBirthSearchQueryDataToDraft(data, declaration) break - case Event.Death: + case EventType.Death: transformDeathSearchQueryDataToDraft(data, declaration) break - case Event.Marriage: + case EventType.Marriage: transformMarriageSearchQueryDataToDraft(data, declaration) break } diff --git a/packages/client/src/utils/gateway.ts b/packages/client/src/utils/gateway.ts index 2381b895e76..67c67822aa9 100644 --- a/packages/client/src/utils/gateway.ts +++ b/packages/client/src/utils/gateway.ts @@ -35,11 +35,18 @@ export type Scalars = { Int: number Float: number Date: any + DateTime: any FieldValue: any Map: any PlainDate: PlainDate } +export type Action = + | CreateAction + | DeclareAction + | NotifyAction + | RegisterAction + export type AdditionalIdWithCompositionId = { __typename?: 'AdditionalIdWithCompositionId' compositionId: Scalars['String'] @@ -122,7 +129,7 @@ export type AdvancedSeachParameters = { deceasedIdentifier?: Maybe declarationJurisdictionId?: Maybe declarationLocationId?: Maybe - event?: Maybe + event?: Maybe eventCountry?: Maybe eventLocationId?: Maybe eventLocationLevel1?: Maybe @@ -189,7 +196,7 @@ export type AdvancedSearchParametersInput = { deceasedIdentifier?: InputMaybe declarationJurisdictionId?: InputMaybe declarationLocationId?: InputMaybe - event?: InputMaybe + event?: InputMaybe eventCountry?: InputMaybe eventLocationId?: InputMaybe eventLocationLevel1?: InputMaybe @@ -230,6 +237,10 @@ export type AdvancedSearchParametersInput = { trackingId?: InputMaybe } +export type ApproveCorrectionActionInput = { + fields: Array +} + export type AssignmentData = { __typename?: 'AssignmentData' avatarURL: Scalars['String'] @@ -403,6 +414,10 @@ export type CertificationMetric = { total: Scalars['Float'] } +export type CertifyActionInput = { + fields: Array +} + export type Comment = { __typename?: 'Comment' comment?: Maybe @@ -428,6 +443,12 @@ export type ComparisonInput = { nin?: InputMaybe> } +export type ConfirmRegistrationInput = { + error?: InputMaybe + identifiers?: InputMaybe> + registrationNumber: Scalars['String'] +} + export type ContactPoint = { __typename?: 'ContactPoint' system?: Maybe @@ -482,6 +503,14 @@ export type CorrectionValueInput = { section: Scalars['String'] } +export type CreateAction = { + __typename?: 'CreateAction' + createdAt: Scalars['DateTime'] + createdBy: Scalars['String'] + fields: Array + type: Scalars['String'] +} + export type CreatedIds = { __typename?: 'CreatedIds' compositionId?: Maybe @@ -565,6 +594,19 @@ export type DeclarationsStartedMetrics = { officeDeclarations: Scalars['Int'] } +export type DeclareAction = { + __typename?: 'DeclareAction' + createdAt: Scalars['DateTime'] + createdBy: Scalars['String'] + fields: Array + identifiers: Identifiers + type: Scalars['String'] +} + +export type DeclareActionInput = { + fields: Array +} + export type Dummy = { __typename?: 'Dummy' dummy: Scalars['String'] @@ -585,10 +627,17 @@ export type Estimation = { totalEstimation: Scalars['Float'] } -export enum Event { - Birth = 'birth', - Death = 'death', - Marriage = 'marriage' +export type Event = { + __typename?: 'Event' + actions: Array + createdAt: Scalars['DateTime'] + id: Scalars['String'] + type: Scalars['String'] + updatedAt: Scalars['DateTime'] +} + +export type EventInput = { + type: Scalars['String'] } export type EventMetrics = { @@ -678,6 +727,12 @@ export type EventSearchSet = { type?: Maybe } +export enum EventType { + Birth = 'birth', + Death = 'death', + Marriage = 'marriage' +} + export type FhiridMap = { composition?: InputMaybe encounter?: InputMaybe @@ -686,6 +741,17 @@ export type FhiridMap = { questionnaireResponse?: InputMaybe } +export type Field = { + __typename?: 'Field' + id: Scalars['String'] + value: Scalars['FieldValue'] +} + +export type FieldInput = { + id: Scalars['String'] + value: Scalars['FieldValue'] +} + export enum Gender { Female = 'female', Male = 'male', @@ -746,6 +812,17 @@ export type Identifier = { value?: Maybe } +export type IdentifierInput = { + type: Scalars['String'] + value: Scalars['String'] +} + +export type Identifiers = { + __typename?: 'Identifiers' + registrationNumber: Scalars['String'] + trackingId: Scalars['String'] +} + export type IdentityInput = { fieldsModifiedByIdentity?: InputMaybe>> id?: InputMaybe @@ -780,6 +857,10 @@ export enum IntegratingSystemType { Other = 'OTHER' } +export type IssueActionInput = { + fields: Array +} + export type LabelInput = { label: Scalars['String'] lang: Scalars['String'] @@ -926,10 +1007,12 @@ export type Mutation = { __typename?: 'Mutation' activateUser?: Maybe approveBirthRegistrationCorrection: Scalars['ID'] + approveCorrectionEvent: Event approveDeathRegistrationCorrection: Scalars['ID'] approveMarriageRegistrationCorrection: Scalars['ID'] auditUser?: Maybe bookmarkAdvancedSearch?: Maybe + certifyEvent: Event changeAvatar?: Maybe changeEmail?: Maybe changePassword?: Maybe @@ -939,11 +1022,14 @@ export type Mutation = { createBirthRegistrationCorrection: Scalars['ID'] createDeathRegistration: CreatedIds createDeathRegistrationCorrection: Scalars['ID'] + createEvent: Event createMarriageRegistration: CreatedIds createMarriageRegistrationCorrection: Scalars['ID'] createOrUpdateUser: User deactivateSystem?: Maybe + declareEvent: Event deleteSystem?: Maybe + issueEvent: Event markBirthAsCertified: Scalars['ID'] markBirthAsIssued: Scalars['ID'] markBirthAsRegistered: Scalars['ID'] @@ -964,14 +1050,22 @@ export type Mutation = { markMarriageAsIssued: Scalars['ID'] markMarriageAsRegistered: Scalars['ID'] markMarriageAsValidated?: Maybe + notifyEvent: Event reactivateSystem?: Maybe refreshSystemSecret?: Maybe + registerEvent: Event registerSystem?: Maybe + reinstateEvent: Event + rejectCorrectionEvent: Event + rejectRegistration: Scalars['ID'] rejectRegistrationCorrection: Scalars['ID'] removeBookmarkedAdvancedSearch?: Maybe + requestCorrectionEvent: Event requestRegistrationCorrection: Scalars['ID'] resendInvite?: Maybe resetPasswordInvite?: Maybe + revokeCorrectionEvent: Event + revokeEvent: Event updateDeathRegistration: Scalars['ID'] updatePermissions?: Maybe updateRole: Response @@ -989,6 +1083,11 @@ export type MutationApproveBirthRegistrationCorrectionArgs = { id: Scalars['ID'] } +export type MutationApproveCorrectionEventArgs = { + eventId: Scalars['ID'] + input: ApproveCorrectionActionInput +} + export type MutationApproveDeathRegistrationCorrectionArgs = { details: DeathRegistrationInput id: Scalars['ID'] @@ -1010,6 +1109,11 @@ export type MutationBookmarkAdvancedSearchArgs = { bookmarkSearchInput: BookmarkSearchInput } +export type MutationCertifyEventArgs = { + eventId: Scalars['ID'] + input: CertifyActionInput +} + export type MutationChangeAvatarArgs = { avatar: AvatarInput userId: Scalars['String'] @@ -1036,6 +1140,7 @@ export type MutationChangePhoneArgs = { } export type MutationConfirmRegistrationArgs = { + details: ConfirmRegistrationInput id: Scalars['ID'] } @@ -1057,6 +1162,10 @@ export type MutationCreateDeathRegistrationCorrectionArgs = { id: Scalars['ID'] } +export type MutationCreateEventArgs = { + event: EventInput +} + export type MutationCreateMarriageRegistrationArgs = { details: MarriageRegistrationInput } @@ -1074,10 +1183,20 @@ export type MutationDeactivateSystemArgs = { clientId: Scalars['ID'] } +export type MutationDeclareEventArgs = { + eventId: Scalars['ID'] + input: DeclareActionInput +} + export type MutationDeleteSystemArgs = { clientId: Scalars['ID'] } +export type MutationIssueEventArgs = { + eventId: Scalars['ID'] + input: IssueActionInput +} + export type MutationMarkBirthAsCertifiedArgs = { details: BirthRegistrationInput id: Scalars['ID'] @@ -1180,6 +1299,11 @@ export type MutationMarkMarriageAsValidatedArgs = { id: Scalars['ID'] } +export type MutationNotifyEventArgs = { + eventId: Scalars['ID'] + input: NotifyActionInput +} + export type MutationReactivateSystemArgs = { clientId: Scalars['ID'] } @@ -1188,10 +1312,30 @@ export type MutationRefreshSystemSecretArgs = { clientId: Scalars['String'] } +export type MutationRegisterEventArgs = { + eventId: Scalars['ID'] + input: RegisterActionInput +} + export type MutationRegisterSystemArgs = { system?: InputMaybe } +export type MutationReinstateEventArgs = { + eventId: Scalars['ID'] + input: ReinstateActionInput +} + +export type MutationRejectCorrectionEventArgs = { + eventId: Scalars['ID'] + input: RejectCorrectionActionInput +} + +export type MutationRejectRegistrationArgs = { + details: RejectRegistrationInput + id: Scalars['ID'] +} + export type MutationRejectRegistrationCorrectionArgs = { details: CorrectionRejectionInput id: Scalars['ID'] @@ -1201,6 +1345,11 @@ export type MutationRemoveBookmarkedAdvancedSearchArgs = { removeBookmarkedSearchInput: RemoveBookmarkedSeachInput } +export type MutationRequestCorrectionEventArgs = { + eventId: Scalars['ID'] + input: RequestCorrectionActionInput +} + export type MutationRequestRegistrationCorrectionArgs = { details: CorrectionInput id: Scalars['ID'] @@ -1214,6 +1363,16 @@ export type MutationResetPasswordInviteArgs = { userId: Scalars['String'] } +export type MutationRevokeCorrectionEventArgs = { + eventId: Scalars['ID'] + input: RevokeCorrectionActionInput +} + +export type MutationRevokeEventArgs = { + eventId: Scalars['ID'] + input: RevokeActionInput +} + export type MutationUpdateDeathRegistrationArgs = { details: DeathRegistrationInput id: Scalars['ID'] @@ -1241,6 +1400,18 @@ export enum NotificationType { Sms = 'SMS' } +export type NotifyAction = { + __typename?: 'NotifyAction' + createdAt: Scalars['DateTime'] + createdBy: Scalars['String'] + fields: Array + type: Scalars['String'] +} + +export type NotifyActionInput = { + fields: Array +} + export type ObservationFhirids = { attendantAtBirth?: InputMaybe birthType?: InputMaybe @@ -1368,6 +1539,7 @@ export type Query = { fetchRegistrationForViewing?: Maybe fetchSystem?: Maybe getDeclarationsStartedMetrics?: Maybe + getEvent: Event getEventsWithProgress?: Maybe getLocationStatistics?: Maybe getRegistrationsListByFilter?: Maybe @@ -1453,6 +1625,10 @@ export type QueryGetDeclarationsStartedMetricsArgs = { timeStart: Scalars['String'] } +export type QueryGetEventArgs = { + eventId: Scalars['ID'] +} + export type QueryGetEventsWithProgressArgs = { compositionType?: InputMaybe>> count?: InputMaybe @@ -1514,7 +1690,7 @@ export type QueryGetTotalPaymentsArgs = { } export type QueryGetUserArgs = { - userId?: InputMaybe + userId: Scalars['String'] } export type QueryGetUserAuditLogArgs = { @@ -1526,11 +1702,11 @@ export type QueryGetUserAuditLogArgs = { } export type QueryGetUserByEmailArgs = { - email?: InputMaybe + email: Scalars['String'] } export type QueryGetUserByMobileArgs = { - mobile?: InputMaybe + mobile: Scalars['String'] } export type QueryIsLeafLevelLocationArgs = { @@ -1685,6 +1861,19 @@ export type RegWorkflowInput = { user?: InputMaybe } +export type RegisterAction = { + __typename?: 'RegisterAction' + createdAt: Scalars['DateTime'] + createdBy: Scalars['String'] + fields: Array + identifiers: Identifiers + type: Scalars['String'] +} + +export type RegisterActionInput = { + fields: Array +} + export type Registration = { __typename?: 'Registration' _fhirID?: Maybe @@ -1773,12 +1962,25 @@ export enum RegistrationType { Marriage = 'MARRIAGE' } +export type ReinstateActionInput = { + fields: Array +} + export type Reinstated = { __typename?: 'Reinstated' registrationStatus?: Maybe taskEntryResourceID: Scalars['ID'] } +export type RejectCorrectionActionInput = { + fields: Array +} + +export type RejectRegistrationInput = { + comment?: InputMaybe + reason: Scalars['String'] +} + export type RelatedPerson = { __typename?: 'RelatedPerson' _fhirID?: Maybe @@ -1841,11 +2043,23 @@ export type RemoveBookmarkedSeachInput = { userId: Scalars['String'] } +export type RequestCorrectionActionInput = { + fields: Array +} + export type Response = { __typename?: 'Response' roleIdMap: Scalars['Map'] } +export type RevokeActionInput = { + fields: Array +} + +export type RevokeCorrectionActionInput = { + fields: Array +} + export type Role = { __typename?: 'Role' _id: Scalars['ID'] @@ -2324,7 +2538,7 @@ export type GetSystemRolesQuery = { export type AdvancedSeachParametersFragment = { __typename?: 'AdvancedSeachParameters' - event?: Event | null + event?: EventType | null name?: string | null registrationStatuses?: Array | null dateOfEvent?: string | null @@ -2395,7 +2609,7 @@ export type BookmarkAdvancedSearchMutation = { name: string parameters: { __typename?: 'AdvancedSeachParameters' - event?: Event | null + event?: EventType | null name?: string | null registrationStatuses?: Array | null dateOfEvent?: string | null @@ -2469,7 +2683,7 @@ export type RemoveBookmarkedAdvancedSearchMutation = { name: string parameters: { __typename?: 'AdvancedSeachParameters' - event?: Event | null + event?: EventType | null name?: string | null registrationStatuses?: Array | null dateOfEvent?: string | null @@ -2586,7 +2800,7 @@ export type FetchUserQuery = { name: string parameters: { __typename?: 'AdvancedSeachParameters' - event?: Event | null + event?: EventType | null name?: string | null registrationStatuses?: Array | null dateOfEvent?: string | null @@ -2885,7 +3099,7 @@ export type GetUserAuditLogQuery = { } export type GetUserQueryVariables = Exact<{ - userId?: InputMaybe + userId: Scalars['String'] }> export type GetUserQuery = { @@ -6937,7 +7151,7 @@ export type ChangeEmailMutation = { } export type GetUserByMobileQueryVariables = Exact<{ - mobile?: InputMaybe + mobile: Scalars['String'] }> export type GetUserByMobileQuery = { @@ -6955,7 +7169,7 @@ export type GetUserByMobileQuery = { } export type GetUserByEmailQueryVariables = Exact<{ - email?: InputMaybe + email: Scalars['String'] }> export type GetUserByEmailQuery = { diff --git a/packages/client/src/utils/referenceApi.ts b/packages/client/src/utils/referenceApi.ts index 341257463b4..b2343d90c80 100644 --- a/packages/client/src/utils/referenceApi.ts +++ b/packages/client/src/utils/referenceApi.ts @@ -10,6 +10,7 @@ */ import { ISerializedForm } from '@client/forms' import { Conditional } from '@client/forms/conditionals' +import { Validator } from '@client/forms/validators' import { ILanguage } from '@client/i18n/reducer' import { AdminStructure, @@ -18,8 +19,7 @@ import { ILocation } from '@client/offline/reducer' import { getToken } from '@client/utils/authUtils' -import { Event, System } from '@client/utils/gateway' -import { Validator } from '@client/forms/validators' +import { EventType, System } from '@client/utils/gateway' import { IntlShape } from 'react-intl' export interface ILocationDataResponse { @@ -78,7 +78,7 @@ interface ILoginBackground { imageFit?: string } export interface ICertificateTemplateData { - event: Event + event: EventType svgCode: string } export interface ICurrency { diff --git a/packages/client/src/v2-events/features/events/PublishEvent.tsx b/packages/client/src/v2-events/features/events/PublishEvent.tsx new file mode 100644 index 00000000000..c84eddccc1e --- /dev/null +++ b/packages/client/src/v2-events/features/events/PublishEvent.tsx @@ -0,0 +1,82 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { + Frame, + AppBar, + Stack, + Button, + Icon, + Content +} from '@opencrvs/components' +import React from 'react' +import { useEvent } from './useEvent' +import { useParams } from 'react-router-dom' + +export function PublishEvent() { + const { eventType } = useParams<{ eventType: string }>() + const { title, exit, saveAndExit, previous, next, finish } = + useEvent(eventType) + + return ( + + + + + } + /> + } + > + + + {previous && ( + + )} + + + + + Continue + + ]} + > + This is where the form will be rendered + + + + + ) +} diff --git a/packages/client/src/v2-events/features/events/fixtures.ts b/packages/client/src/v2-events/features/events/fixtures.ts new file mode 100644 index 00000000000..2e8782b4cc4 --- /dev/null +++ b/packages/client/src/v2-events/features/events/fixtures.ts @@ -0,0 +1,129 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ +export const tennisClubMembershipEvent = { + id: 'TENNIS_CLUB_MEMBERSHIP', + label: { + defaultMessage: 'Tennis club membership application', + description: 'This is what this event is referred as in the system', + id: 'event.tennis-club-membership.label' + }, + actions: [ + { + type: 'DECLARE', + label: { + defaultMessage: 'Send an application', + description: + 'This is shown as the action name anywhere the user can trigger the action from', + id: 'event.tennis-club-membership.action.declare.label' + }, + forms: [ + { + label: { + id: 'event.tennis-club-membership.action.declare.form.label', + defaultMessage: 'Tennis club membership application', + description: 'This is what this form is referred as in the system' + }, + active: true, + version: { + id: '1.0.0', + label: { + id: 'event.tennis-club-membership.action.declare.form.version.1', + defaultMessage: 'Version 1', + description: 'This is the first version of the form' + } + }, + pages: [ + { + id: 'applicant', + title: { + id: 'event.tennis-club-membership.action.declare.form.section.who.title', + defaultMessage: 'Who is applying for the membership?', + description: 'This is the title of the section' + }, + fields: [ + { + id: 'applicant.firstname', + type: 'TEXT', + required: true, + label: { + defaultMessage: "Applicant's first name", + description: 'This is the label for the field', + id: 'event.tennis-club-membership.action.declare.form.section.who.field.firstname.label' + } + }, + { + id: 'applicant.surname', + type: 'TEXT', + required: true, + label: { + defaultMessage: "Applicant's surname", + description: 'This is the label for the field', + id: 'event.tennis-club-membership.action.declare.form.section.who.field.surname.label' + } + }, + { + id: 'applicant.dob', + type: 'DATE', + required: true, + label: { + defaultMessage: "Applicant's date of birth", + description: 'This is the label for the field', + id: 'event.tennis-club-membership.action.declare.form.section.who.field.dob.label' + } + } + ] + }, + { + id: 'recommender', + title: { + id: 'event.tennis-club-membership.action.declare.form.section.recommender.title', + defaultMessage: 'Who is recommending the applicant?', + description: 'This is the title of the section' + }, + fields: [ + { + id: 'recommender.firstname', + type: 'TEXT', + required: true, + label: { + defaultMessage: "Recommender's first name", + description: 'This is the label for the field', + id: 'event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label' + } + }, + { + id: 'recommender.surname', + type: 'TEXT', + required: true, + label: { + defaultMessage: "Recommender's surname", + description: 'This is the label for the field', + id: 'event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label' + } + }, + { + id: 'recommender.id', + type: 'TEXT', + required: true, + label: { + defaultMessage: "Recommender's membership ID", + description: 'This is the label for the field', + id: 'event.tennis-club-membership.action.declare.form.section.recommender.field.id.label' + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/packages/client/src/v2-events/features/events/useEvent.ts b/packages/client/src/v2-events/features/events/useEvent.ts new file mode 100644 index 00000000000..7ed530dfb3d --- /dev/null +++ b/packages/client/src/v2-events/features/events/useEvent.ts @@ -0,0 +1,48 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { tennisClubMembershipEvent } from './fixtures' +import { useIntl } from 'react-intl' +import { usePagination } from './usePagination' +import { FieldConfig } from '@opencrvs/commons' + +const eventTypes = { 'tennis-club-membership': tennisClubMembershipEvent } + +export function useEvent(anyEventType: string) { + const intl = useIntl() + + if (!eventTypes[anyEventType as keyof typeof eventTypes]) { + throw new Error(`Event type ${anyEventType} not found`) + } + + const type = anyEventType as keyof typeof eventTypes + const { pages, label } = eventTypes[type].actions[0].forms[0] + + const { next, previous, page } = usePagination(pages.length) + + const exit = () => alert('exit') + const saveAndExit = () => alert('save and exit') + const finish = () => alert('finish') + + const title = intl.formatMessage(label) + + return { + type, + title, + exit, + saveAndExit, + previous, + next, + finish, + form: pages, + fields: pages[page].fields as FieldConfig[] + } +} diff --git a/packages/client/src/v2-events/features/events/usePagination.ts b/packages/client/src/v2-events/features/events/usePagination.ts new file mode 100644 index 00000000000..00f12a689c9 --- /dev/null +++ b/packages/client/src/v2-events/features/events/usePagination.ts @@ -0,0 +1,29 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ +import { useState } from 'react' + +// TODO: Paginate with react-router-dom +export const usePagination = ( + /** Amount of pages to iterate through */ + pages: number +) => { + const [page, setPage] = useState(0) + + const next = page < pages - 1 ? () => setPage(page + 1) : undefined + const previous = page > 0 ? () => setPage(page - 1) : undefined + + return { + /** Page number between 0 and pages - 1 */ + page, + next, + previous + } +} diff --git a/packages/client/src/v2-events/workqueues/index.tsx b/packages/client/src/v2-events/features/workqueues/index.tsx similarity index 86% rename from packages/client/src/v2-events/workqueues/index.tsx rename to packages/client/src/v2-events/features/workqueues/index.tsx index 60483d5a7da..8065a50ecc7 100644 --- a/packages/client/src/v2-events/workqueues/index.tsx +++ b/packages/client/src/v2-events/features/workqueues/index.tsx @@ -8,9 +8,8 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ - import React from 'react' -export function Workqueues() { - return
This is where it starts from
+export const Workqueues = () => { + return
Workqueues
} diff --git a/packages/client/src/v2-events/routes.ts b/packages/client/src/v2-events/routes/routes.ts similarity index 88% rename from packages/client/src/v2-events/routes.ts rename to packages/client/src/v2-events/routes/routes.ts index 4fdd9235d68..6d7efe2e514 100644 --- a/packages/client/src/v2-events/routes.ts +++ b/packages/client/src/v2-events/routes/routes.ts @@ -9,3 +9,4 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ export const V2_ROOT_ROUTE = '/v2' +export const V2_EVENT_ROUTE = `${V2_ROOT_ROUTE}/event/:eventType` diff --git a/packages/client/src/views/AdvancedSearch/AdvancedSearchResult.test.tsx b/packages/client/src/views/AdvancedSearch/AdvancedSearchResult.test.tsx index 352b644ffd6..53f6f5cbf76 100644 --- a/packages/client/src/views/AdvancedSearch/AdvancedSearchResult.test.tsx +++ b/packages/client/src/views/AdvancedSearch/AdvancedSearchResult.test.tsx @@ -31,7 +31,7 @@ import { REMOVE_ADVANCED_SEARCH_RESULT_BOOKMARK_MUTATION } from '@client/profile/mutations' import { getStorageUserDetailsSuccess } from '@client/profile/profileActions' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' const graphqlMock = [ { @@ -55,7 +55,7 @@ const graphqlMock = [ results: [ { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, __typename: 'X', registration: { __typename: 'X', diff --git a/packages/client/src/views/CorrectionForm/CorrectionReasonForm.test.tsx b/packages/client/src/views/CorrectionForm/CorrectionReasonForm.test.tsx index 9f9391da29f..b4f5e4ba18a 100644 --- a/packages/client/src/views/CorrectionForm/CorrectionReasonForm.test.tsx +++ b/packages/client/src/views/CorrectionForm/CorrectionReasonForm.test.tsx @@ -17,7 +17,7 @@ import { import { ReactWrapper } from 'enzyme' import * as React from 'react' import { CorrectionSection } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { IDeclaration, storeDeclaration } from '@client/declarations' import { CorrectionForm } from './CorrectionForm' import { formatUrl } from '@client/navigation' @@ -29,7 +29,7 @@ let wrapper: ReactWrapper<{}, {}> const birthDeclaration: IDeclaration = { id: '72c18939-70c1-40b4-9b80-b162c4871160', data: mockDeclarationData, - event: Event.Birth + event: EventType.Birth } const { store, history } = createStore() diff --git a/packages/client/src/views/CorrectionForm/CorrectionSummary.test.tsx b/packages/client/src/views/CorrectionForm/CorrectionSummary.test.tsx index 224f2f35601..28c6f61c8d8 100644 --- a/packages/client/src/views/CorrectionForm/CorrectionSummary.test.tsx +++ b/packages/client/src/views/CorrectionForm/CorrectionSummary.test.tsx @@ -22,7 +22,7 @@ import { import { ReactWrapper } from 'enzyme' import * as React from 'react' import { CorrectionSection } from '@client/forms' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { IDeclaration, storeDeclaration, @@ -89,7 +89,7 @@ const deathDeclaration: IDeclaration = { }, originalData: mockDeathDeclarationData, review: true, - event: Event.Death, + event: EventType.Death, registrationStatus: RegStatus.Registered, downloadStatus: DOWNLOAD_STATUS.DOWNLOADED, modifiedOn: 1644490181166, @@ -148,7 +148,7 @@ const birthDeclaration: IDeclaration = { }, originalData: mockDeclarationData, review: true, - event: Event.Birth, + event: EventType.Birth, registrationStatus: RegStatus.Registered, downloadStatus: DOWNLOAD_STATUS.DOWNLOADED, modifiedOn: 1644407705186, @@ -173,7 +173,7 @@ describe('Correction summary', () => { store.dispatch(getOfflineDataSuccess(JSON.stringify(mockOfflineData))) await flushPromises() store.dispatch(storeDeclaration(birthDeclaration)) - const form = await getRegisterFormFromStore(store, Event.Birth) + const form = await getRegisterFormFromStore(store, EventType.Birth) wrapper = await createTestComponent( const birthDeclaration: IDeclaration = { id: '72c18939-70c1-40b4-9b80-b162c4871160', data: mockDeclarationData, - event: Event.Birth + event: EventType.Birth } const deathDeclaration: IDeclaration = { id: '72c18939-70c1-40b4-9b80-b162c4871161', data: mockDeathDeclarationData, - event: Event.Death + event: EventType.Death } const { store, history } = createStore() diff --git a/packages/client/src/views/CorrectionForm/CorrectorForm.tsx b/packages/client/src/views/CorrectionForm/CorrectorForm.tsx index 7f46a733207..91975f00b6a 100644 --- a/packages/client/src/views/CorrectionForm/CorrectorForm.tsx +++ b/packages/client/src/views/CorrectionForm/CorrectorForm.tsx @@ -27,7 +27,7 @@ import { goToHomeTab } from '@client/navigation' import { IFormSection, IFormSectionData, ReviewSection } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { ActionPageLight } from '@opencrvs/components/lib/ActionPageLight' import { FormFieldGenerator } from '@client/components/form' import { Button } from '@opencrvs/components/lib/Button' @@ -159,7 +159,7 @@ function CorrectorFormComponent(props: IFullProps) { size={ContentSize.SMALL} title={group.title && intl.formatMessage(group.title)} subtitle={ - declaration.event === Event.Birth + declaration.event === EventType.Birth ? intl.formatMessage(messages.birthCorrectionNote) : undefined } diff --git a/packages/client/src/views/CorrectionForm/ReviewForm.test.tsx b/packages/client/src/views/CorrectionForm/ReviewForm.test.tsx index 5a064110d66..f6ee96218f0 100644 --- a/packages/client/src/views/CorrectionForm/ReviewForm.test.tsx +++ b/packages/client/src/views/CorrectionForm/ReviewForm.test.tsx @@ -15,7 +15,7 @@ import { } from '@client/tests/util' import { ReactWrapper } from 'enzyme' import { ReviewSection } from '@client/forms' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { IDeclaration, storeDeclaration, @@ -36,7 +36,7 @@ let history: History const declaration: IDeclaration = createReviewDeclaration( '72c18939-70c1-40b4-9b80-b162c4871160', mockDeclarationData, - Event.Birth, + EventType.Birth, RegStatus.Registered ) diff --git a/packages/client/src/views/CorrectionForm/ReviewForm.tsx b/packages/client/src/views/CorrectionForm/ReviewForm.tsx index cdee3a2fa7b..8f5fa097f70 100644 --- a/packages/client/src/views/CorrectionForm/ReviewForm.tsx +++ b/packages/client/src/views/CorrectionForm/ReviewForm.tsx @@ -19,7 +19,7 @@ import { IStoreState } from '@client/store' import { CERTIFICATE_CORRECTION_REVIEW, HOME } from '@client/navigation/routes' import { connect } from 'react-redux' import { getEventReviewForm } from '@client/forms/register/review-selectors' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { Redirect } from 'react-router-dom' type IStateProps = { @@ -46,7 +46,7 @@ function mapStateToProps(state: IStoreState, props: RouteProps): IStateProps { (app) => app.id === declarationId ) - const event = declaration?.event || Event.Birth + const event = declaration?.event || EventType.Birth const reviewForm = getEventReviewForm(state, event) diff --git a/packages/client/src/views/CorrectionForm/SupportingDocumentsForm.test.tsx b/packages/client/src/views/CorrectionForm/SupportingDocumentsForm.test.tsx index 53c6c876cb4..4d9dc95d06d 100644 --- a/packages/client/src/views/CorrectionForm/SupportingDocumentsForm.test.tsx +++ b/packages/client/src/views/CorrectionForm/SupportingDocumentsForm.test.tsx @@ -17,7 +17,7 @@ import { import { ReactWrapper } from 'enzyme' import * as React from 'react' import { CorrectionSection } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { IDeclaration, storeDeclaration } from '@client/declarations' import { formatUrl } from '@client/navigation' import { CERTIFICATE_CORRECTION } from '@client/navigation/routes' @@ -29,7 +29,7 @@ let wrapper: ReactWrapper<{}, {}> const birthDeclaration: IDeclaration = { id: '72c18939-70c1-40b4-9b80-b162c4871160', data: mockDeclarationData, - event: Event.Birth + event: EventType.Birth } const { store, history } = createStore() diff --git a/packages/client/src/views/CorrectionForm/VerifyCorrector.test.tsx b/packages/client/src/views/CorrectionForm/VerifyCorrector.test.tsx index a656a70aff7..3a4fd795d9b 100644 --- a/packages/client/src/views/CorrectionForm/VerifyCorrector.test.tsx +++ b/packages/client/src/views/CorrectionForm/VerifyCorrector.test.tsx @@ -18,7 +18,7 @@ import { } from '@client/tests/util' import { VerifyCorrector } from './VerifyCorrector' import { storeDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { ReactWrapper } from 'enzyme' import { WORKQUEUE_TABS } from '@client/components/interface/Navigation' import { vi } from 'vitest' @@ -29,13 +29,13 @@ describe('verify corrector tests', () => { const birthDeclaration = { id: 'mockBirth1234', data: mockDeclarationData, - event: Event.Birth + event: EventType.Birth } const deathDeclaration = { id: 'mockDeath1234', data: mockDeathDeclarationData, - event: Event.Death + event: EventType.Death } describe('in case of birth declaration', () => { diff --git a/packages/client/src/views/CorrectionForm/VerifyCorrector.tsx b/packages/client/src/views/CorrectionForm/VerifyCorrector.tsx index db2ff5e8ca3..b9e8f1aafd6 100644 --- a/packages/client/src/views/CorrectionForm/VerifyCorrector.tsx +++ b/packages/client/src/views/CorrectionForm/VerifyCorrector.tsx @@ -92,9 +92,26 @@ type IOwnProps = RouteComponentProps type IFullProps = IStateProps & IDispatchProps & IOwnProps & IntlShapeProps -class VerifyCorrectorComponent extends React.Component { - handleVerification = (hasShowedVerifiedDocument: boolean) => { - const declaration = this.props.declaration +const CHILD = 'child' +const FATHER = 'father' +const INFORMANT = 'informant' +const MOTHER = 'mother' + +const VerifyCorrectorComponent = ({ + declaration, + form, + registerForm, + config, + user, + goBack, + modifyDeclaration, + writeDeclaration, + goToPageGroup, + goToHomeTab, + intl, + match +}: IFullProps) => { + const handleVerification = (hasShowedVerifiedDocument: boolean) => { const changed = { ...declaration, data: { @@ -105,24 +122,22 @@ class VerifyCorrectorComponent extends React.Component { } } } - this.props.modifyDeclaration(changed) + modifyDeclaration(changed) + writeDeclaration(changed) - this.props.writeDeclaration(changed) - - this.props.goToPageGroup( + goToPageGroup( CERTIFICATE_CORRECTION_REVIEW, - this.props.declaration.id, + declaration.id, ReviewSection.Review, 'review-view-group', - this.props.declaration.event + declaration.event ) } - getGenericCorrectorInfo = (corrector: string): ICorrectorInfo => { - const { intl, declaration, form, registerForm, config, user } = this.props + const getGenericCorrectorInfo = (corrector: string): ICorrectorInfo => { const info = declaration.data[corrector] //TODO :: we have to get form defination from new certificateCorrectorDefination - const showInfoFor = ['mother', 'father', 'child', 'informant'] + const showInfoFor = [MOTHER, FATHER, CHILD, INFORMANT] const eventRegistrationInput = draftToGqlTransformer( registerForm, @@ -138,11 +153,11 @@ class VerifyCorrectorComponent extends React.Component { if (showInfoFor.includes(corrector)) { const fields = form[corrector] const iD = - (corrector === 'informant' + (corrector === INFORMANT ? eventRegistrationInput[informantType]?.identifier?.[0]?.id : undefined) ?? eventRegistrationInput[corrector]?.identifier?.[0]?.id const iDType = - (corrector === 'informant' + (corrector === INFORMANT ? eventRegistrationInput[informantType]?.identifier?.[0]?.type : undefined) ?? eventRegistrationInput[corrector]?.identifier?.[0]?.type @@ -181,79 +196,74 @@ class VerifyCorrectorComponent extends React.Component { nationality, age } - } else { - return { - iD: '', - iDType: '', - firstNames: '', - familyName: '', - birthDate: '', - nationality: '', - age: '' - } } - } - - logTime = (timeMs: number) => { - const declaration = this.props.declaration - if (!declaration.timeLoggedMS) { - declaration.timeLoggedMS = 0 + return { + iD: '', + iDType: '', + firstNames: '', + familyName: '', + birthDate: '', + nationality: '', + age: '' } - declaration.timeLoggedMS += timeMs - this.props.modifyDeclaration(declaration) } - render() { - const { corrector } = this.props.match.params - const { intl, declaration } = this.props - if (!declaration) { - return ( - - ) - } - const correctorInfo = this.getGenericCorrectorInfo(corrector) - const hasNoInfo = Object.values(correctorInfo).every( - (property) => property === undefined || property === '' - ) + const logTime = (timeMs: number) => { + const updatedDeclaration = { ...declaration } + + updatedDeclaration.timeLoggedMS = updatedDeclaration.timeLoggedMS ?? 0 + updatedDeclaration.timeLoggedMS += timeMs + modifyDeclaration(updatedDeclaration) + } + const { corrector } = match.params + if (!declaration) { return ( - - this.props.goToHomeTab(WORKQUEUE_TABS.readyForReview)} - title={intl.formatMessage(messages.title)} - hideBackground - > - { - { - this.handleVerification(true) - } - }, - negativeAction: { - label: intl.formatMessage(messages.idCheckWithoutVerify), - handler: () => { - this.handleVerification(false) - } - } - }} - /> - } - - + ) } + const correctorInfo = getGenericCorrectorInfo(corrector) + const hasNoInfo = Object.values(correctorInfo).every( + (property) => property === undefined || property === '' + ) + + return ( + + goToHomeTab(WORKQUEUE_TABS.readyForReview)} + title={intl.formatMessage(messages.title)} + hideBackground + > + { + { + handleVerification(true) + } + }, + negativeAction: { + label: intl.formatMessage(messages.idCheckWithoutVerify), + handler: () => { + handleVerification(false) + } + } + }} + /> + } + + + ) } const mapStateToProps = ( diff --git a/packages/client/src/views/CorrectionForm/utils.test.ts b/packages/client/src/views/CorrectionForm/utils.test.ts index f16c5f99388..b407037e1f9 100644 --- a/packages/client/src/views/CorrectionForm/utils.test.ts +++ b/packages/client/src/views/CorrectionForm/utils.test.ts @@ -10,13 +10,13 @@ */ import { IDeclaration } from '@client/declarations' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { isCorrection } from './utils' let declaration: IDeclaration = { id: '72c18939-70c1-40b4-9b80-b162c4871160', data: {}, - event: Event.Birth + event: EventType.Birth } describe('isCorrection()', () => { diff --git a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueCollectorForm.test.tsx b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueCollectorForm.test.tsx index 714502fb456..14a6f6c6670 100644 --- a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueCollectorForm.test.tsx +++ b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueCollectorForm.test.tsx @@ -14,7 +14,7 @@ import { createLocation, History } from 'history' import { ReactWrapper } from 'enzyme' import { IssueCollectorForm } from './IssueCollectorForm' import { createTestComponent, mockDeclarationData } from '@client/tests/util' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { IssueCollectorFormForOthers } from './IssueFormForOthers' let store: AppStore @@ -173,7 +173,7 @@ mockDeclarationData['history'] = declarationsHistory const birthDeclarationForIssuance = { id: '6a5fd35d-01ec-4c37-976e-e055107a74a1', data: mockDeclarationData, - event: Event.Birth + event: EventType.Birth } beforeEach(() => { diff --git a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueFormForOthers.tsx b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueFormForOthers.tsx index d09e62d6db4..5c9a83fbcd3 100644 --- a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueFormForOthers.tsx +++ b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssueFormForOthers.tsx @@ -30,18 +30,18 @@ import { collectDeathCertificateFormSection, collectMarriageCertificateFormSection } from '@client/forms/certificate/fieldDefinitions/collectorSection' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { Redirect } from 'react-router-dom' import { REGISTRAR_HOME_TAB } from '@client/navigation/routes' import { WORKQUEUE_TABS } from '@client/components/interface/Navigation' import { getOfflineData } from '@client/offline/selectors' import { getUserDetails } from '@client/profile/profileSelectors' -function collectorFormFieldsForOthers(event: Event) { +function collectorFormFieldsForOthers(event: EventType) { const collectCertFormSection = - event === Event.Birth + event === EventType.Birth ? collectBirthCertificateFormSection - : event === Event.Death + : event === EventType.Death ? collectDeathCertificateFormSection : collectMarriageCertificateFormSection diff --git a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx index 8a0ce5963e7..568e36c96a2 100644 --- a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx +++ b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.test.tsx @@ -20,7 +20,7 @@ import { mockUserResponse, validToken } from '@client/tests/util' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import * as React from 'react' import { Mock, vi } from 'vitest' import { IssuePayment } from './IssuePayment' @@ -47,7 +47,7 @@ const birthDeclaration = { } ] }, - event: Event.Birth + event: EventType.Birth } const deathDeclaration = { @@ -67,7 +67,7 @@ const deathDeclaration = { } ] }, - event: Event.Death + event: EventType.Death } describe('verify collector tests for issuance', () => { @@ -103,7 +103,7 @@ describe('verify collector tests for issuance', () => { match={{ params: { registrationId: 'mockBirth', - eventType: Event.Birth + eventType: EventType.Birth }, isExact: true, path: '', diff --git a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.tsx b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.tsx index 74d2775a127..ef239b7078d 100644 --- a/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.tsx +++ b/packages/client/src/views/IssueCertificate/IssueCollectorForm/IssuePayment.tsx @@ -42,7 +42,7 @@ import { messages } from '@client/i18n/messages/views/certificate' import { getOfflineData } from '@client/offline/selectors' import { IStoreState } from '@client/store' import { useDispatch, useSelector } from 'react-redux' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { Button } from '@opencrvs/components/src/Button' import { SubmissionAction } from '@client/forms' import { issueMessages } from '@client/i18n/messages/issueCertificate' @@ -215,10 +215,10 @@ const getEvent = (eventType: string | undefined) => { switch (eventType && eventType.toLowerCase()) { case 'birth': default: - return Event.Birth + return EventType.Birth case 'death': - return Event.Death + return EventType.Death case 'marriage': - return Event.Marriage + return EventType.Marriage } } diff --git a/packages/client/src/views/OfficeHome/OfficeHome.tsx b/packages/client/src/views/OfficeHome/OfficeHome.tsx index 64795cb6ce2..bb58f4d376a 100644 --- a/packages/client/src/views/OfficeHome/OfficeHome.tsx +++ b/packages/client/src/views/OfficeHome/OfficeHome.tsx @@ -32,10 +32,7 @@ import styled from 'styled-components' import { getUserLocation } from '@client/utils/userUtils' import { FloatingActionButton } from '@opencrvs/components/lib/buttons' import { PlusTransparentWhite } from '@opencrvs/components/lib/icons' -import { - PAGE_TRANSITIONS_ENTER_TIME, - FIELD_AGENT_ROLES -} from '@client/utils/constants' +import { SYNC_WORKQUEUE_TIME, FIELD_AGENT_ROLES } from '@client/utils/constants' import { Toast } from '@opencrvs/components/lib/Toast' import * as React from 'react' import { injectIntl, WrappedComponentProps as IntlShapeProps } from 'react-intl' @@ -60,7 +57,7 @@ import { ArrayElement } from '@client/SubmissionController' import { ReadyToIssue } from './readyToIssue/ReadyToIssue' import { getOfflineData } from '@client/offline/selectors' import { IOfflineData } from '@client/offline/reducer' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { SELECT_VITAL_EVENT } from '@client/navigation/routes' const FABContainer = styled.div` @@ -160,7 +157,7 @@ class OfficeHomeView extends React.Component< } syncWorkqueue() { - setTimeout(() => this.updateWorkqueue(), PAGE_TRANSITIONS_ENTER_TIME) + setTimeout(() => this.updateWorkqueue(), SYNC_WORKQUEUE_TIME) if (this.interval) { clearInterval(this.interval) } @@ -278,10 +275,12 @@ class OfficeHomeView extends React.Component< storedDeclarations ) - const isOnePrintInAdvanceOn = Object.values(Event).some((event: Event) => { - const upperCaseEvent = event.toUpperCase() as Uppercase - return offlineResources.config[upperCaseEvent].PRINT_IN_ADVANCE - }) + const isOnePrintInAdvanceOn = Object.values(EventType).some( + (event: EventType) => { + const upperCaseEvent = event.toUpperCase() as Uppercase + return offlineResources.config[upperCaseEvent].PRINT_IN_ADVANCE + } + ) return ( <> diff --git a/packages/client/src/views/OfficeHome/inExternalValidation/inExternalValidationTab.test.tsx b/packages/client/src/views/OfficeHome/inExternalValidation/inExternalValidationTab.test.tsx index 39dbe0bb5f3..91a38e172cb 100644 --- a/packages/client/src/views/OfficeHome/inExternalValidation/inExternalValidationTab.test.tsx +++ b/packages/client/src/views/OfficeHome/inExternalValidation/inExternalValidationTab.test.tsx @@ -25,7 +25,7 @@ import { waitForElement } from '@client/tests/wait-for-element' import { Workqueue } from '@opencrvs/components/lib/Workqueue' import { History } from 'history' import { vi, Mock } from 'vitest' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' const EVENT_CREATION_TIME = 1583322631424 // Wed Mar 04 2020 13:50:31 GMT+0200 (Eastern European Standard Time) const SEND_FOR_VALIDATION_TIME = 1582912800000 // Fri Feb 28 2020 20:00:00 GMT+0200 (Eastern European Standard Time) @@ -43,7 +43,7 @@ const getItem = window.localStorage.getItem as Mock const birthEventSearchSet: GQLBirthEventSearchSet = { id: '956281c9-1f47-4c26-948a-970dd23c4094', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'WAITING_VALIDATION', contactNumber: '01622688231', diff --git a/packages/client/src/views/OfficeHome/inProgress/InProgress.tsx b/packages/client/src/views/OfficeHome/inProgress/InProgress.tsx index e8949fe824a..4b3ce93783a 100644 --- a/packages/client/src/views/OfficeHome/inProgress/InProgress.tsx +++ b/packages/client/src/views/OfficeHome/inProgress/InProgress.tsx @@ -54,7 +54,7 @@ import { IOfflineData } from '@client/offline/reducer' import { getOfflineData } from '@client/offline/selectors' import { IStoreState } from '@client/store' import { DownloadAction } from '@client/forms' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { DownloadButton } from '@client/components/interface/DownloadButton' import { getDeclarationFullName } from '@client/utils/draftUtils' import { @@ -361,9 +361,9 @@ function InProgressComponent(props: IRegistrarHomeProps) { '' const eventTime = - draft.event === Event.Birth + draft.event === EventType.Birth ? draft.data.child?.childBirthDate || '' - : draft.event === Event.Death + : draft.event === EventType.Death ? draft.data.deathEvent?.deathDate || '' : draft.data.marriageEvent?.marriageDate || '' diff --git a/packages/client/src/views/OfficeHome/inProgress/inProgress.test.tsx b/packages/client/src/views/OfficeHome/inProgress/inProgress.test.tsx index 6232b2049b2..b8e821b93f6 100644 --- a/packages/client/src/views/OfficeHome/inProgress/inProgress.test.tsx +++ b/packages/client/src/views/OfficeHome/inProgress/inProgress.test.tsx @@ -19,7 +19,7 @@ import { modifyDeclaration } from '@client/declarations' import { DownloadAction } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { formatUrl } from '@client/navigation' import { REGISTRAR_HOME_TAB, @@ -86,12 +86,12 @@ describe('In Progress tab', () => { const localDrafts = [ { id: '1', - event: Event.Birth, + event: EventType.Birth, data: {} }, { id: '2', - event: Event.Birth, + event: EventType.Birth, data: {} } ] @@ -154,12 +154,12 @@ describe('In Progress tab', () => { const localDrafts = [ { id: '1', - event: Event.Birth, + event: EventType.Birth, data: {} }, { id: '2', - event: Event.Birth, + event: EventType.Birth, data: {} } ] @@ -217,13 +217,13 @@ describe('In Progress tab', () => { familyNameEng: 'Hoque' } }, - event: Event.Birth, + event: EventType.Birth, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], modifiedOn: TIME_STAMP }, { id: 'e6605607-92e0-4625-87d8-c168205bdde7', - event: Event.Birth, + event: EventType.Birth, modifiedOn: TIME_STAMP, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], data: { @@ -247,7 +247,7 @@ describe('In Progress tab', () => { familyNameEng: 'Hoque' } }, - event: Event.Death, + event: EventType.Death, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], modifiedOn: TIME_STAMP }, @@ -260,7 +260,7 @@ describe('In Progress tab', () => { familyNameEng: 'Hoque' } }, - event: Event.Death, + event: EventType.Death, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], modifiedOn: TIME_STAMP } @@ -307,7 +307,7 @@ describe('In Progress tab', () => { vi.clearAllMocks() const drafts: IDeclaration[] = [] for (let i = 0; i < 12; i++) { - drafts.push(createDeclaration(Event.Birth)) + drafts.push(createDeclaration(EventType.Birth)) } const testComponent = await createTestComponent( { const drafts: IDeclaration[] = [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - event: Event.Birth, + event: EventType.Birth, modifiedOn: TIME_STAMP, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], data: { @@ -372,7 +372,7 @@ describe('In Progress tab', () => { }, { id: 'bd22s7c5-ad87-4117-91c1-35eaf2ese32bw', - event: Event.Birth, + event: EventType.Birth, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], modifiedOn: TIME_STAMP, data: { @@ -383,7 +383,7 @@ describe('In Progress tab', () => { }, { id: 'cc66d69c-7f0a-4047-9283-f066571830f1', - event: Event.Death, + event: EventType.Death, modifiedOn: TIME_STAMP, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], data: { @@ -395,7 +395,7 @@ describe('In Progress tab', () => { }, { id: 'cc66d69c-7f0a-4047-9283-f066571830f2', - event: Event.Death, + event: EventType.Death, modifiedOn: TIME_STAMP, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], data: { @@ -406,7 +406,7 @@ describe('In Progress tab', () => { }, { id: 'cc66d69c-7f0a-4047-9283-f066571830f4', - event: Event.Death, + event: EventType.Death, modifiedOn: TIME_STAMP + 1, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT], data: { @@ -463,7 +463,7 @@ describe('In Progress tab', () => { it('renders all items returned from graphql query in inProgress tab', async () => { const TIME_STAMP = '1562912635549' const drafts: IDeclaration[] = [] - drafts.push(createDeclaration(Event.Birth)) + drafts.push(createDeclaration(EventType.Birth)) const testComponent = await createTestComponent( { results: [ { id: '956281c9-1f47-4c26-948a-970dd23c4094', - type: Event.Death, + type: EventType.Death, registration: { status: 'IN_PROGRESS', contactNumber: undefined, @@ -556,7 +556,7 @@ describe('In Progress tab', () => { it('Should render pagination in progress tab if data is more than 10', async () => { vi.clearAllMocks() const drafts: IDeclaration[] = [] - drafts.push(createDeclaration(Event.Birth)) + drafts.push(createDeclaration(EventType.Birth)) const testComponent = await createTestComponent( { vi.clearAllMocks() const TIME_STAMP = '1562912635549' const drafts: IDeclaration[] = [] - drafts.push(createDeclaration(Event.Birth)) + drafts.push(createDeclaration(EventType.Birth)) // @ts-ignore const testComponent = await createTestComponent( { results: [ { id: '956281c9-1f47-4c26-948a-970dd23c4094', - type: Event.Death, + type: EventType.Death, registration: { status: 'IN_PROGRESS', contactNumber: undefined, @@ -706,7 +706,7 @@ describe('In Progress tab', () => { results: [ { id: declarationId, - type: Event.Birth, + type: EventType.Birth, registration: { trackingId: 'BQ2IDOP', modifiedAt: TIME_STAMP @@ -734,7 +734,7 @@ describe('In Progress tab', () => { } it('renders download button when not downloaded', async () => { const downloadableDeclaration = makeDeclarationReadyToDownload( - Event.Birth, + EventType.Birth, declarationId, DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -751,7 +751,7 @@ describe('In Progress tab', () => { }) it('renders loading indicator when declaration is being downloaded', async () => { const downloadableDeclaration = makeDeclarationReadyToDownload( - Event.Birth, + EventType.Birth, declarationId, DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -768,7 +768,7 @@ describe('In Progress tab', () => { }) it('renders update button when download succeeds', async () => { const downloadableDeclaration = makeDeclarationReadyToDownload( - Event.Birth, + EventType.Birth, declarationId, DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -797,13 +797,13 @@ describe('In Progress tab', () => { formatUrl(REVIEW_EVENT_PARENT_FORM_PAGE, { declarationId, pageId: 'review', - event: Event.Birth + event: EventType.Birth }) ) }) it('renders error when download fails', async () => { const downloadableDeclaration = makeDeclarationReadyToDownload( - Event.Birth, + EventType.Birth, declarationId, DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -825,7 +825,7 @@ describe('In Progress tab', () => { const TIME_STAMP = '1562912635549' const birthNotificationSentDateStr = '2019-10-20T11:03:20.660Z' const drafts: IDeclaration[] = [] - drafts.push(createDeclaration(Event.Birth)) + drafts.push(createDeclaration(EventType.Birth)) const testComponent = await createTestComponent( { results: [ { id: 'f0a1ca2c-6a14-4b9e-a627-c3e2e110587e', - type: Event.Birth, + type: EventType.Birth, registration: { trackingId: 'BQ2IDOP', modifiedAt: TIME_STAMP @@ -872,7 +872,7 @@ describe('In Progress tab', () => { } as GQLBirthEventSearchSet, { id: '2f7828fd-24ac-49fd-a1fd-53cda4777aa0', - type: Event.Death, + type: EventType.Death, registration: { trackingId: 'DZECJZC', modifiedAt: TIME_STAMP @@ -937,7 +937,7 @@ describe('In Progress tab', () => { vi.clearAllMocks() const TIME_STAMP = '1562912635549' const drafts: IDeclaration[] = [] - drafts.push(createDeclaration(Event.Birth)) + drafts.push(createDeclaration(EventType.Birth)) const declarationId = 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8' // @ts-ignore @@ -951,7 +951,7 @@ describe('In Progress tab', () => { results: [ { id: declarationId, - type: Event.Birth, + type: EventType.Birth, registration: { trackingId: 'BQ2IDOP', modifiedAt: TIME_STAMP diff --git a/packages/client/src/views/OfficeHome/outbox/Outbox.test.tsx b/packages/client/src/views/OfficeHome/outbox/Outbox.test.tsx index 7c2653bcd7b..f427e8bf606 100644 --- a/packages/client/src/views/OfficeHome/outbox/Outbox.test.tsx +++ b/packages/client/src/views/OfficeHome/outbox/Outbox.test.tsx @@ -23,7 +23,7 @@ import { createTestStore, mockDeclarationData } from '@client/tests/util' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { ReactWrapper } from 'enzyme' import * as React from 'react' import { Outbox } from './Outbox' @@ -32,7 +32,7 @@ function storeOutboxDeclaration( store: AppStore, submissionStatus: SUBMISSION_STATUS ) { - const declaration = createDeclaration(Event.Birth, mockDeclarationData) + const declaration = createDeclaration(EventType.Birth, mockDeclarationData) declaration.submissionStatus = submissionStatus store.dispatch(storeDeclaration(declaration)) } diff --git a/packages/client/src/views/OfficeHome/readyForReview/readyForReview.test.tsx b/packages/client/src/views/OfficeHome/readyForReview/readyForReview.test.tsx index 24c4f231e72..9af994a24f9 100644 --- a/packages/client/src/views/OfficeHome/readyForReview/readyForReview.test.tsx +++ b/packages/client/src/views/OfficeHome/readyForReview/readyForReview.test.tsx @@ -15,7 +15,7 @@ import { modifyDeclaration } from '@client/declarations' import { DownloadAction } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { checkAuth } from '@client/profile/profileActions' import { queries } from '@client/profile/queries' import { createStore } from '@client/store' @@ -72,7 +72,7 @@ const mockListSyncController = vi.fn() const mockSearchData = { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'DECLARED', contactNumber: '01622688231', @@ -153,7 +153,7 @@ const mockReviewTabData = { results: [ { id: '9a55d213-ad9f-4dcd-9418-340f3a7f6269', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'DECLARED', contactNumber: '01622688231', @@ -201,7 +201,7 @@ const mockReviewTabData = { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'VALIDATED', trackingId: 'DW0UTHR', @@ -352,7 +352,7 @@ describe('OfficeHome sent for review tab related tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'DECLARED', contactNumber: '01622688231', @@ -380,7 +380,7 @@ describe('OfficeHome sent for review tab related tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'VALIDATED', trackingId: 'DW0UTHR', @@ -528,7 +528,7 @@ describe('OfficeHome sent for review tab related tests', () => { //TODO:: FAILED TEST it.skip('shows error when download is failed', async () => { const downloadedDeclaration = makeDeclarationReadyToDownload( - Event.Death, + EventType.Death, 'bc09200d-0160-43b4-9e2b-5b9e90424e95', DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -555,7 +555,7 @@ describe('OfficeHome sent for review tab related tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'VALIDATED', contactNumber: '01622688231', @@ -580,7 +580,7 @@ describe('OfficeHome sent for review tab related tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'DECLARED', trackingId: 'DW0UTHR', @@ -681,7 +681,7 @@ describe('OfficeHome sent for review tab related tests', () => { it('shows review button when download is complete', async () => { const downloadedDeclaration = makeDeclarationReadyToDownload( - Event.Death, + EventType.Death, 'bc09200d-0160-43b4-9e2b-5b9e90424e95', DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -705,7 +705,7 @@ describe('OfficeHome sent for review tab related tests', () => { it('shows error when download is failed', async () => { const downloadedDeclaration = makeDeclarationReadyToDownload( - Event.Death, + EventType.Death, 'bc09200d-0160-43b4-9e2b-5b9e90424e95', DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -750,7 +750,7 @@ describe('Tablet tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'VALIDATED', contactNumber: '01622688231', @@ -778,7 +778,7 @@ describe('Tablet tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'DECLARED', trackingId: 'DW0UTHR', diff --git a/packages/client/src/views/OfficeHome/readyToPrint/readyToPrint.test.tsx b/packages/client/src/views/OfficeHome/readyToPrint/readyToPrint.test.tsx index 4aa1773c424..b349d8aaded 100644 --- a/packages/client/src/views/OfficeHome/readyToPrint/readyToPrint.test.tsx +++ b/packages/client/src/views/OfficeHome/readyToPrint/readyToPrint.test.tsx @@ -14,7 +14,7 @@ import { storeDeclaration } from '@client/declarations' import { DownloadAction } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { checkAuth } from '@client/profile/profileActions' import { queries } from '@client/profile/queries' import { storage } from '@client/storage' @@ -73,7 +73,7 @@ const nameObj = { const mockUserData = { id: '956281c9-1f47-4c26-948a-970dd23c4094', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'REGISTERED', contactNumber: '01622688231', @@ -155,7 +155,7 @@ const mockPrintTabData = { results: [ { id: '956281c9-1f47-4c26-948a-970dd23c4094', - type: Event.Death, + type: EventType.Death, registration: { status: 'REGISTERED', contactNumber: undefined, @@ -204,7 +204,7 @@ const mockPrintTabData = { } as GQLDeathEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'REGISTERED', trackingId: 'DW0UTHR', @@ -252,7 +252,7 @@ describe('RegistrarHome ready to print tab related tests', () => { const birthEventRegisteredDate = '2019-10-20T11:03:20.660Z' const birthEventSearchSet: GQLBirthEventSearchSet = { id: '956281c9-1f47-4c26-948a-970dd23c4094', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'REGISTERED', contactNumber: '01622688231', @@ -302,7 +302,7 @@ describe('RegistrarHome ready to print tab related tests', () => { const deathEventSearchSet: GQLDeathEventSearchSet = { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'REGISTERED', trackingId: 'DW0UTHR', @@ -751,7 +751,7 @@ describe('RegistrarHome ready to print tab related tests', () => { it('shows error when download is failed', async () => { const downloadedDeclaration = makeDeclarationReadyToDownload( - Event.Death, + EventType.Death, 'bc09200d-0160-43b4-9e2b-5b9e90424e95', DownloadAction.LOAD_CERTIFICATE_DECLARATION ) diff --git a/packages/client/src/views/OfficeHome/requiresUpdate/requiresUpdate.test.tsx b/packages/client/src/views/OfficeHome/requiresUpdate/requiresUpdate.test.tsx index 1b88a7f5b46..43062e666b3 100644 --- a/packages/client/src/views/OfficeHome/requiresUpdate/requiresUpdate.test.tsx +++ b/packages/client/src/views/OfficeHome/requiresUpdate/requiresUpdate.test.tsx @@ -14,7 +14,7 @@ import { storeDeclaration } from '@client/declarations' import { DownloadAction } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { checkAuth } from '@client/profile/profileActions' import { queries } from '@client/profile/queries' import { storage } from '@client/storage' @@ -78,7 +78,7 @@ const TIME_STAMP = '1544188309380' const mockUserData = { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'REJECTED', contactNumber: '01622688231', @@ -181,7 +181,7 @@ describe('OfficeHome sent for update tab related tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'REJECTED', contactNumber: '01622688231', @@ -230,7 +230,7 @@ describe('OfficeHome sent for update tab related tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'REJECTED', trackingId: 'DW0UTHR', @@ -338,7 +338,7 @@ describe('OfficeHome sent for update tab related tests', () => { results: [ { id: '9a55d213-ad9f-4dcd-9418-340f3a7f6269', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'REJECTED', contactNumber: '01622688231', @@ -369,7 +369,7 @@ describe('OfficeHome sent for update tab related tests', () => { }, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'REJECTED', trackingId: 'DW0UTHR', @@ -470,7 +470,7 @@ describe('OfficeHome sent for update tab related tests', () => { it('shows error when download is failed', async () => { const downloadedDeclaration = makeDeclarationReadyToDownload( - Event.Death, + EventType.Death, 'bc09200d-0160-43b4-9e2b-5b9e90424e95', DownloadAction.LOAD_REVIEW_DECLARATION ) @@ -510,7 +510,7 @@ describe('Tablet tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'REJECTED', contactNumber: '01622688231', @@ -538,7 +538,7 @@ describe('Tablet tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'REJECTED', trackingId: 'DW0UTHR', diff --git a/packages/client/src/views/OfficeHome/sentForReview/SentForReview.test.tsx b/packages/client/src/views/OfficeHome/sentForReview/SentForReview.test.tsx index d16cc4f651e..979336f15b9 100644 --- a/packages/client/src/views/OfficeHome/sentForReview/SentForReview.test.tsx +++ b/packages/client/src/views/OfficeHome/sentForReview/SentForReview.test.tsx @@ -29,7 +29,7 @@ import type { import { formattedDuration } from '@client/utils/date-formatting' import { History } from 'history' import { vi, Mock } from 'vitest' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' const validateScopeToken = jwt.sign( { scope: ['validate'] }, @@ -60,7 +60,7 @@ const nameObj = { const mockUserData = { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'DECLARED', contactNumber: '01622688231', @@ -159,7 +159,7 @@ describe('RegistrationHome sent for approval tab related tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'VALIDATED', contactNumber: '01622688231', @@ -208,7 +208,7 @@ describe('RegistrationHome sent for approval tab related tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'VALIDATED', trackingId: 'DW0UTHR', @@ -356,7 +356,7 @@ describe('RegistrationHome sent for approval tab related tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'VALIDATED', contactNumber: '01622688231', @@ -384,7 +384,7 @@ describe('RegistrationHome sent for approval tab related tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'VALIDATED', trackingId: 'DW0UTHR', @@ -484,7 +484,7 @@ describe('Tablet tests', () => { results: [ { id: 'e302f7c5-ad87-4117-91c1-35eaf2ea7be8', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'VALIDATED', contactNumber: '01622688231', @@ -512,7 +512,7 @@ describe('Tablet tests', () => { } as GQLBirthEventSearchSet, { id: 'bc09200d-0160-43b4-9e2b-5b9e90424e95', - type: Event.Death, + type: EventType.Death, registration: { status: 'VALIDATED', trackingId: 'DW0UTHR', diff --git a/packages/client/src/views/Performance/FieldAgentList.tsx b/packages/client/src/views/Performance/FieldAgentList.tsx index 374cc889f7e..ad6b41ebfa1 100644 --- a/packages/client/src/views/Performance/FieldAgentList.tsx +++ b/packages/client/src/views/Performance/FieldAgentList.tsx @@ -38,7 +38,7 @@ import styled from 'styled-components' import { ILocation } from '@client/offline/reducer' import format from '@client/utils/date-formatting' import { Content, ContentSize } from '@opencrvs/components/lib/Content' -import { Avatar, Event } from '@client/utils/gateway' +import { Avatar, EventType } from '@client/utils/gateway' import { Pagination } from '@opencrvs/components/lib/Pagination' import { getLanguage } from '@client/i18n/selectors' import { getUserRole } from '@client/utils' @@ -161,7 +161,7 @@ function FieldAgentListComponent(props: IProps) { offlineOffices } = props const { - event = Event.Birth, + event = EventType.Birth, locationId, timeStart, timeEnd @@ -428,11 +428,11 @@ function FieldAgentListComponent(props: IProps) { options={[ { label: intl.formatMessage(messages.eventOptionForBirths), - value: Event.Birth + value: EventType.Birth }, { label: intl.formatMessage(messages.eventOptionForDeaths), - value: Event.Death + value: EventType.Death } ]} /> diff --git a/packages/client/src/views/PrintCertificate/Payment.test.tsx b/packages/client/src/views/PrintCertificate/Payment.test.tsx index 9896a006a72..3b0e820d4a0 100644 --- a/packages/client/src/views/PrintCertificate/Payment.test.tsx +++ b/packages/client/src/views/PrintCertificate/Payment.test.tsx @@ -19,7 +19,7 @@ import { flushPromises } from '@client/tests/util' import { storeDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { Payment } from './Payment' import { queries } from '@client/profile/queries' import { checkAuth } from '@client/profile/profileActions' @@ -47,7 +47,7 @@ describe('verify collector tests', () => { } ] }, - event: Event.Birth + event: EventType.Birth } const deathDeclaration = { @@ -62,7 +62,7 @@ describe('verify collector tests', () => { } ] }, - event: Event.Death + event: EventType.Death } describe('in case of birth declaration', () => { @@ -82,7 +82,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth1234', - eventType: Event.Birth + eventType: EventType.Birth }, isExact: true, path: '', @@ -116,7 +116,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth1234', - eventType: Event.Birth + eventType: EventType.Birth }, isExact: true, path: '', @@ -139,7 +139,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth', - eventType: Event.Birth + eventType: EventType.Birth }, isExact: true, path: '', @@ -171,7 +171,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockDeath1234', - eventType: Event.Death + eventType: EventType.Death }, isExact: true, path: '', diff --git a/packages/client/src/views/PrintCertificate/Payment.tsx b/packages/client/src/views/PrintCertificate/Payment.tsx index 5ff027deec5..8d09e93c65d 100644 --- a/packages/client/src/views/PrintCertificate/Payment.tsx +++ b/packages/client/src/views/PrintCertificate/Payment.tsx @@ -13,7 +13,7 @@ import { Button } from '@opencrvs/components/lib/Button' import { Content, ContentSize } from '@opencrvs/components/lib/Content' import { Currency } from '@opencrvs/components/lib/Currency' import { IPrintableDeclaration, modifyDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { buttonMessages } from '@client/i18n/messages' import { messages } from '@client/i18n/messages/views/certificate' import { @@ -44,7 +44,7 @@ import { Summary } from '@opencrvs/components/lib/Summary' import { UserDetails } from '@client/utils/userUtils' interface IProps { - event: Event + event: EventType registrationId: string language: string declaration: IPrintableDeclaration @@ -184,11 +184,11 @@ const getEvent = (eventType: string | undefined) => { switch (eventType && eventType.toLowerCase()) { case 'birth': default: - return Event.Birth + return EventType.Birth case 'death': - return Event.Death + return EventType.Death case 'marriage': - return Event.Marriage + return EventType.Marriage } } diff --git a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx index 3806ce0308c..212699e25ed 100644 --- a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx +++ b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx @@ -24,7 +24,7 @@ import { import { ReviewCertificate } from './ReviewCertificateAction' import { ReactWrapper } from 'enzyme' import { IFormSectionData } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { cloneDeep } from 'lodash' import { waitForElement } from '@client/tests/wait-for-element' import { push } from 'connected-react-router' @@ -42,7 +42,7 @@ const deathDeclaration = { } ] }, - event: Event.Death + event: EventType.Death } describe('when user wants to review death certificate', () => { @@ -53,7 +53,7 @@ describe('when user wants to review death certificate', () => { { matchParams: { registrationId: 'mockDeath1234', - eventType: Event.Death + eventType: EventType.Death } } ) @@ -104,7 +104,7 @@ describe('back button behavior tests of review certificate action', () => { { matchParams: { registrationId: 'asdhdqe2472487jsdfsdf', - eventType: Event.Birth + eventType: EventType.Birth } } ) @@ -118,7 +118,7 @@ describe('back button behavior tests of review certificate action', () => { const birthDeclaration = { id: 'asdhdqe2472487jsdfsdf', data: mockBirthDeclarationData, - event: Event.Birth + event: EventType.Birth } store.dispatch( // @ts-ignore @@ -140,7 +140,7 @@ describe('back button behavior tests of review certificate action', () => { { matchParams: { registrationId: 'asdhdqe2472487jsdfsdf', - eventType: Event.Birth + eventType: EventType.Birth } } ) @@ -153,7 +153,7 @@ describe('back button behavior tests of review certificate action', () => { storeDeclaration({ id: 'asdhdqe2472487jsdfsdf', data: mockBirthDeclarationData, - event: Event.Birth + event: EventType.Birth } as IDeclaration) ) component = await createTestComponent(, { @@ -177,7 +177,7 @@ describe('when user wants to review birth certificate', () => { { matchParams: { registrationId: 'asdhdqe2472487jsdfsdf', - eventType: Event.Birth + eventType: EventType.Birth } } ) @@ -205,7 +205,7 @@ describe('when user wants to review birth certificate', () => { } ] as unknown as IFormSectionData }, - event: Event.Birth + event: EventType.Birth }) ) @@ -257,7 +257,7 @@ describe('when user wants to review marriage certificate', () => { { matchParams: { registrationId: '1234896128934719', - eventType: Event.Birth + eventType: EventType.Birth } } ) @@ -281,7 +281,7 @@ describe('when user wants to review marriage certificate', () => { } ] as unknown as IFormSectionData }, - event: Event.Marriage + event: EventType.Marriage }) ) diff --git a/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx b/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx index 30d7de84a8b..19c6acc5ba5 100644 --- a/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx +++ b/packages/client/src/views/PrintCertificate/VerifyCollector.test.tsx @@ -17,7 +17,7 @@ import { } from '@client/tests/util' import { VerifyCollector } from './VerifyCollector' import { storeDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { ReactWrapper } from 'enzyme' describe('verify collector tests', () => { @@ -35,7 +35,7 @@ describe('verify collector tests', () => { } ] }, - event: Event.Birth + event: EventType.Birth } const deathDeclaration = { @@ -50,7 +50,7 @@ describe('verify collector tests', () => { } ] }, - event: Event.Death + event: EventType.Death } describe('in case of birth declaration', () => { @@ -67,7 +67,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth1234', - eventType: Event.Birth, + eventType: EventType.Birth, collector: 'mother' }, isExact: true, @@ -89,7 +89,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth1234', - eventType: Event.Birth, + eventType: EventType.Birth, collector: 'mother' }, isExact: true, @@ -128,7 +128,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockDeath1234', - eventType: Event.Death, + eventType: EventType.Death, collector: 'informant' }, isExact: true, @@ -168,7 +168,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockBirth1234', - eventType: Event.Death, + eventType: EventType.Death, collector: 'father' }, isExact: true, @@ -251,7 +251,7 @@ describe('verify collector tests', () => { match={{ params: { registrationId: 'mockDeath1234', - eventType: Event.Death, + eventType: EventType.Death, collector: 'informant' }, isExact: true, diff --git a/packages/client/src/views/PrintCertificate/VerifyCollector.tsx b/packages/client/src/views/PrintCertificate/VerifyCollector.tsx index 5c4910a4b89..0489090a229 100644 --- a/packages/client/src/views/PrintCertificate/VerifyCollector.tsx +++ b/packages/client/src/views/PrintCertificate/VerifyCollector.tsx @@ -14,7 +14,7 @@ import { modifyDeclaration, writeDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { messages } from '@client/i18n/messages/views/certificate' import { formatUrl, @@ -51,7 +51,7 @@ import { getUserDetails } from '@client/profile/profileSelectors' interface IMatchParams { registrationId: string - eventType: Event + eventType: EventType collector: string } diff --git a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx index 32b2dbf0184..cab89be3fd6 100644 --- a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx +++ b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx @@ -25,7 +25,7 @@ import { CollectorForm } from './CollectorForm' import { waitFor, waitForElement } from '@client/tests/wait-for-element' import { createLocation, History } from 'history' import { merge } from 'lodash' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { storeDeclaration } from '@client/declarations' import { vi } from 'vitest' @@ -149,19 +149,19 @@ mockDeclarationData['history'] = declarationsHistory const birthDeclaration = { id: '6a5fd35d-01ec-4c37-976e-e055107a74a1', data: mockDeclarationData, - event: Event.Birth + event: EventType.Birth } const deathDeclaration = { id: '16ff35e1-3f92-4db3-b812-c402e609fb00', data: mockDeathDeclarationData, - event: Event.Death + event: EventType.Death } const marriageDeclaration = { id: '18ff35e1-3d92-4db3-b815-c4d2e609fb23', data: mockMarriageDeclarationData, - event: Event.Marriage + event: EventType.Marriage } beforeEach(() => { diff --git a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.tsx b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.tsx index 5fd9ae54470..4f1c3157359 100644 --- a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.tsx +++ b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.tsx @@ -30,7 +30,7 @@ import { IFormSectionData, IFormSectionGroup } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { getVisibleSectionGroupsBasedOnConditions } from '@client/forms/utils' import { getValidationErrorsForForm, @@ -85,7 +85,7 @@ const ErrorWrapper = styled.div` type PropsWhenDeclarationIsFound = { registerForm: IForm - event: Event + event: EventType pageRoute: string declarationId: string declaration: IPrintableDeclaration @@ -232,7 +232,7 @@ class CollectorFormComponent extends React.Component { declarationId: string, currentGroup: string, nextGroup: string | undefined, - event: Event, + event: EventType, sectionId: keyof IPrintableDeclaration['data'], fields: IFormField[], draft: IPrintableDeclaration | undefined @@ -318,7 +318,7 @@ class CollectorFormComponent extends React.Component { goToNextFormForSomeoneElse = ( declarationId: string, declaration: IPrintableDeclaration, - event: Event + event: EventType ) => { const { offlineCountryConfiguration } = this .props as PropsWhenDeclarationIsFound @@ -510,9 +510,9 @@ const mapStateToProps = ( const certFormSection = getCertificateCollectorFormSection(declaration) const isAllowPrintInAdvance = - event === Event.Birth + event === EventType.Birth ? getOfflineData(state).config.BIRTH.PRINT_IN_ADVANCE - : event === Event.Death + : event === EventType.Death ? getOfflineData(state).config.DEATH.PRINT_IN_ADVANCE : getOfflineData(state).config.MARRIAGE.PRINT_IN_ADVANCE diff --git a/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts b/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts index e69966f3389..b7b1f9bc538 100644 --- a/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts +++ b/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts @@ -11,8 +11,8 @@ import { WORKQUEUE_TABS } from '@client/components/interface/Navigation' import { IPrintableDeclaration, - SUBMISSION_STATUS, modifyDeclaration, + SUBMISSION_STATUS, writeDeclaration } from '@client/declarations' import { useDeclaration } from '@client/declarations/selectors' @@ -22,28 +22,28 @@ import { SubmissionAction } from '@client/forms' import { goToCertificateCorrection, goToHomeTab } from '@client/navigation' +import { AdminStructure, IOfflineData } from '@client/offline/reducer' import { getOfflineData } from '@client/offline/selectors' +import { printPDF } from '@client/pdfRenderer' import { getScope, getUserDetails } from '@client/profile/profileSelectors' import { IStoreState } from '@client/store' import { hasRegisterScope, hasRegistrationClerkScope } from '@client/utils/authUtils' +import { formatLongDate } from '@client/utils/date-formatting' +import { EventType } from '@client/utils/gateway' +import { getLocationHierarchy } from '@client/utils/locationUtils' +import { getUserName, UserDetails } from '@client/utils/userUtils' import { cloneDeep } from 'lodash' import { useDispatch, useSelector } from 'react-redux' import { addFontsToSvg, compileSvg, svgToPdfTemplate } from './PDFUtils' import { - isCertificateForPrintInAdvance, - getRegisteredDate, + calculatePrice, getEventDate, - calculatePrice + getRegisteredDate, + isCertificateForPrintInAdvance } from './utils' -import { Event } from '@client/utils/gateway' -import { getUserName, UserDetails } from '@client/utils/userUtils' -import { formatLongDate } from '@client/utils/date-formatting' -import { AdminStructure, IOfflineData } from '@client/offline/reducer' -import { getLocationHierarchy } from '@client/utils/locationUtils' -import { printPDF } from '@client/pdfRenderer' const withEnhancedTemplateVariables = ( declaration: IPrintableDeclaration | undefined, @@ -117,7 +117,7 @@ export const usePrintableCertificate = (declarationId: string) => { const dispatch = useDispatch() const scope = useSelector(getScope) const canUserEditRecord = - declaration?.event !== Event.Marriage && + declaration?.event !== EventType.Marriage && (hasRegisterScope(scope) || hasRegistrationClerkScope(scope)) let svg = undefined diff --git a/packages/client/src/views/PrintCertificate/utils.ts b/packages/client/src/views/PrintCertificate/utils.ts index d40371b1c3c..6b7c63dd745 100644 --- a/packages/client/src/views/PrintCertificate/utils.ts +++ b/packages/client/src/views/PrintCertificate/utils.ts @@ -8,15 +8,15 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import { IPrintableDeclaration } from '@client/declarations' import { IFormData, IFormSectionGroup, ISelectOption } from '@client/forms' -import { Event } from '@client/utils/gateway' import { dynamicMessages } from '@client/i18n/messages/views/certificate' -import { getAvailableLanguages } from '@client/i18n/utils' import { ILanguageState } from '@client/i18n/reducer' -import { IPrintableDeclaration } from '@client/declarations' -import { IntlShape } from 'react-intl' +import { getAvailableLanguages } from '@client/i18n/utils' import { IOfflineData } from '@client/offline/reducer' +import { EventType } from '@client/utils/gateway' import differenceInDays from 'date-fns/differenceInDays' +import { IntlShape } from 'react-intl' const MONTH_IN_DAYS = 30 const YEAR_IN_DAYS = 365 @@ -58,7 +58,7 @@ export function getCountryTranslations( } interface IDayRange { - rangeData: { [key in Event]?: IRange[] } + rangeData: { [key in EventType]?: IRange[] } } function getDayRanges(offlineData: IOfflineData): IDayRange { @@ -104,16 +104,16 @@ function getDayRanges(offlineData: IOfflineData): IDayRange { return { rangeData: { - [Event.Birth]: birthRanges, - [Event.Death]: deathRanges, - [Event.Marriage]: marriageRanges + [EventType.Birth]: birthRanges, + [EventType.Death]: deathRanges, + [EventType.Marriage]: marriageRanges } } } function getValue( offlineData: IOfflineData, - event: Event, + event: EventType, check: number ): IRange['value'] { const rangeByEvent = getDayRanges(offlineData).rangeData[event] as IRange[] @@ -159,7 +159,7 @@ export function timeElapsed(days: number) { } export function calculatePrice( - event: Event, + event: EventType, eventDate: string, registeredDate: string, offlineData: IOfflineData @@ -171,14 +171,14 @@ export function calculatePrice( export function getServiceMessage( intl: IntlShape, - event: Event, + event: EventType, eventDate: string, registeredDate: string, offlineData: IOfflineData ) { const days = calculateDays(eventDate, registeredDate) - if (event === Event.Birth) { + if (event === EventType.Birth) { if (days <= offlineData.config.BIRTH.REGISTRATION_TARGET) { return intl.formatMessage(dynamicMessages[`${event}ServiceBefore`], { target: offlineData.config.BIRTH.REGISTRATION_TARGET @@ -196,7 +196,7 @@ export function getServiceMessage( target: offlineData.config.BIRTH.LATE_REGISTRATION_TARGET }) } - } else if (event === Event.Death) { + } else if (event === EventType.Death) { if (days <= offlineData.config.DEATH.REGISTRATION_TARGET) { return intl.formatMessage(dynamicMessages[`${event}ServiceBefore`], { target: offlineData.config.DEATH.REGISTRATION_TARGET @@ -206,7 +206,7 @@ export function getServiceMessage( target: offlineData.config.DEATH.REGISTRATION_TARGET }) } - } else if (event === Event.Marriage) { + } else if (event === EventType.Marriage) { if (days <= offlineData.config.DEATH.REGISTRATION_TARGET) { return intl.formatMessage(dynamicMessages[`${event}ServiceBefore`], { target: offlineData.config.MARRIAGE.REGISTRATION_TARGET @@ -220,7 +220,7 @@ export function getServiceMessage( } export function isFreeOfCost( - event: Event, + event: EventType, eventDate: string, registeredDate: string, offlineData: IOfflineData @@ -230,13 +230,13 @@ export function isFreeOfCost( return result === 0 } -export function getEventDate(data: IFormData, event: Event) { +export function getEventDate(data: IFormData, event: EventType) { switch (event) { - case Event.Birth: + case EventType.Birth: return data.child.childBirthDate as string - case Event.Death: + case EventType.Death: return data.deathEvent.deathDate as string - case Event.Marriage: + case EventType.Marriage: return data.marriageEvent.marriageDate as string } } @@ -253,11 +253,11 @@ export function getEvent(eventType: string | undefined) { switch (eventType && eventType.toLowerCase()) { case 'birth': default: - return Event.Birth + return EventType.Birth case 'death': - return Event.Death + return EventType.Death case 'marriage': - return Event.Marriage + return EventType.Marriage } } diff --git a/packages/client/src/views/PrintRecord/Body.tsx b/packages/client/src/views/PrintRecord/Body.tsx index 5f2f00d6e60..f66b9cb5075 100644 --- a/packages/client/src/views/PrintRecord/Body.tsx +++ b/packages/client/src/views/PrintRecord/Body.tsx @@ -76,7 +76,7 @@ import { getRegisterForm } from '@client/forms/register/declaration-selectors' import { messages as reviewMessages } from '@client/i18n/messages/views/review' import { Checkbox, Stack } from '@opencrvs/components/lib' import { printRecordMessages } from '@client/i18n/messages/views/printRecord' -import { Event, History, RegStatus } from '@client/utils/gateway' +import { EventType, History, RegStatus } from '@client/utils/gateway' import { createNamesMap } from '@client/utils/data-formatting' import { PrintRecordTable as Table } from '@client/views/PrintRecord/Table' import { getUserDetails } from '@client/profile/profileSelectors' @@ -821,7 +821,7 @@ export function PrintRecordBody(props: PrintRecordTableProps) { offlineCountryConfiguration ).filter((sec) => sec.items.length > 0) function renderSignatureBox() { - if (props.declaration.event === Event.Marriage) { + if (props.declaration.event === EventType.Marriage) { return ( @@ -943,7 +943,7 @@ export function PrintRecordBody(props: PrintRecordTableProps) { .filter(({ id }) => id === 'informant') .map((section, idx) => { const items = - props.declaration.event === Event.Marriage + props.declaration.event === EventType.Marriage ? [ ...section.items.map((item) => ({ data: [ diff --git a/packages/client/src/views/PrintRecord/utils.ts b/packages/client/src/views/PrintRecord/utils.ts index 72517c381a3..e2c329b47b7 100644 --- a/packages/client/src/views/PrintRecord/utils.ts +++ b/packages/client/src/views/PrintRecord/utils.ts @@ -11,8 +11,8 @@ import { ILanguageState } from '@client/i18n/reducer' import { ILocation, IOfflineData } from '@client/offline/reducer' -import { Event } from '@client/utils/gateway' -import { createIntl, MessageDescriptor, IntlShape, IntlCache } from 'react-intl' +import { EventType } from '@client/utils/gateway' +import { createIntl, IntlCache, IntlShape, MessageDescriptor } from 'react-intl' export function formatMessage( intls: IntlShape[], @@ -55,10 +55,10 @@ export function getLocationHierarchy( } } -export function getEventwiseSubjectColor(event: Event) { - if (event === Event.Death) { +export function getEventwiseSubjectColor(event: EventType) { + if (event === EventType.Death) { return 'subheaderCopyDeath' - } else if (event === Event.Marriage) { + } else if (event === EventType.Marriage) { return 'subheaderCopyMarriage' } else { return 'subheaderCopyBirth' diff --git a/packages/client/src/views/RecordAudit/ActionMenu.test.tsx b/packages/client/src/views/RecordAudit/ActionMenu.test.tsx index da5890834d0..17d8de94510 100644 --- a/packages/client/src/views/RecordAudit/ActionMenu.test.tsx +++ b/packages/client/src/views/RecordAudit/ActionMenu.test.tsx @@ -20,13 +20,13 @@ import { } from '@client/declarations' import { ActionMenu } from './ActionMenu' import { Scope } from '@sentry/react' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { vi } from 'vitest' const defaultDeclaration = { id: '65c48a2b-68dd-4a7e-8868-d2bb1fd27844', name: 'Elissabe Sandrava', - type: Event.Birth, + type: EventType.Birth, status: SUBMISSION_STATUS.REGISTERED, assignment: { practitionerId: '73da21a1-4b8b-4174-83ca-122d829cb6ec', @@ -45,7 +45,7 @@ const defaultDeclaration = { const draftBirthDownloaded = { id: '65c48a2b-68dd-4a7e-8868-d2bb1fd27844', data: {}, - event: Event.Birth, + event: EventType.Birth, action: 'load declaration data for review', downloadStatus: DOWNLOAD_STATUS.DOWNLOADED } as unknown as IDeclaration @@ -53,7 +53,7 @@ const draftBirthDownloaded = { const draftDeathDownloaded = { id: '65c48a2b-68dd-4a7e-8868-d2bb1fd27844', data: {}, - event: Event.Death, + event: EventType.Death, action: 'load declaration data for review', downloadStatus: DOWNLOAD_STATUS.DOWNLOADED } as unknown as IDeclaration @@ -61,7 +61,7 @@ const draftDeathDownloaded = { const draftBirthNotDownloaded = { id: '65c48a2b-68dd-4a7e-8868-d2bb1fd27844', data: {}, - event: Event.Birth, + event: EventType.Birth, action: 'load declaration data for review', downloadStatus: DOWNLOAD_STATUS.READY_TO_DOWNLOAD } as unknown as IDeclaration @@ -69,7 +69,7 @@ const draftBirthNotDownloaded = { const draftDeathNotDownloaded = { id: '65c48a2b-68dd-4a7e-8868-d2bb1fd27844', data: {}, - event: Event.Death, + event: EventType.Death, action: 'load declaration data for review', downloadStatus: DOWNLOAD_STATUS.READY_TO_DOWNLOAD } as unknown as IDeclaration diff --git a/packages/client/src/views/RecordAudit/ActionMenu.tsx b/packages/client/src/views/RecordAudit/ActionMenu.tsx index 729e4495d08..a6f9cedaef2 100644 --- a/packages/client/src/views/RecordAudit/ActionMenu.tsx +++ b/packages/client/src/views/RecordAudit/ActionMenu.tsx @@ -9,27 +9,6 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import React from 'react' -import { DropdownMenu } from '@opencrvs/components/lib/Dropdown' -import { - DangerButton, - PrimaryButton, - TertiaryButton -} from '@opencrvs/components/lib/buttons' -import { CaretDown } from '@opencrvs/components/lib/Icon/all-icons' -import { useDispatch } from 'react-redux' -import { Icon, ResponsiveModal } from '@opencrvs/components' -import { - goToCertificateCorrection, - goToHome, - goToIssueCertificate, - goToPage, - goToPrintCertificate, - goToViewRecordPage -} from '@client/navigation' -import { useIntl } from 'react-intl' -import { Scope } from '@sentry/react' -import { IDeclarationData } from './utils' import { clearCorrectionAndPrintChanges, deleteDeclaration, @@ -38,21 +17,6 @@ import { SUBMISSION_STATUS, unassignDeclaration } from '@client/declarations' -import { CorrectionSection } from '@client/forms' -import { buttonMessages } from '@client/i18n/messages' -import { - DRAFT_BIRTH_PARENT_FORM_PAGE, - DRAFT_DEATH_FORM_PAGE, - DRAFT_MARRIAGE_FORM_PAGE, - REVIEW_CORRECTION, - REVIEW_EVENT_PARENT_FORM_PAGE -} from '@client/navigation/routes' -import { messages } from '@client/i18n/messages/views/action' -import { useModal } from '@client/hooks/useModal' -import { DeleteModal } from '@client/views/RegisterForm/RegisterForm' -import { client } from '@client/utils/apolloClient' -import { conflictsMessages } from '@client/i18n/messages/views/conflicts' -import { GQLAssignmentData } from '@client/utils/gateway-deprecated-do-not-use' import { canBeCorrected, isArchivable, @@ -64,7 +28,44 @@ import { isReviewableDeclaration, isUpdatableDeclaration } from '@client/declarations/utils' +import { CorrectionSection } from '@client/forms' +import { useModal } from '@client/hooks/useModal' +import { buttonMessages } from '@client/i18n/messages' +import { messages } from '@client/i18n/messages/views/action' +import { conflictsMessages } from '@client/i18n/messages/views/conflicts' +import { + goToCertificateCorrection, + goToHome, + goToIssueCertificate, + goToPage, + goToPrintCertificate, + goToViewRecordPage +} from '@client/navigation' +import { + DRAFT_BIRTH_PARENT_FORM_PAGE, + DRAFT_DEATH_FORM_PAGE, + DRAFT_MARRIAGE_FORM_PAGE, + REVIEW_CORRECTION, + REVIEW_EVENT_PARENT_FORM_PAGE +} from '@client/navigation/routes' +import { client } from '@client/utils/apolloClient' +import { EventType } from '@client/utils/gateway' +import { GQLAssignmentData } from '@client/utils/gateway-deprecated-do-not-use' +import { DeleteModal } from '@client/views/RegisterForm/RegisterForm' import { EVENT } from '@opencrvs/commons/client' +import { Icon, ResponsiveModal } from '@opencrvs/components' +import { + DangerButton, + PrimaryButton, + TertiaryButton +} from '@opencrvs/components/lib/buttons' +import { DropdownMenu } from '@opencrvs/components/lib/Dropdown' +import { CaretDown } from '@opencrvs/components/lib/Icon/all-icons' +import { Scope } from '@sentry/react' +import React from 'react' +import { useIntl } from 'react-intl' +import { useDispatch } from 'react-redux' +import { IDeclarationData } from './utils' export const ActionMenu: React.FC<{ declaration: IDeclarationData scope: Scope @@ -238,7 +239,7 @@ const CorrectRecordAction: React.FC< const intl = useIntl() const isBirthOrDeathEvent = - type && [EVENT.BIRTH, EVENT.DEATH].includes(type as EVENT) + type && [EventType.Birth, EventType.Death].includes(type as EventType) // @ToDo use: `record.registration-correct` after configurable role pr is merged const userHasRegisterScope = diff --git a/packages/client/src/views/RecordAudit/RecordAudit.test.tsx b/packages/client/src/views/RecordAudit/RecordAudit.test.tsx index 78eff975f4f..cd4e8c289cf 100644 --- a/packages/client/src/views/RecordAudit/RecordAudit.test.tsx +++ b/packages/client/src/views/RecordAudit/RecordAudit.test.tsx @@ -27,7 +27,7 @@ import { storeDeclaration, IDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { formatUrl } from '@client/navigation' import { DECLARATION_RECORD_AUDIT } from '@client/navigation/routes' import type { GQLBirthEventSearchSet } from '@client/utils/gateway-deprecated-do-not-use' @@ -35,7 +35,7 @@ import { FETCH_DECLARATION_SHORT_INFO } from './queries' import { waitForElement } from '@client/tests/wait-for-element' const declaration: IDeclaration = createDeclaration( - Event.Birth, + EventType.Birth, mockDeclarationData ) declaration.data.registration = { @@ -115,7 +115,7 @@ describe('Record audit summary for a draft death declaration', () => { beforeEach(async () => { const { store, history } = createStore() const deathDeclaration = createDeclaration( - Event.Death, + EventType.Death, mockDeathDeclarationData ) @@ -164,7 +164,7 @@ describe('Record audit summary for a draft marriage declaration', () => { beforeEach(async () => { const { store, history } = createStore() const marriageDeclaration = createDeclaration( - Event.Marriage, + EventType.Marriage, mockMarriageDeclarationData ) @@ -216,7 +216,7 @@ describe('Record audit summary for WorkQueue declarations', () => { store.getState().workqueueState.workqueue.data.inProgressTab.results = [ { id: 'db097901-feba-4f71-a1ae-d3d46289d2d5', - type: Event.Birth, + type: EventType.Birth, registration: { status: 'DRAFT', contactNumber: '+8801622688231', diff --git a/packages/client/src/views/RecordAudit/RecordAudit.tsx b/packages/client/src/views/RecordAudit/RecordAudit.tsx index 3d5824402c5..7c6d6f19320 100644 --- a/packages/client/src/views/RecordAudit/RecordAudit.tsx +++ b/packages/client/src/views/RecordAudit/RecordAudit.tsx @@ -73,7 +73,7 @@ import { getLanguage } from '@client/i18n/selectors' import { MarkEventAsReinstatedMutation, MarkEventAsReinstatedMutationVariables, - Event, + EventType, History } from '@client/utils/gateway' import { get } from 'lodash' @@ -212,7 +212,7 @@ function ReinstateButton({ MarkEventAsReinstatedMutationVariables > mutation={ - declaration.event === Event.Birth + declaration.event === EventType.Birth ? REINSTATE_BIRTH_DECLARATION : REINSTATE_DEATH_DECLARATION } @@ -338,7 +338,7 @@ function RecordAuditBody({ const eventType = declaration.type if (eventType in registerForm.registerForm) regForm = get(registerForm.registerForm, eventType) - else regForm = registerForm.registerForm[Event.Birth] + else regForm = registerForm.registerForm[EventType.Birth] const actionDetailsModalProps = { show: showActionDetails, diff --git a/packages/client/src/views/RecordAudit/utils.ts b/packages/client/src/views/RecordAudit/utils.ts index 5abb838320e..bcb09097f0e 100644 --- a/packages/client/src/views/RecordAudit/utils.ts +++ b/packages/client/src/views/RecordAudit/utils.ts @@ -8,47 +8,47 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { IFormField, IRadioGroupFormField, ISelectOption } from '@client/forms' -import { IOfflineData } from '@client/offline/reducer' -import { get, has, PropertyPath } from 'lodash' -import { IntlShape } from 'react-intl' import { IDeclaration, SUBMISSION_STATUS } from '@client/declarations' -import { - generateLocationName, - generateFullLocation -} from '@client/utils/locationUtils' -import type { - GQLEventSearchSet, - GQLBirthEventSearchSet, - GQLDeathEventSearchSet, - GQLHumanName, - GQLAssignmentData, - GQLMarriageEventSearchSet -} from '@client/utils/gateway-deprecated-do-not-use' -import { createNamesMap } from '@client/utils/data-formatting' -import { IDynamicValues } from '@client/navigation' +import { IFormField, IRadioGroupFormField, ISelectOption } from '@client/forms' import { countryMessages } from '@client/i18n/messages/constants' import { recordAuditMessages, regActionMessages, regStatusMessages } from '@client/i18n/messages/views/recordAudit' +import { IDynamicValues } from '@client/navigation' +import { IOfflineData } from '@client/offline/reducer' import { EMPTY_STRING, FIELD_AGENT_ROLES, LANG_EN } from '@client/utils/constants' +import { createNamesMap } from '@client/utils/data-formatting' +import { getDeclarationFullName } from '@client/utils/draftUtils' import { - Event, + EventType, + History, + HumanName, Maybe, RegAction, RegStatus, - User, - History, - HumanName + User } from '@client/utils/gateway' +import type { + GQLAssignmentData, + GQLBirthEventSearchSet, + GQLDeathEventSearchSet, + GQLEventSearchSet, + GQLHumanName, + GQLMarriageEventSearchSet +} from '@client/utils/gateway-deprecated-do-not-use' +import { + generateFullLocation, + generateLocationName +} from '@client/utils/locationUtils' import { UserDetails } from '@client/utils/userUtils' -import { getDeclarationFullName } from '@client/utils/draftUtils' +import { get, has, PropertyPath } from 'lodash' +import { IntlShape } from 'react-intl' export interface IDeclarationData { id: string @@ -145,7 +145,7 @@ const getLocation = ( let internationalDistrict = EMPTY_STRING let internationalState = EMPTY_STRING let country = EMPTY_STRING - if (declaration.event === Event.Death) { + if (declaration.event === EventType.Death) { locationType = declaration.data?.deathEvent?.placeOfDeath?.toString() || EMPTY_STRING @@ -169,7 +169,7 @@ const getLocation = ( internationalState = declaration.data?.deathEvent?.internationalStatePlaceofdeath?.toString() || EMPTY_STRING - } else if (declaration.event === Event.Birth) { + } else if (declaration.event === EventType.Birth) { locationType = declaration.data?.child?.placeOfBirth?.toString() || EMPTY_STRING locationId = @@ -189,7 +189,7 @@ const getLocation = ( internationalState = declaration.data?.child?.internationalStatePlaceofbirth?.toString() || EMPTY_STRING - } else if (declaration.event === Event.Marriage) { + } else if (declaration.event === EventType.Marriage) { district = declaration.data?.marriageEvent?.districtPlaceofmarriage?.toString() || EMPTY_STRING @@ -309,19 +309,19 @@ export const removeUnderscore = (word: string): string => { const isBirthDeclaration = ( declaration: GQLEventSearchSet | null ): declaration is GQLBirthEventSearchSet => { - return (declaration && declaration.type === Event.Birth) || false + return (declaration && declaration.type === EventType.Birth) || false } const isDeathDeclaration = ( declaration: GQLEventSearchSet | null ): declaration is GQLDeathEventSearchSet => { - return (declaration && declaration.type === Event.Death) || false + return (declaration && declaration.type === EventType.Death) || false } const isMarriageDeclaration = ( declaration: GQLEventSearchSet | null ): declaration is GQLMarriageEventSearchSet => { - return (declaration && declaration.type === Event.Marriage) || false + return (declaration && declaration.type === EventType.Marriage) || false } export const getName = (names: (HumanName | null)[], language: string) => { diff --git a/packages/client/src/views/RegisterForm/DeclarationForm.test.tsx b/packages/client/src/views/RegisterForm/DeclarationForm.test.tsx index 25eb56f03a1..34074ec538a 100644 --- a/packages/client/src/views/RegisterForm/DeclarationForm.test.tsx +++ b/packages/client/src/views/RegisterForm/DeclarationForm.test.tsx @@ -31,7 +31,7 @@ import { ReactWrapper } from 'enzyme' import { History } from 'history' import { Store } from 'redux' import { storage } from '@client/storage' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { waitForElement } from '@client/tests/wait-for-element' import { vi, Mock } from 'vitest' import { DRAFT_BIRTH_PARENT_FORM } from '@client/navigation/routes' @@ -66,7 +66,7 @@ describe('when user has starts a new declaration', () => { history = testApp.history store = testApp.store - draft = createDeclaration(Event.Birth) + draft = createDeclaration(EventType.Birth) await store.dispatch(storeDeclaration(draft)) }) @@ -105,7 +105,7 @@ describe('when user has starts a new declaration', () => { } } } - draft = createDeclaration(Event.Birth, data) + draft = createDeclaration(EventType.Birth, data) /* * Needs to be done before storeDeclaration(draft) diff --git a/packages/client/src/views/RegisterForm/DeclarationForm.tsx b/packages/client/src/views/RegisterForm/DeclarationForm.tsx index 90b98257cf0..226043b60da 100644 --- a/packages/client/src/views/RegisterForm/DeclarationForm.tsx +++ b/packages/client/src/views/RegisterForm/DeclarationForm.tsx @@ -23,7 +23,7 @@ import { getRegisterForm } from '@opencrvs/client/src/forms/register/declaration import { IStoreState } from '@opencrvs/client/src/store' import { connect } from 'react-redux' import { IForm } from '@client/forms' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { IDeclaration } from '@client/declarations' import { Redirect } from 'react-router-dom' @@ -34,7 +34,7 @@ interface IFormProps { duplicate?: boolean } -const pageRoute: { [key in Event]: string } = { +const pageRoute: { [key in EventType]: string } = { birth: DRAFT_BIRTH_PARENT_FORM_PAGE_GROUP, death: DRAFT_DEATH_FORM_PAGE_GROUP, marriage: DRAFT_MARRIAGE_FORM_PAGE_GROUP @@ -54,7 +54,7 @@ function mapStatetoProps(state: IStoreState, props: RouteProps) { ({ id }) => id === match.params.declarationId ) - const event = declaration?.event || Event.Birth + const event = declaration?.event || EventType.Birth const registerForm = getRegisterForm(state)[event] return { diff --git a/packages/client/src/views/RegisterForm/PreviewForm.test.tsx b/packages/client/src/views/RegisterForm/PreviewForm.test.tsx index 808945efa0b..4a13bd9ecd9 100644 --- a/packages/client/src/views/RegisterForm/PreviewForm.test.tsx +++ b/packages/client/src/views/RegisterForm/PreviewForm.test.tsx @@ -32,7 +32,7 @@ import { import { ReactWrapper } from 'enzyme' import { History } from 'history' import { Store } from 'redux' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { v4 as uuid } from 'uuid' // eslint-disable-next-line no-restricted-imports import * as ReactApollo from '@apollo/client/react' @@ -71,7 +71,7 @@ describe('when user is previewing the form data', () => { await flushPromises() const data = deathReviewDraftData - customDraft = { id: uuid(), data, review: true, event: Event.Death } + customDraft = { id: uuid(), data, review: true, event: EventType.Death } store.dispatch(storeDeclaration(customDraft)) history.replace( REVIEW_EVENT_PARENT_FORM_PAGE.replace( @@ -121,7 +121,7 @@ describe('when user is previewing the form data', () => { customDraft = { id: uuid(), data, - event: Event.Birth, + event: EventType.Birth, submissionStatus: SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] } store.dispatch(storeDeclaration(customDraft)) @@ -177,7 +177,7 @@ describe('when user is previewing the form data', () => { await flushPromises() const data = birthReviewDraftData - customDraft = { id: uuid(), data, review: true, event: Event.Birth } + customDraft = { id: uuid(), data, review: true, event: EventType.Birth } store.dispatch(storeDeclaration(customDraft)) history.replace( REVIEW_EVENT_PARENT_FORM_PAGE.replace( @@ -223,7 +223,12 @@ describe('when user is previewing the form data', () => { await flushPromises() const data = marriageReviewDraftData - customDraft = { id: uuid(), data, review: true, event: Event.Marriage } + customDraft = { + id: uuid(), + data, + review: true, + event: EventType.Marriage + } store.dispatch(storeDeclaration(customDraft)) history.replace( REVIEW_EVENT_PARENT_FORM_PAGE.replace( @@ -270,7 +275,7 @@ describe('when user is previewing the form data', () => { ...mockDeclarationData } - const customDraft = createReviewDeclaration(uuid(), data, Event.Birth) + const customDraft = createReviewDeclaration(uuid(), data, EventType.Birth) customDraft.submissionStatus = SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] store.dispatch(storeDeclaration(customDraft)) diff --git a/packages/client/src/views/RegisterForm/RegisterForm.init.test.tsx b/packages/client/src/views/RegisterForm/RegisterForm.init.test.tsx index 4fb88d0ac09..fcd8c495a3a 100644 --- a/packages/client/src/views/RegisterForm/RegisterForm.init.test.tsx +++ b/packages/client/src/views/RegisterForm/RegisterForm.init.test.tsx @@ -27,14 +27,14 @@ import { import { DRAFT_BIRTH_PARENT_FORM_PAGE } from '@opencrvs/client/src/navigation/routes' import { vi } from 'vitest' -import { Event, SystemRoleType, Status } from '@client/utils/gateway' +import { EventType, SystemRoleType, Status } from '@client/utils/gateway' import { storage } from '@client/storage' import { UserDetails } from '@client/utils/userUtils' describe('when user logs in', () => { // Some mock data - const draft1 = createDeclaration(Event.Birth) - const draft2 = createDeclaration(Event.Death) - const draft3 = createDeclaration(Event.Birth) + const draft1 = createDeclaration(EventType.Birth) + const draft2 = createDeclaration(EventType.Death) + const draft3 = createDeclaration(EventType.Birth) const currentUserData: IUserData = { userID: 'shakib75', @@ -126,7 +126,7 @@ describe('when user logs in', () => { let draft: IDeclaration beforeAll(async () => { - draft = createDeclaration(Event.Death) + draft = createDeclaration(EventType.Death) vi.mock('lodash/debounce', () => vi.fn((fn) => fn)) const { store } = await createTestStore() await writeDeclarationByUser( @@ -188,8 +188,8 @@ describe('when user is in the register form before initial draft load', () => { const { store, history } = await createTestStore() const mock: any = vi.fn() - const draft = createDeclaration(Event.Birth) - const form = await getRegisterFormFromStore(store, Event.Birth) + const draft = createDeclaration(EventType.Birth) + const form = await getRegisterFormFromStore(store, EventType.Birth) try { await createTestComponent( diff --git a/packages/client/src/views/RegisterForm/RegisterForm.test.tsx b/packages/client/src/views/RegisterForm/RegisterForm.test.tsx index 1a18d61be2f..57be0bf36f4 100644 --- a/packages/client/src/views/RegisterForm/RegisterForm.test.tsx +++ b/packages/client/src/views/RegisterForm/RegisterForm.test.tsx @@ -43,7 +43,7 @@ import { DRAFT_MARRIAGE_FORM_PAGE } from '@opencrvs/client/src/navigation/routes' import { IFormData } from '@opencrvs/client/src/forms' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { draftToGqlTransformer } from '@client/transformer' import { IForm } from '@client/forms' import { clone, cloneDeep } from 'lodash' @@ -69,13 +69,13 @@ describe('when user is in the register form for birth event', () => { history = storeContext.history client = createClient(store) - const draft = createDeclaration(Event.Birth) + const draft = createDeclaration(EventType.Birth) store.dispatch(storeDeclaration(draft)) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) const mock: any = vi.fn() - const form = await getRegisterFormFromStore(store, Event.Birth) + const form = await getRegisterFormFromStore(store, EventType.Birth) const testComponent = await createTestComponent( // @ts-ignore { store = testStore.store history = testStore.history - draft = createDeclaration(Event.Death) + draft = createDeclaration(EventType.Death) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) - form = await getRegisterFormFromStore(store, Event.Death) + form = await getRegisterFormFromStore(store, EventType.Death) }) describe('when user is in optional cause of death section', () => { beforeEach(async () => { @@ -203,10 +203,10 @@ describe('when user is in the register form for marriage event', () => { store = testStore.store history = testStore.history - draft = createDeclaration(Event.Marriage) + draft = createDeclaration(EventType.Marriage) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) - form = await getRegisterFormFromStore(store, Event.Marriage) + form = await getRegisterFormFromStore(store, EventType.Marriage) }) describe('when user is in marriage section', () => { @@ -260,7 +260,7 @@ describe('when user is in the register form preview section', () => { store = storeContext.store history = storeContext.history - const draft = createDeclaration(Event.Birth) + const draft = createDeclaration(EventType.Birth) draft.data = { child: { firstNamesEng: 'John', familyNameEng: 'Doe' }, father: { @@ -285,7 +285,7 @@ describe('when user is in the register form preview section', () => { store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) - const form = await getRegisterFormFromStore(store, Event.Birth) + const form = await getRegisterFormFromStore(store, EventType.Birth) const testComponent = await createTestComponent( // @ts-ignore { const nDeclaration = createReviewDeclaration( uuid(), mockDeclarationData, - Event.Birth + EventType.Birth ) nDeclaration.submissionStatus = SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(nDeclaration)) - const nform = getRegisterForm(store.getState())[Event.Birth] + const nform = getRegisterForm(store.getState())[EventType.Birth] const nTestComponent = await createTestComponent( // @ts-ignore { const declaration = createReviewDeclaration( uuid(), mockDeclarationData, - Event.Birth + EventType.Birth ) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(declaration)) const mock: any = vi.fn() vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['register']) - const form = await getReviewFormFromStore(store, Event.Birth) + const form = await getReviewFormFromStore(store, EventType.Birth) const testComponent = await createTestComponent( // @ts-ignore @@ -443,14 +443,14 @@ describe('when user is in the register form from review edit', () => { const declaration = createReviewDeclaration( uuid(), mockDeclarationData, - Event.Birth + EventType.Birth ) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(declaration)) const mock: any = vi.fn() vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['register']) - const form = await getReviewFormFromStore(store, Event.Birth) + const form = await getReviewFormFromStore(store, EventType.Birth) const testComponent = await createTestComponent( // @ts-ignore @@ -496,7 +496,7 @@ describe('when user is in the register form from sent for review edit', () => { const declaration = createReviewDeclaration( uuid(), mockDeclarationData, - Event.Birth, + EventType.Birth, RegStatus.Declared ) store.dispatch(setInitialDeclarations()) @@ -504,7 +504,7 @@ describe('when user is in the register form from sent for review edit', () => { const mock: any = vi.fn() vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['register']) - const form = await getReviewFormFromStore(store, Event.Birth) + const form = await getReviewFormFromStore(store, EventType.Birth) const testComponent = await createTestComponent( // @ts-ignore @@ -587,7 +587,7 @@ describe('When user is in Preview section death event', () => { store = testStore.store history = testStore.history - const draft = createDeclaration(Event.Death) + const draft = createDeclaration(EventType.Death) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) vi.clearAllMocks() @@ -596,7 +596,7 @@ describe('When user is in Preview section death event', () => { uuid(), // @ts-ignore mockDeathDeclarationData, - Event.Death + EventType.Death ) deathDraft.submissionStatus = SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] store.dispatch(setInitialDeclarations()) @@ -604,7 +604,7 @@ describe('When user is in Preview section death event', () => { vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['declare']) - deathForm = await getRegisterFormFromStore(store, Event.Death) + deathForm = await getRegisterFormFromStore(store, EventType.Death) const nTestComponent = await createTestComponent( // @ts-ignore { history = testStore.history store = testStore.store - const draft = createDeclaration(Event.Death) + const draft = createDeclaration(EventType.Death) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) @@ -747,13 +747,13 @@ describe('When user is in Preview section death event in offline mode', () => { uuid(), // @ts-ignore mockDeathDeclarationData, - Event.Death + EventType.Death ) deathDraft.submissionStatus = SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(deathDraft)) - deathForm = await getRegisterFormFromStore(store, Event.Death) + deathForm = await getRegisterFormFromStore(store, EventType.Death) const nTestComponent = await createTestComponent( // @ts-ignore { store = testStore.store history = testStore.history - const draft = createDeclaration(Event.Death) + const draft = createDeclaration(EventType.Death) store.dispatch(setInitialDeclarations()) store.dispatch(storeDeclaration(draft)) vi.clearAllMocks() @@ -815,7 +815,7 @@ describe('When user is in Preview section marriage event', () => { uuid(), // @ts-ignore mockDeathDeclarationData, - Event.Marriage + EventType.Marriage ) marriageDraft.submissionStatus = SUBMISSION_STATUS[SUBMISSION_STATUS.DRAFT] store.dispatch(setInitialDeclarations()) @@ -823,7 +823,7 @@ describe('When user is in Preview section marriage event', () => { vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['declare']) - marriageForm = await getRegisterFormFromStore(store, Event.Marriage) + marriageForm = await getRegisterFormFromStore(store, EventType.Marriage) const nTestComponent = await createTestComponent( // @ts-ignore theme.colors.primary}; @@ -260,7 +260,8 @@ function FormAppBar({ duplicate, modifyDeclarationMethod, deleteDeclarationMethod, - printDeclarationMethod + printDeclarationMethod, + canSaveAndExit }: { duplicate: boolean | undefined section: IFormSection @@ -268,6 +269,7 @@ function FormAppBar({ modifyDeclarationMethod: (declration: IDeclaration) => void deleteDeclarationMethod: (declration: IDeclaration) => void printDeclarationMethod: (declarationId: string) => void + canSaveAndExit: boolean }) { const intl = useIntl() const dispatch = useDispatch() @@ -551,6 +553,7 @@ function FormAppBar({ id="save-exit-btn" type="primary" size="small" + disabled={!canSaveAndExit} onClick={handleSaveAndExit} > @@ -609,7 +612,12 @@ function FormAppBar({ mobileRight={ <> {!isCorrection(declaration) && ( - )} @@ -856,13 +864,13 @@ class RegisterFormView extends React.Component { const eventType = this.props.declaration.event || 'BIRTH' switch (eventType.toLocaleLowerCase()) { case 'birth': - return Event.Birth + return EventType.Birth case 'death': - return Event.Death + return EventType.Death case 'marriage': - return Event.Marriage + return EventType.Marriage default: - return Event.Birth + return EventType.Birth } } @@ -1047,6 +1055,7 @@ class RegisterFormView extends React.Component { modifyDeclarationMethod={this.props.modifyDeclaration} deleteDeclarationMethod={this.onDeleteDeclaration} printDeclarationMethod={this.props.goToPrintRecord} + canSaveAndExit={canContinue} /> } key={activeSection.id} diff --git a/packages/client/src/views/RegisterForm/ReviewForm.test.tsx b/packages/client/src/views/RegisterForm/ReviewForm.test.tsx index 3dc10d58689..df33326f66d 100644 --- a/packages/client/src/views/RegisterForm/ReviewForm.test.tsx +++ b/packages/client/src/views/RegisterForm/ReviewForm.test.tsx @@ -16,7 +16,7 @@ import { storeDeclaration } from '@opencrvs/client/src/declarations' import { IForm, IFormSectionData } from '@opencrvs/client/src/forms' -import { Event, RegStatus } from '@client/utils/gateway' +import { EventType, RegStatus } from '@client/utils/gateway' import { REVIEW_EVENT_PARENT_FORM_PAGE } from '@opencrvs/client/src/navigation/routes' import { checkAuth } from '@opencrvs/client/src/profile/profileActions' import { RegisterForm } from '@opencrvs/client/src/views/RegisterForm/RegisterForm' @@ -153,7 +153,7 @@ const birthDeclaration: IDeclaration = { }, originalData: mockDeclarationData, review: true, - event: Event.Birth, + event: EventType.Birth, registrationStatus: RegStatus.Registered, downloadStatus: DOWNLOAD_STATUS.DOWNLOADED, modifiedOn: 1644407705186, @@ -221,7 +221,7 @@ const deathDeclaration: IDeclaration = { }, originalData: mockDeathDeclarationData, review: true, - event: Event.Death, + event: EventType.Death, registrationStatus: RegStatus.Registered, downloadStatus: DOWNLOAD_STATUS.DOWNLOADED, modifiedOn: 1644490181166, @@ -265,7 +265,7 @@ describe('ReviewForm tests', () => { store = testStore.store history = testStore.history - form = await getReviewFormFromStore(store, Event.Birth) + form = await getReviewFormFromStore(store, EventType.Birth) getItem.mockReturnValue(registerScopeToken) store.dispatch(checkAuth()) }) @@ -409,7 +409,7 @@ describe('ReviewForm tests', () => { const declaration = createReviewDeclaration( uuid(), birthDraftData, - Event.Birth, + EventType.Birth, RegStatus.InProgress ) @@ -456,7 +456,7 @@ describe('ReviewForm tests', () => { const declaration = createReviewDeclaration( uuid(), birthDraftData, - Event.Birth, + EventType.Birth, RegStatus.Declared ) @@ -504,7 +504,7 @@ describe('ReviewForm tests', () => { const declaration = createReviewDeclaration( uuid(), birthDraftData, - Event.Birth, + EventType.Birth, RegStatus.Validated ) @@ -552,7 +552,7 @@ describe('ReviewForm tests', () => { const declaration = createReviewDeclaration( uuid(), birthDraftData, - Event.Birth, + EventType.Birth, RegStatus.Rejected ) @@ -600,7 +600,7 @@ describe('ReviewForm tests', () => { const declaration = createReviewDeclaration( uuid(), birthDraftData, - Event.Birth + EventType.Birth ) const testComponent = await createTestComponent( @@ -647,7 +647,7 @@ describe('ReviewForm tests', () => { const declaration = createReviewDeclaration( uuid(), birthDraftData, - Event.Birth + EventType.Birth ) store.dispatch( getStorageDeclarationsSuccess( @@ -700,7 +700,7 @@ describe('ReviewForm tests', () => { scope={scope} staticContext={mock} event={deathDeclaration.event} - registerForm={getReviewFormFromStore(store, Event.Death)} + registerForm={getReviewFormFromStore(store, EventType.Death)} pageRoute={REVIEW_EVENT_PARENT_FORM_PAGE} match={{ params: { @@ -739,7 +739,7 @@ describe('ReviewForm tests', () => { ) }) it('populates proper death event section', async () => { - const form = await getReviewFormFromStore(store, Event.Death) + const form = await getReviewFormFromStore(store, EventType.Death) const testComponent = await createTestComponent( { function getEvent(eventType: string) { switch (eventType && eventType.toLocaleLowerCase()) { case 'birth': - return Event.Birth + return EventType.Birth case 'death': - return Event.Death + return EventType.Death case 'marriage': - return Event.Marriage + return EventType.Marriage default: - return Event.Birth + return EventType.Birth } } diff --git a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx index 123658b827a..6f5610cc17c 100644 --- a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx @@ -8,9 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as React from 'react' import { createDeclaration } from '@client/declarations' -import { Event as DeclarationEvent, Event } from '@client/utils/gateway' import { REVIEW_EVENT_PARENT_FORM_PAGE } from '@client/navigation/routes' import { createStore } from '@client/store' import { @@ -20,16 +18,18 @@ import { selectOption, userDetails } from '@client/tests/util' -import { ReviewSection } from '@client/views/RegisterForm/review/ReviewSection' -import { ReactWrapper } from 'enzyme' import { waitForElement } from '@client/tests/wait-for-element' import { isMobileDevice } from '@client/utils/commonUtils' -import { vi, Mock, SpyInstance } from 'vitest' +import { EventType } from '@client/utils/gateway' +import { ReviewSection } from '@client/views/RegisterForm/review/ReviewSection' +import { ReactWrapper } from 'enzyme' +import * as React from 'react' +import { Mock, SpyInstance, vi } from 'vitest' const { store, history } = createStore() const mockHandler = vi.fn() -const draft = createDeclaration(DeclarationEvent.Birth) +const draft = createDeclaration(EventType.Birth) draft.data = { child: { firstNamesEng: 'John', familyNameEng: 'Doe' }, father: { @@ -61,7 +61,7 @@ describe('when in device of large viewport', () => { beforeEach(async () => { const { store } = await createTestStore() - form = await getRegisterFormFromStore(store, Event.Birth) + form = await getRegisterFormFromStore(store, EventType.Birth) userAgentMock = vi.spyOn(window.navigator, 'userAgent', 'get') Object.assign(window, { outerWidth: 1034 }) diff --git a/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.test.tsx b/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.test.tsx index d3d27c28941..14cbd87f53d 100644 --- a/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.test.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.test.tsx @@ -23,7 +23,7 @@ import { } from '@client/declarations' import { v4 as uuid } from 'uuid' import { REVIEW_EVENT_PARENT_FORM_PAGE } from '@opencrvs/client/src/navigation/routes' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import * as profileSelectors from '@client/profile/profileSelectors' import { vi } from 'vitest' import { ViewRecordQueries } from '@client/views/ViewRecord/query' @@ -1157,7 +1157,7 @@ describe('when user is in the register form review section', () => { } ] }, - Event.Birth + EventType.Birth ) declaration.duplicates = [ { @@ -1170,7 +1170,7 @@ describe('when user is in the register form review section', () => { const mock: any = vi.fn() vi.spyOn(profileSelectors, 'getScope').mockReturnValue(['register']) - const form = await getReviewFormFromStore(store, Event.Birth) + const form = await getReviewFormFromStore(store, EventType.Birth) const testComponent = await createTestComponent( // @ts-ignore diff --git a/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.tsx b/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.tsx index 2dafa8289c2..32629fc3c9f 100644 --- a/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/DuplicateFormTabs.tsx @@ -23,7 +23,7 @@ import { import { useSelector } from 'react-redux' import { getOfflineData } from '@client/offline/selectors' import { gqlToDraftTransformer } from '@client/transformer' -import { Event, RegStatus, History } from '@client/utils/gateway' +import { EventType, RegStatus, History } from '@client/utils/gateway' import { MessageDescriptor, useIntl } from 'react-intl' import { getLanguage } from '@client/i18n/selectors' import { getRegisterForm } from '@client/forms/register/declaration-selectors' @@ -629,7 +629,7 @@ export const DuplicateFormTabs = (props: IProps) => { const eventData = duplicateDeclarationGQLData?.data?.fetchRegistrationForViewing const eventType = - duplicateDeclarationGQLData?.data?.fetchRegistrationForViewing?.registration.type.toLowerCase() as Event + duplicateDeclarationGQLData?.data?.fetchRegistrationForViewing?.registration.type.toLowerCase() as EventType const duplicateDeclarationData = gqlToDraftTransformer( form[eventType], eventData, diff --git a/packages/client/src/views/RegisterForm/duplicate/SupportingDocumentsView.tsx b/packages/client/src/views/RegisterForm/duplicate/SupportingDocumentsView.tsx index bca9148d568..a4ec87dece3 100644 --- a/packages/client/src/views/RegisterForm/duplicate/SupportingDocumentsView.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/SupportingDocumentsView.tsx @@ -28,7 +28,7 @@ import { getDeathSection, getRegisterForm } from '@client/forms/register/declaration-selectors' -import { Event } from '@client/utils/gateway' +import { EventType } from '@client/utils/gateway' import { isArray } from 'lodash' import { ZeroDocument } from '@client/views/RegisterForm/review/ReviewSection' import { DocumentListPreview } from '@client/components/form/DocumentUploadField/DocumentListPreview' @@ -55,7 +55,7 @@ export const SupportingDocumentsView = (props: IProps) => { const eventsRegisterForm = useSelector(getRegisterForm) const eventType = String( declaration.data.registration.type - ).toLowerCase() as Event + ).toLowerCase() as EventType const documentsSection = useSelector((state: IStoreState) => eventType.toLowerCase() === 'birth' ? getBirthSection(state, 'documents') diff --git a/packages/client/src/views/RegisterForm/review/ReviewSection.test.tsx b/packages/client/src/views/RegisterForm/review/ReviewSection.test.tsx index 08ccebc578e..bc013df11a0 100644 --- a/packages/client/src/views/RegisterForm/review/ReviewSection.test.tsx +++ b/packages/client/src/views/RegisterForm/review/ReviewSection.test.tsx @@ -14,18 +14,19 @@ import { storeDeclaration } from '@client/declarations' import { - // BirthSection, - ViewType, - // DeathSection, - LOCATION_SEARCH_INPUT, DATE, DOCUMENT_UPLOADER_WITH_OPTION, IForm, - TEXT + // DeathSection, + LOCATION_SEARCH_INPUT, + TEXT, // MarriageSection + // BirthSection, + ViewType } from '@client/forms' -import { Event as DeclarationEvent, RegStatus } from '@client/utils/gateway' +import { formMessages } from '@client/i18n/messages' import { REVIEW_EVENT_PARENT_FORM_PAGE } from '@client/navigation/routes' +import { offlineDataReady } from '@client/offline/actions' import * as profileSelectors from '@client/profile/profileSelectors' import { createStore } from '@client/store' import { @@ -37,24 +38,27 @@ import { resizeWindow, userDetails } from '@client/tests/util' +import { waitForElement } from '@client/tests/wait-for-element' +import { isMobileDevice } from '@client/utils/commonUtils' +import { + EventType as DeclarationEvent, + EventType, + RegStatus +} from '@client/utils/gateway' import { renderSelectDynamicLabel, ReviewSection } from '@client/views/RegisterForm/review/ReviewSection' import { ReactWrapper } from 'enzyme' import * as React from 'react' -import { v4 as uuid } from 'uuid' -import { waitForElement } from '@client/tests/wait-for-element' -import { isMobileDevice } from '@client/utils/commonUtils' import { createIntl } from 'react-intl' -import { formMessages } from '@client/i18n/messages' -import { vi, Mock, SpyInstance } from 'vitest' -import { offlineDataReady } from '@client/offline/actions' +import { v4 as uuid } from 'uuid' +import { Mock, SpyInstance, vi } from 'vitest' const { store, history } = createStore() const mockHandler = vi.fn() -const draft = createDeclaration(DeclarationEvent.Birth) +const draft = createDeclaration(EventType.Birth) draft.data = { child: { firstNamesEng: 'John', familyNameEng: 'Doe' }, father: { @@ -74,18 +78,18 @@ draft.data = { const declaredBirthDeclaration = createReviewDeclaration( uuid(), draft.data, - DeclarationEvent.Birth + EventType.Birth ) const rejectedDraftBirth = createReviewDeclaration( uuid(), draft.data, - DeclarationEvent.Birth, + EventType.Birth, RegStatus.Rejected ) const rejectedDraftDeath = createReviewDeclaration( uuid(), draft.data, - DeclarationEvent.Death, + EventType.Death, RegStatus.Rejected ) const rejectedDraftMarriage = createReviewDeclaration( @@ -102,7 +106,7 @@ describe('when in device of large viewport', () => { beforeEach(async () => { store.dispatch(offlineDataReady(mockOfflineDataDispatch)) await flushPromises() - form = await getRegisterFormFromStore(store, DeclarationEvent.Birth) + form = await getRegisterFormFromStore(store, EventType.Birth) userAgentMock = vi.spyOn(window.navigator, 'userAgent', 'get') Object.assign(window, { outerWidth: 1034 }) @@ -465,11 +469,7 @@ describe('when in device of large viewport', () => { documents: {} } - const simpleDraft = createReviewDeclaration( - uuid(), - data, - DeclarationEvent.Birth - ) + const simpleDraft = createReviewDeclaration(uuid(), data, EventType.Birth) const testComponent = await createTestComponent( { documents: {} } - const simpleDraft = createReviewDeclaration( - uuid(), - data, - DeclarationEvent.Birth - ) + const simpleDraft = createReviewDeclaration(uuid(), data, EventType.Birth) const testComponent = await createTestComponent( { documents: {} } - const simpleDraft = createReviewDeclaration( - uuid(), - data, - DeclarationEvent.Birth - ) + const simpleDraft = createReviewDeclaration(uuid(), data, EventType.Birth) const testComponent = await createTestComponent(