Skip to content

Commit 3641df7

Browse files
authored
Merge pull request #9970 from opencrvs/merge-1_7_3-to-1_8_0
Merge 1.7.3 to 1.8.0
2 parents a32754a + c768546 commit 3641df7

File tree

12 files changed

+80
-59
lines changed

12 files changed

+80
-59
lines changed

.github/workflows/lint-and-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,20 @@ jobs:
430430
ref: ${{ github.head_ref }}
431431
path: pr
432432

433-
- uses: actions/setup-node@v4
433+
- name: Use Node.js from .nvmrc from base branch
434+
uses: actions/setup-node@v4
435+
with:
436+
node-version-file: base/.nvmrc
434437

435438
- name: Install base dependencies
436439
run: yarn install --ignore-scripts
437440
working-directory: base
438441

442+
- name: Use Node.js from .nvmrc from PR branch
443+
uses: actions/setup-node@v4
444+
with:
445+
node-version-file: pr/.nvmrc
446+
439447
- name: Install PR dependencies
440448
run: yarn install --ignore-scripts
441449
working-directory: pr

CHANGELOG.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@
2020
- Secret `GITHUB_GHCR_PUBLISH_TOKEN` is classic token with permissions `repo, write:packages`. Required to build and push OpenCRVS Core images.
2121
- Secret `E2E_WORKFLOWS_TOKEN` is fine-grained token scoped to your fork of country config template repository with permissions `Contents: Read and Write`.
2222

