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

Events v2 collect certificate workflow boilerplate code #8321

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5740e8b
events v2 collect certificate workflow boilerplate code
tareq89 Jan 10, 2025
349d2b1
tennis club membership svg certificate added
tareq89 Jan 15, 2025
29ac67d
basic rendered certificate svg preview
tareq89 Jan 20, 2025
776977d
Merge branch 'ocrvs-event-v2-7919' of github.com:opencrvs/opencrvs-co…
tareq89 Jan 22, 2025
f405d0a
defaultCertificateCollectorFormConfig introduced in core
tareq89 Jan 22, 2025
9d1c056
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 22, 2025
004a75b
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 23, 2025
d058835
FormHeader label and icon are now configurable
tareq89 Jan 23, 2025
1dc80c7
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 23, 2025
a36f94c
made onSaveAndExit optional in form layout to match design
tareq89 Jan 23, 2025
558cee0
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 23, 2025
8fa7d97
collectCertificate procedure added
tareq89 Jan 23, 2025
979e3bb
default certificate form is defined in toolkit
tareq89 Jan 24, 2025
541a72c
certificate collector verify and payment page boilerplate added
tareq89 Jan 24, 2025
073754b
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 27, 2025
c1e974d
hard coded template selector in event v2 print flow
tareq89 Jan 28, 2025
5032af8
fix build.sh in toolkit and copied in utils for print
tareq89 Jan 29, 2025
0226f4b
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 29, 2025
2142887
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 29, 2025
756c765
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into ocrv…
tareq89 Jan 30, 2025
5106b3d
refactored print flow based on feedbacks
tareq89 Jan 30, 2025
9580776
certificate page added in storybook
tareq89 Jan 31, 2025
bcd57c4
mock api call for certificate config added in storybook
tareq89 Jan 31, 2025
94da4d3
clean up
tareq89 Jan 31, 2025
fe24f9f
Merge branch 'develop' into ocrvs-event-v2-7919
tareq89 Jan 31, 2025
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 debug-service-in-chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
SERVICES=(
"auth:4040"
"workflow:5050"
"events:5555"
"config:2021"
"gateway:7070"
"metrics:1050"
Expand Down
91 changes: 86 additions & 5 deletions packages/client/.storybook/default-request-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import { http } from 'msw'

import { graphql, HttpResponse } from 'msw'
/* eslint-disable import/no-relative-parent-imports */
import { http, graphql, HttpResponse } from 'msw'
import { createTRPCMsw, httpLink } from '@vafanassieff/msw-trpc'
import superjson from 'superjson'
import { mockOfflineData } from '../src/tests/mock-offline-data'
import forms from '../src/tests/forms.json'
import superjson from 'superjson'
import { AppRouter } from '../src/v2-events/trpc'
import { createTRPCMsw, httpLink } from '@vafanassieff/msw-trpc'
import {
tennisClubMembershipEvent,
tennisClubMembershipEventIndex
} from '../src/v2-events/features/events/fixtures'
import { tennisClubMembershipCertifiedCertificateTemplate } from './tennisClubMembershipCertifiedCertificateTemplate'

const tRPCMsw = createTRPCMsw<AppRouter>({
links: [
Expand Down Expand Up @@ -1106,11 +1107,91 @@ export const handlers = {
})
],
config: [
http.get(
'http://localhost:6006/api/countryconfig/certificates/tennis-club-membership-certificate.svg',
() => {
return HttpResponse.text(
tennisClubMembershipCertifiedCertificateTemplate
)
}
),
http.get(
'http://localhost:6006/api/countryconfig/certificates/tennis-club-membership-certified-certificate.svg',
() => {
return HttpResponse.text(
tennisClubMembershipCertifiedCertificateTemplate
)
}
),

http.get(
'http://localhost:6006/api/countryconfig/fonts/NotoSans-Regular.ttf',
async () => {
const fontResponse = await fetch(
'http://localhost:3040/fonts/NotoSans-Regular.ttf'
)
const fontArrayBuffer = await fontResponse.arrayBuffer()
return HttpResponse.arrayBuffer(fontArrayBuffer)
}
),

http.get('http://localhost:2021/config', () => {
return HttpResponse.json({
systems: [],
config: mockOfflineData.config,
certificates: []
certificates: [
{
id: 'tennis-club-membership-certificate',
event: 'TENNIS_CLUB_MEMBERSHIP',
label: {
id: 'certificates.tennis-club-membership.certificate.copy',
defaultMessage: 'Tennis Club Membership Certificate copy',
description: 'The label for a tennis-club-membership certificate'
},
isDefault: false,
fee: {
onTime: 7,
late: 10.6,
delayed: 18
},
svgUrl:
'/api/countryconfig/certificates/tennis-club-membership-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: 'tennis-club-membership-certified-certificate',
event: 'TENNIS_CLUB_MEMBERSHIP',
label: {
id: 'certificates.tennis-club-membership.certificate.certified-copy',
defaultMessage:
'Tennis Club Membership Certificate certified copy',
description: 'The label for a tennis-club-membership certificate'
},
isDefault: false,
fee: {
onTime: 7,
late: 10.6,
delayed: 18
},
svgUrl:
'/api/countryconfig/certificates/tennis-club-membership-certified-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'
}
}
}
]
})
})
],
Expand Down

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/client/src/offline/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export const getOfflineData = (store: IStoreState): IOfflineData => {
return data
}

