@@ -2,15 +2,10 @@ import { TFunction } from 'i18next';
22import { AriaAttributes , Dispatch , FC , SetStateAction } from 'react' ;
33import { useTranslation } from 'react-i18next' ;
44import { twJoin } from 'tailwind-merge' ;
5- import { SortOrder } from '../../../../../types' ;
6- import { ExpandButton } from '../../../../../uiComponents' ;
7- import { StopVersionTableColumn , StopVersionTableSortingInfo } from '../types' ;
8-
9- const testIds = {
10- column : ( type : StopVersionTableColumn ) =>
11- `StopVersionTableHeaderSortableCell::${ type . toLowerCase ( ) } ` ,
12- sortButton : 'StopVersionTableHeaderSortableCell::sortButton' ,
13- } ;
5+ import { SortOrder } from '../../../types' ;
6+ import { ExpandButton } from '../../../uiComponents' ;
7+ import { VersionTableSortingInfo } from './useVersionContainerControls' ;
8+ import { VersionTableColumn } from './VersionTableColumn' ;
149
1510function getAriaSortValue (
1611 active : boolean ,
@@ -23,39 +18,45 @@ function getAriaSortValue(
2318 return undefined ;
2419}
2520
26- function trColumnName ( t : TFunction , columnType : StopVersionTableColumn ) {
21+ function trColumnName ( t : TFunction , columnType : VersionTableColumn ) {
2722 switch ( columnType ) {
2823 case 'CHANGED' :
29- return t ( ( $ ) => $ . stopVersion . header . changed ) ;
24+ return t ( ( $ ) => $ . versions . header . changed ) ;
3025 case 'CHANGED_BY' :
31- return t ( ( $ ) => $ . stopVersion . header . changed_by ) ;
26+ return t ( ( $ ) => $ . versions . header . changed_by ) ;
3227 case 'STATUS' :
33- return t ( ( $ ) => $ . stopVersion . header . status ) ;
28+ return t ( ( $ ) => $ . versions . header . status ) ;
3429 case 'VALIDITY_END' :
35- return t ( ( $ ) => $ . stopVersion . header . validity_end ) ;
30+ return t ( ( $ ) => $ . versions . header . validity_end ) ;
3631 case 'VALIDITY_START' :
37- return t ( ( $ ) => $ . stopVersion . header . validity_start ) ;
32+ return t ( ( $ ) => $ . versions . header . validity_start ) ;
3833 case 'VERSION_COMMENT' :
39- return t ( ( $ ) => $ . stopVersion . header . version_comment ) ;
34+ return t ( ( $ ) => $ . versions . header . version_comment ) ;
4035
4136 default :
4237 return '' ;
4338 }
4439}
4540
46- type StopVersionTableHeaderSortableCellProps = {
41+ type VersionTableHeaderSortableCellProps = {
4742 readonly className ?: string ;
4843 readonly tdClassName ?: string ;
49- readonly columnType : StopVersionTableColumn ;
50- readonly sortingInfo : StopVersionTableSortingInfo ;
51- readonly setSortingInfo : Dispatch <
52- SetStateAction < StopVersionTableSortingInfo >
53- > ;
44+ readonly columnType : VersionTableColumn ;
45+ readonly sortingInfo : VersionTableSortingInfo ;
46+ readonly setSortingInfo : Dispatch < SetStateAction < VersionTableSortingInfo > > ;
47+ readonly testIdPrefix ?: string ;
5448} ;
5549
56- export const StopVersionTableHeaderSortableCell : FC <
57- StopVersionTableHeaderSortableCellProps
58- > = ( { className, tdClassName, columnType, sortingInfo, setSortingInfo } ) => {
50+ export const VersionTableHeaderSortableCell : FC <
51+ VersionTableHeaderSortableCellProps
52+ > = ( {
53+ className,
54+ tdClassName,
55+ columnType,
56+ sortingInfo,
57+ setSortingInfo,
58+ testIdPrefix = 'VersionTableHeaderSortableCell' ,
59+ } ) => {
5960 const { t } = useTranslation ( ) ;
6061
6162 const active = sortingInfo . sortBy === columnType ;
@@ -81,7 +82,7 @@ export const StopVersionTableHeaderSortableCell: FC<
8182 < td
8283 aria-sort = { getAriaSortValue ( active , ascending ) }
8384 className = { tdClassName }
84- data-testid = { testIds . column ( columnType ) }
85+ data-testid = { ` ${ testIdPrefix } :: ${ columnType . toLowerCase ( ) } ` }
8586 >
8687 < ExpandButton
8788 forSorting
@@ -90,7 +91,7 @@ export const StopVersionTableHeaderSortableCell: FC<
9091 expanded = { ! ascending }
9192 expandedText = { trColumnName ( t , columnType ) }
9293 onClick = { onClick }
93- testId = { testIds . sortButton }
94+ testId = { ` ${ testIdPrefix } :: sortButton` }
9495 />
9596 </ td >
9697 ) ;
0 commit comments