23-
## 1.7.2
23+
## [1.7.3](https://github.com/opencrvs/opencrvs-core/compare/v1.7.2...v1.7.3)
24+
25+
### New features
26+
27+
### Bug fixes
28+
29+
- Allow booleanTransformer to be used as a certificate handlebar template transformer [#9631](https://github.com/opencrvs/opencrvs-core/issues/9631)
30+
- Fix international to local number conversion from failing if the number was already local [#9634](https://github.com/opencrvs/opencrvs-core/issues/9634)
31+
- Pre-select default certificate option in print certificate collector form [#9935](https://github.com/opencrvs/opencrvs-core/issues/9935)
32+
33+
34+
## [1.7.2](https://github.com/opencrvs/opencrvs-core/compare/v1.7.1...v1.7.2)
2435

2536
### New features
2637

@@ -102,14 +113,14 @@
102113

103114
## [1.6.5](https://github.com/opencrvs/opencrvs-core/compare/v1.6.4...v1.6.5)
104115

105-
- Fix migration issue discovered when restoring an OpenCRVS instance with a large number of records. `$push used too much memory and cannot spill to disk. Memory limit: 104857600 bytes` [#9116](https://github.com/opencrvs/opencrvs-core/issues/9116)
106-
107116
### Breaking changes
108117

109118
- Limit year past record `LIMIT_YEAR_PAST_RECORDS` forcing date of birth to start from the year 1900 has been addressed [#9326](https://github.com/opencrvs/opencrvs-core/pull/9326)
110119

111120
## [1.6.4](https://github.com/opencrvs/opencrvs-core/compare/v1.6.3...v1.6.4)
112121

122+
### Bug fixes
123+
113124
- Fix migration issue discovered when restoring an OpenCRVS instance with a large number of records. `$push used too much memory and cannot spill to disk. Memory limit: 104857600 bytes` [#9116](https://github.com/opencrvs/opencrvs-core/issues/9116)
114125

115126
## [1.6.3](https://github.com/opencrvs/opencrvs-core/compare/v1.6.2...v1.6.3)
@@ -138,7 +149,6 @@
138149
- Fix health facilities missing from dropdown after correcting a record address [#7528](https://github.com/opencrvs/opencrvs-core/issues/7528)
139150
- Fix stale validations showing for document uploader with options form field
140151
- Fix a bug in the POST `{{gateway}}/locations` endpoint used to create new locations, the check to verify if a `statisticalId` was already used was broken so we've fixed that. This was picked when we were trying to seed a location for a country via the endpoint [#8606](https://github.com/opencrvs/opencrvs-core/issues/8606)
141-
- Fix task history getting corrupted if a user views a record while it's in external validation [#8278](https://github.com/opencrvs/opencrvs-core/issues/8278)
142152

143153
### Improvements
144154

development-environment/setup-countryconfig.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ echo
3434

3535
cd ../
3636

37-
BRANCH=develop
37+
BRANCH=master
3838

3939

4040
git clone --branch $BRANCH --depth 1 https://github.com/opencrvs/opencrvs-countryconfig.git

packages/client/src/components/form/FormFieldGenerator.tsx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,10 @@ export const mapFieldsToValues = (
805805
...evalParams
806806
)
807807

808+
if (field.type === SELECT_WITH_OPTIONS && !field.initialValue) {
809+
fieldInitialValue = field.options.find((x) => x.isDefault)?.value ?? ''
810+
}
811+
808812
if (field.type === RADIO_GROUP_WITH_NESTED_FIELDS && !field.initialValue) {
809813
const nestedFieldsFlatted = flatten(Object.values(field.nestedFields))
810814

@@ -1194,29 +1198,7 @@ export class FormSectionComponent extends React.Component<Props> {
11941198
setValues(updatedValues)
11951199
}
11961200
} as ILoaderButton)
1197-
: field.type === LOCATION_SEARCH_INPUT
1198-
? {
1199-
...field,
1200-
locationList: generateLocations(
1201-
field.searchableResource.reduce(
1202-
(locations, resource) => {
1203-
return {
1204-
...locations,
1205-
...getListOfLocations(
1206-
offlineCountryConfig,
1207-
resource
1208-
)
1209-
}
1210-
},
1211-
{}
1212-
),
1213-
intl,
1214-
(location) =>
1215-
field.searchableType.includes(location.type),
1216-
field.userOfficeId
1217-
)
1218-
}
1219-
: field
1201+
: field
12201202

12211203
if (
12221204
field.type === FETCH_BUTTON ||

packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,8 @@ function getCertCollectorGroupForEvent(
10661066
const certificateTemplateOptions =
10671067
certificates
10681068
.filter((x) => x.event === declaration.event)
1069-
.map((x) => ({ label: x.label, value: x.id })) || []
1069+
.map((x) => ({ label: x.label, value: x.id, isDefault: x.isDefault })) ||
1070+
[]
10701071
return {
10711072
id: 'certCollector',
10721073
title: certificateMessages.whoToCollect,

packages/client/src/forms/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export type Action = SubmissionAction | DownloadAction
112112
export interface ISelectOption {
113113
value: SelectComponentOption['value']
114114
label: MessageDescriptor
115+
isDefault?: boolean
115116
}
116117
export interface IRadioOption {
117118
value: RadioComponentOption['value']

packages/client/src/forms/register/mappings/query/field-mappings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@ export const booleanTransformer = (
603603
sectionId: SectionId,
604604
field: IFormField
605605
) => {
606+
if (!transformedData[sectionId]) {
607+
transformedData[sectionId] = {}
608+
}
606609
// graphql boolean ignored unless forced like this
607610
if (queryData && queryData[sectionId] && field && field.name) {
608611
transformedData[sectionId][field.name] = queryData[sectionId][field.name]

packages/client/src/forms/register/mappings/query/registration-mappings.test.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@
1010
*/
1111

1212
import { convertToLocal } from './registration-mappings'
13+
describe('convertToLocal', () => {
14+
describe('given number in international format', () => {
15+
it('replaces country code and returns local format', async () => {
16+
expect(convertToLocal('+260211000000', 'ZMB')).toBe('0211000000')
17+
expect(convertToLocal('+358504700715', 'FIN')).toBe('0504700715')
18+
expect(convertToLocal('+237666666666', 'CMR')).toBe('666666666')
19+
expect(convertToLocal('+8801700000000', 'BGD')).toBe('01700000000')
20+
expect(convertToLocal('+260211000000')).toBe('0211000000')
21+
expect(convertToLocal('+358504700715')).toBe('0504700715')
22+
expect(convertToLocal('+237666666666')).toBe('666666666')
23+
expect(convertToLocal('+8801700000000')).toBe('01700000000')
24+
})
25+
})
1326

14-
describe('phone number conversion from international format back to local format', () => {
15-
it('replaces country code', async () => {
16-
expect(convertToLocal('+260211000000', 'ZMB')).toBe('0211000000')
17-
expect(convertToLocal('+358504700715', 'FIN')).toBe('0504700715')
18-
expect(convertToLocal('+237666666666', 'CMR')).toBe('666666666')
19-
expect(convertToLocal('+8801700000000', 'BGD')).toBe('01700000000')
20-
expect(convertToLocal('+260211000000')).toBe('0211000000')
21-
expect(convertToLocal('+358504700715')).toBe('0504700715')
22-
expect(convertToLocal('+237666666666')).toBe('666666666')
23-
expect(convertToLocal('+8801700000000')).toBe('01700000000')
27+
describe('given number in local format with country code', () => {
28+
it('returns the local number', async () => {
29+
expect(convertToLocal('0835114899', 'ZAF')).toBe('0835114899')
30+
expect(convertToLocal('0650310707', 'SOM')).toBe('0650310707')
31+
expect(convertToLocal('650310707', 'SOM')).toBe('0650310707')
32+
})
2433
})
2534
})

packages/client/src/forms/register/mappings/query/registration-mappings.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ import { get } from 'lodash'
3232
import { MessageDescriptor } from 'react-intl'
3333
import QRCode from 'qrcode'
3434
import { getAddressName } from '@client/views/SysAdmin/Team/utils'
35-
import { PhoneNumberFormat, PhoneNumberUtil } from 'google-libphonenumber'
35+
import {
36+
PhoneNumber,
37+
PhoneNumberFormat,
38+
PhoneNumberUtil
39+
} from 'google-libphonenumber'
3640
import {
3741
countryAlpha3toAlpha2,
3842
getLocationHierarchy
@@ -94,28 +98,34 @@ export const certificateDateTransformer =
9498
window.__localeId__ = prevLocale
9599
}
96100

101+
const getParseableCountryCode = (alpha3CountryCode?: string): string => {
102+
if (!alpha3CountryCode) {
103+
return ''
104+
}
105+
alpha3CountryCode = alpha3CountryCode === 'FAR' ? 'ZMB' : alpha3CountryCode
106+
107+
return countryAlpha3toAlpha2(alpha3CountryCode) || ''
108+
}
109+
97110
export const convertToLocal = (
98111
mobileWithCountryCode: string,
99112
alpha3CountryCode?: string
100113
) => {
101114
/*
102115
* If country is the fictional demo country (Farajaland), use Zambian number format
103116
*/
104-
alpha3CountryCode = alpha3CountryCode === 'FAR' ? 'ZMB' : alpha3CountryCode
105-
106117
const phoneUtil = PhoneNumberUtil.getInstance()
107-
const number = phoneUtil.parse(mobileWithCountryCode)
108-
const countryCode = alpha3CountryCode
109-
? countryAlpha3toAlpha2(alpha3CountryCode)
110-
: phoneUtil.getRegionCodeForNumber(number)
111118

112-
if (!countryCode) {
113-
return
114-
}
119+
const alpha2Code = getParseableCountryCode(alpha3CountryCode)
115120

116-
if (!phoneUtil.isPossibleNumberString(mobileWithCountryCode, countryCode)) {
121+
if (!phoneUtil.isPossibleNumberString(mobileWithCountryCode, alpha2Code)) {
117122
return
118123
}
124+
125+
const number = phoneUtil.parse(mobileWithCountryCode, alpha2Code)
126+
127+
const countryCode = alpha2Code || phoneUtil.getRegionCodeForNumber(number)
128+
119129
let nationalFormat = phoneUtil
120130
.format(number, PhoneNumberFormat.NATIONAL)
121131
.replace(/[^A-Z0-9]+/gi, '')

packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,7 @@ describe('Certificate collector test for a birth registration without father det
209209

210210
it('prompt error when no option is selected', async () => {
211211
component.find('#confirm_form').hostNodes().simulate('click')
212-
await waitForElement(component, '#certificateTemplateId_error')
213-
expect(
214-
component.find('#certificateTemplateId_error').hostNodes().text()
215-
).toBe('Please select certificate type')
212+
await waitForElement(component, '#type_error')
216213
expect(component.find('#type_error').hostNodes().text()).toBe(
217214
'Please select who is collecting the certificate'
218215
)

0 commit comments

Comments
 (0)