export const getLanguage = createSelector(
getOfflineData,
(data) => data.languages[0]
)
export const getCertificateTemplates = createSelector(
getOfflineData,
(data) => data.templates.certificates
)
export const getLocations = createSelector(getOfflineData, (data) => ({
...data.locations,
...data.facilities,
Expand Down
95 changes: 95 additions & 0 deletions packages/client/src/v2-events/STYLEGUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Styleguide

## Zod Schemas and types

good:

```
// This way we can import both the type and validator under same alias.
const FontFamily = z.object({
normal: z.string(),
bold: z.string(),
italics: z.string(),
bolditalics: z.string()
})

type FontFamily = z.infer<typeof FontFamily>
```

- Use the same name for file and the main export
- Prefer variable names without postfix (e.g. schema, data)

## Naming files

good:

```
- ZodInterfacePascalCase.ts
- ReactComponentPascalCase.tsx
- useHookCamelCase.ts
- anything-else-in-kebab-case.ts
```

## Naming interfaces

good:

```
interface ApplicationConfig {
certificateTemplates: CertificateTemplateConfig[]
language?: LanguageConfig
}
```

not-so-good:

```
interface IApplicationConfig {
certificateTemplates: ICertificateTemplateConfig[]
language?: ILanguageConfig
}
```

# Coding conventions, definition of done

- When introducing a new `MessageDescriptor` create a new row in `client.csv`
- They should all have `v2.`-prefix

## Naming, abbreviation

When naming things with known abbreviations use camel case format despite of it.

good:

```
export interface SvgTemplate {
definition: string
}

export function printPdf(template: PdfTemplate, declarationId: string) {
const pdf = pdfMake.createPdf(template.definition, undefined, template.fonts)
if (isMobileDevice()) {
pdf.download(`${declarationId}`)
} else {
pdf.print()
}
}
```

not-so-good:

```
export interface ISVGTemplate {
definition: string
}

export function printPDF(template: PDFTemplate, declarationId: string) {
// note: example uses external lib with the same convention.
const PDF = pdfMake.createPdf(template.definition, undefined, template.fonts)
if (isMobileDevice()) {
PDF.download(`${declarationId}`)
} else {
PDF.print()
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ export function Pages() {
}, [pageId, currentPageId, navigate, eventId])

return (
<FormLayout
canSaveAndExit={false}
route={ROUTES.V2.EVENTS.REQUEST_CORRECTION}
>
<FormLayout route={ROUTES.V2.EVENTS.REQUEST_CORRECTION}>
{modal}
<PagesComponent
eventId={eventId}
form={form}
formPages={formPages}
pageId={currentPageId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function Review() {
}

return (
<FormLayout canSaveAndExit={false} route={ROUTES.V2.EVENTS.REGISTER}>
<FormLayout route={ROUTES.V2.EVENTS.REGISTER}>
<ReviewComponent.Body
eventConfig={config}
form={form}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export function Pages() {
>
{modal}
<PagesComponent
eventId={eventId}
form={formValues}
formPages={formPages}
pageId={currentPageId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Text,
TextInput
} from '@opencrvs/components'
import { ActionType } from '@opencrvs/commons/client'
import { useEventConfiguration } from '@client/v2-events/features/events/useEventConfiguration'
import { useEventFormData } from '@client/v2-events/features/events/useEventFormData'
import { useEventFormNavigation } from '@client/v2-events/features/events/useEventFormNavigation'
Expand Down
Loading
Loading