Skip to content

Commit ee2d812

Browse files
committed
Reuse country to region mapping in surge personnel table
1 parent 4c46af6 commit ee2d812

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/views/AllDeployedPersonnel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import {
2828
useRequest,
2929
} from '#utils/restRequest';
3030
import { resolveToComponent } from '#utils/translation';
31+
import { COUNTRY_RECORD_TYPE_REGION } from '#utils/constants';
32+
import { countryIdToRegionIdMap } from '#utils/domain/country';
3133

3234
import i18n from './i18n.json';
33-
import { COUNTRY_RECORD_TYPE_COUNTRY, COUNTRY_RECORD_TYPE_REGION } from '#utils/constants';
34-
import { countryIdToRegionIdMap } from '#utils/domain/country';
3535

3636
type PersonnelTableItem = NonNullable<GoApiResponse<'/api/v2/personnel/'>['results']>[number];
3737
function keySelector(personnel: PersonnelTableItem) {

src/views/DrefApplicationForm/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ const schema: DrefFormSchema = {
316316
lessons_learned: {},
317317
event_scope: {},
318318
people_in_need: { validations: [positiveIntegerCondition] },
319-
event_text: { validations: [max500CharCondition] },
320319
};
321320
}
322321

323322
if (val?.type_of_dref === TYPE_IMMINENT) {
324323
conditionalFields = {
325324
...conditionalFields,
325+
event_text: { validations: [max500CharCondition] },
326326
anticipatory_actions: {},
327327
supporting_document: {},
328328
};

src/views/EmergencySurge/RapidResponsePersonnelTable/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
maxSafe,
2929
minSafe,
3030
} from '#utils/common';
31+
import { COUNTRY_RECORD_TYPE_REGION } from '#utils/constants';
32+
import { countryIdToRegionIdMap } from '#utils/domain/country';
3133

3234
import i18n from './i18n.json';
3335
import styles from './styles.module.css';
@@ -142,14 +144,26 @@ export default function RapidResponsePersonnelTable(props: Props) {
142144
strings.personnelTableDeployedParty,
143145
(item) => item.country_from?.society_name,
144146
(item) => {
145-
if (isDefined(item.country_from?.record_type === 3)) {
147+
if (isNotDefined(item.country_from)) {
148+
return { to: undefined };
149+
}
150+
151+
const countryId = item.country_from.id;
152+
153+
if (item.country_from.record_type === COUNTRY_RECORD_TYPE_REGION) {
154+
const regionId = isDefined(countryId)
155+
? countryIdToRegionIdMap[countryId]
156+
: undefined;
157+
146158
return {
147-
to: undefined,
159+
to: 'regionsLayout',
160+
urlParams: { regionId },
148161
};
149162
}
163+
150164
return {
151165
to: 'countriesLayout',
152-
urlParams: { countryId: item.country_from?.id },
166+
urlParams: { countryId },
153167
};
154168
},
155169
{ sortable: true },

0 commit comments

Comments
 (0)