Skip to content

Commit

Permalink
Merge pull request #290 from opencrvs/ocrvs-7584
Browse files Browse the repository at this point in the history
As a user I want to select a template to issue a certified copy with
  • Loading branch information
tareq89 authored Dec 26, 2024
2 parents 914161d + b07cb57 commit 93294a7
Show file tree
Hide file tree
Showing 28 changed files with 2,430 additions and 561 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

### Breaking changes

- **Title** Description
- Existing implementations relying on database-stored SVGs need to be updated to use the new configuration-based approach. A migration needs to be run (defined in [migration](https://github.com/opencrvs/opencrvs-core/pull/7813/files#diff-e5472dec87399bb9f73f75ec379ceb6a32ca135bc01dd8d0eb8f7d7aaa0bc0b1)), and default certificate templates must be created for each event type, following the convention `${event}-certificate` as the certificate template ID.

### Improvements

Expand All @@ -32,7 +32,7 @@

### New features

- **Major new feature** Description
- **Refactored certificate handling:** SVGs are no longer stored in the database; streamlined configurations now include certificate details, and clients request SVGs directly via URLs.
- Misc new feature
- Add constant.humanName to allow coutries to have custom ordering on thier full name e.g start with `lastName` or `firstName` [#6830](https://github.com/opencrvs/opencrvs-core/issues/6830)

Expand Down
2 changes: 1 addition & 1 deletion src/api/application/application-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const applicationConfig = {
DECLARATION_AUDIT_LOCATIONS: 'DISTRICT',
FEATURES: {
DEATH_REGISTRATION: true,
MARRIAGE_REGISTRATION: false,
MARRIAGE_REGISTRATION: true,
EXTERNAL_VALIDATION_WORKQUEUE: false,
INFORMANT_SIGNATURE: false,
PRINT_DECLARATION: false,
Expand Down
36 changes: 0 additions & 36 deletions src/api/certificate-configuration/handler.ts

This file was deleted.

183 changes: 178 additions & 5 deletions src/api/certificates/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,184 @@
*/

import { Request, ResponseToolkit } from '@hapi/hapi'
import { readFileSync } from 'fs'

type FontFamilyTypes = {
normal: string
bold: string
italics: string
bolditalics: string
}
export interface ICertificateConfigData {
id: string
event: Event
label: {
id: string
defaultMessage: string
description: string
}
isDefault: boolean
fee: {
onTime: number
late: number
delayed: number
}
svgUrl: string
fonts?: Record<string, FontFamilyTypes>
}

export async function certificateHandler(request: Request, h: ResponseToolkit) {
const res = readFileSync(
`./src/api/certificates/source/Farajaland-${request.params.event}-certificate-v2.svg`
).toString()
return h.response(res).code(200)
if (request.params.id) {
const filePath = `${__dirname}/source/${request.params.id}`
return h.file(filePath)
}
const certificateConfigs: ICertificateConfigData[] = [
{
id: 'birth-certificate',
event: 'birth',
label: {
id: 'certificates.birth.certificate',
defaultMessage: 'Birth Certificate',
description: 'The label for a birth certificate'
},
isDefault: true,
fee: {
onTime: 5,
late: 7,
delayed: 15
},
svgUrl: '/api/countryconfig/certificates/birth-certificate.svg',
fonts: {
'Libre Baskerville': {
normal: '/api/countryconfig/fonts/LibreBaskerville-Regular.ttf',
bold: '/api/countryconfig/fonts/LibreBaskerville-Bold.ttf',
italics: '/api/countryconfig/fonts/LibreBaskerville-Italic.ttf',
bolditalics: '/api/countryconfig/fonts/LibreBaskerville-Regular.ttf'
}
}
},
{
id: 'birth-certificate-certified-copy',
event: 'birth',
label: {
id: 'certificates.birth.certificate.copy',
defaultMessage: 'Birth Certificate certified copy',
description: 'The label for a birth certificate'
},
isDefault: false,
fee: {
onTime: 8,
late: 11.5,
delayed: 17
},
svgUrl:
'/api/countryconfig/certificates/birth-certificate-certified-copy.svg',
fonts: {
'Noto Sans': {
normal: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bold: '/api/countryconfig/fonts/NotoSans-Bold.ttf',
italics: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bolditalics: '/api/countryconfig/fonts/NotoSans-Regular.ttf'
}
}
},
{
id: 'death-certificate',
event: 'death',
label: {
id: 'certificates.death.certificate',
defaultMessage: 'Death Certificate',
description: 'The label for a death certificate'
},
isDefault: true,
fee: {
onTime: 3,
late: 5.7,
delayed: 12
},
svgUrl: '/api/countryconfig/certificates/death-certificate.svg',
fonts: {
'Noto Sans': {
normal: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bold: '/api/countryconfig/fonts/NotoSans-Bold.ttf',
italics: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bolditalics: '/api/countryconfig/fonts/NotoSans-Regular.ttf'
}
}
},
{
id: 'death-certificate-certified-copy',
event: 'death',
label: {
id: 'certificates.death.certificate.copy',
defaultMessage: 'Death Certificate certified copy',
description: 'The label for a death certificate'
},
isDefault: false,
fee: {
onTime: 6,
late: 9,
delayed: 14.5
},
svgUrl:
'/api/countryconfig/certificates/death-certificate-certified-copy.svg',
fonts: {
'Noto Sans': {
normal: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bold: '/api/countryconfig/fonts/NotoSans-Bold.ttf',
italics: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bolditalics: '/api/countryconfig/fonts/NotoSans-Regular.ttf'
}
}
},
{
id: 'marriage-certificate',
event: 'marriage',
label: {
id: 'certificates.marriage.certificate',
defaultMessage: 'Marriage Certificate',
description: 'The label for a marriage certificate'
},
isDefault: true,
fee: {
onTime: 4.4,
late: 6,
delayed: 13.5
},
svgUrl: '/api/countryconfig/certificates/marriage-certificate.svg',
fonts: {
'Noto Sans': {
normal: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bold: '/api/countryconfig/fonts/NotoSans-Bold.ttf',
italics: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bolditalics: '/api/countryconfig/fonts/NotoSans-Regular.ttf'
}
}
},
{
id: 'marriage-certificate-certified-copy',
event: 'marriage',
label: {
id: 'certificates.marriage.certificate.copy',
defaultMessage: 'Marriage Certificate certified copy',
description: 'The label for a marriage certificate'
},
isDefault: false,
fee: {
onTime: 7,
late: 10.6,
delayed: 18
},
svgUrl:
'/api/countryconfig/certificates/marriage-certificate-certified-copy.svg',
fonts: {
'Noto Sans': {
normal: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bold: '/api/countryconfig/fonts/NotoSans-Bold.ttf',
italics: '/api/countryconfig/fonts/NotoSans-Regular.ttf',
bolditalics: '/api/countryconfig/fonts/NotoSans-Regular.ttf'
}
}
}
]
return certificateConfigs
}
Loading

0 comments on commit 93294a7

Please sign in to comment.