Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@hapi/boom": "^9.1.1",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "^0.0.5",
"@types/chalk": "^2.2.0",
"@types/csv2json": "^1.4.0",
"@types/fhir": "^0.0.30",
Expand Down
19 changes: 19 additions & 0 deletions src/api/custom-event/handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 Hapi from '@hapi/hapi'
import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership'

export const customEventHandler = (
request: Hapi.Request,
h: Hapi.ResponseToolkit
) => {
return h.response([tennisClubMembershipEvent]).code(200)
}
8 changes: 8 additions & 0 deletions src/api/event-registration/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
confirmRegistration
// rejectRegistration
} from '@countryconfig/utils/gateway-api'
import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership'

export async function eventRegistrationHandler(
request: Hapi.Request,
Expand Down Expand Up @@ -67,3 +68,10 @@ export async function eventRegistrationHandler(

return h.response().code(202)
}

export const tennisClubMembershipEventHandler = (
request: Hapi.Request,
h: Hapi.ResponseToolkit
) => {
return h.response(tennisClubMembershipEvent).code(200)
}
132 changes: 132 additions & 0 deletions src/form/tennis-club-membership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* 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 { defineConfig } from '@opencrvs/toolkit/events'

export const tennisClubMembershipEvent = defineConfig({
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'
}
}
]
}
]
}
]
}
]
})
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { dashboardQueriesHandler } from './api/dashboards/handler'
import { fontsHandler } from './api/fonts/handler'
import { certificateConfigurationHandler } from './api/certificate-configuration/handler'
import { recordNotificationHandler } from './api/record-notification/handler'
import { customEventHandler } from '@countryconfig/api/custom-event/handler'

export interface ITokenPayload {
sub: string
Expand Down Expand Up @@ -545,6 +546,16 @@ export async function createServer() {
}
})

server.route({
method: 'GET',
path: '/events',
handler: customEventHandler,
options: {
tags: ['api', 'custom-event'],
description: 'Serves custom events'
}
})

server.ext({
type: 'onRequest',
method(request: Hapi.Request & { sentryScope?: any }, h) {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"@countryconfig/*": ["./*"]
},
"target": "es6",
"module": "commonjs",
"module": "Node16",
"outDir": "build/dist",
"sourceMap": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"rootDir": ".",
"lib": ["esnext.asynciterable", "es6", "es2017", "es2019", "es2022"],
"forceConsistentCasingInFileNames": true,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@
dependencies:
"@octokit/openapi-types" "^18.0.0"

"@opencrvs/toolkit@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-0.0.5.tgz#dbd3395b561c1eb3527b8cfc28b6e1dd301671f3"
integrity sha512-Ex45aFUJ1iQwpYGMHhxVbhpuQFqVlmdSkNXz1phkM7KAzNtngL2KGIJCc6TFv4GKOHU/lLEfmGyrhIDCKlA7fQ==

"@rollup/[email protected]":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz#1661ff5ea9beb362795304cb916049aba7ac9c54"
Expand Down
Loading