@@ -4,31 +4,32 @@ import {
44} from 'react' ;
55import Papa from 'papaparse' ;
66import { saveAs } from 'file-saver' ;
7+ import { isDefined , isNotDefined } from '@togglecorp/fujs' ;
78
8- import { toDateTimeString } from '#utils/common' ;
9- import useTranslation from '#hooks/useTranslation' ;
10- import {
11- type GoApiResponse ,
12- useRequest ,
13- } from '#utils/restRequest' ;
14- import { resolveToComponent } from '#utils/translation' ;
159import Container from '#components/Container' ;
1610import Pager from '#components/Pager' ;
1711import Page from '#components/Page' ;
18- import useAlert from '#hooks/useAlert ' ;
12+ import { SortContext } from '#components/Table/useSorting ' ;
1913import ExportButton from '#components/domain/ExportButton' ;
20- import {
21- SortContext ,
22- } from '#components/Table/useSorting' ;
14+ import Table from '#components/Table' ;
15+ import DateInput from '#components/DateInput' ;
2316import {
2417 createStringColumn ,
2518 createDateColumn ,
2619 createLinkColumn ,
2720} from '#components/Table/ColumnShortcuts' ;
21+ import useAlert from '#hooks/useAlert' ;
22+ import useTranslation from '#hooks/useTranslation' ;
2823import useRecursiveCsvExport from '#hooks/useRecursiveCsvRequest' ;
29- import Table from '#components/Table' ;
30- import DateInput from '#components/DateInput' ;
3124import useFilterState from '#hooks/useFilterState' ;
25+ import { toDateTimeString } from '#utils/common' ;
26+ import {
27+ type GoApiResponse ,
28+ useRequest ,
29+ } from '#utils/restRequest' ;
30+ import { resolveToComponent } from '#utils/translation' ;
31+ import { COUNTRY_RECORD_TYPE_REGION } from '#utils/constants' ;
32+ import { countryIdToRegionIdMap } from '#utils/domain/country' ;
3233
3334import i18n from './i18n.json' ;
3435
@@ -122,17 +123,37 @@ export function Component() {
122123 ( item ) => getTypeName ( item . type ) ,
123124 { sortable : true } ,
124125 ) ,
126+ // NOTE:We don't have proper mapping for region
125127 createLinkColumn < PersonnelTableItem , number > (
126128 'country_from' ,
127129 strings . personnelTableDeployingParty ,
128130 ( item ) => (
129131 item . country_from ?. society_name
130132 || item . country_from ?. name
131133 ) ,
132- ( item ) => ( {
133- to : 'countriesLayout' ,
134- urlParams : { countryId : item . country_from ?. id } ,
135- } ) ,
134+ ( item ) => {
135+ if ( isNotDefined ( item . country_from ) ) {
136+ return { to : undefined } ;
137+ }
138+
139+ const countryId = item . country_from . id ;
140+
141+ if ( item . country_from . record_type === COUNTRY_RECORD_TYPE_REGION ) {
142+ const regionId = isDefined ( countryId )
143+ ? countryIdToRegionIdMap [ countryId ]
144+ : undefined ;
145+
146+ return {
147+ to : 'regionsLayout' ,
148+ urlParams : { regionId } ,
149+ } ;
150+ }
151+
152+ return {
153+ to : 'countriesLayout' ,
154+ urlParams : { countryId } ,
155+ } ;
156+ } ,
136157 { sortable : true } ,
137158 ) ,
138159 createLinkColumn < PersonnelTableItem , number > (
0 commit comments