Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocrvs 7584 #1144

Closed
wants to merge 11 commits into from
Closed
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 @@ -28,7 +28,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

### New content keys requiring translation
Expand Down
36 changes: 0 additions & 36 deletions src/api/certificate-configuration/handler.ts

This file was deleted.

184 changes: 180 additions & 4 deletions src/api/certificates/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,185 @@
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.event) {
const res = readFileSync(
`./src/api/certificates/source/${request.params.event}.svg`
).toString()
return h.response(res).code(200)
}
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: 0,
late: 5.5,
delayed: 15
},
svgUrl: '/api/countryconfig/certificates/birth-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: 'certified-birth-certificate',
event: 'birth',
label: {
id: 'certificates.birth.certificate.copy',
defaultMessage: 'Birth Certificate certified copy',
description: 'The label for a birth certificate'
},
isDefault: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
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: 0,
late: 5.5,
delayed: 15
},
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: 'certified-death-certificate',
event: 'death',
label: {
id: 'certificates.death.certificate.copy',
defaultMessage: 'Death Certificate certified copy',
description: 'The label for a death certificate'
},
isDefault: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
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: 0,
late: 5.5,
delayed: 15
},
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: 'certified-marriage-certificate',
event: 'marriage',
label: {
id: 'certificates.marriage.certificate.copy',
defaultMessage: 'Marriage Certificate certified copy',
description: 'The label for a marriage certificate'
},
isDefault: false,
fee: {
onTime: 0,
late: 5.5,
delayed: 15
},
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
Loading