@@ -6,7 +6,10 @@ import { push } from "connected-react-router";
66
77import { getSubmissionList } from "../api/queryServices/analyzeSubmissionServices" ;
88import { formatDate } from "../helper/helper" ;
9- import { setAnalizeSubmissionSort , setAnalyzeSubmissionPage } from "../actions/analyzeSubmissionActions" ;
9+ import {
10+ setAnalizeSubmissionSort ,
11+ setAnalyzeSubmissionPage ,
12+ } from "../actions/analyzeSubmissionActions" ;
1013import {
1114 ReusableResizableTable ,
1215 TableFooter ,
@@ -38,43 +41,66 @@ const TaskSubmissionList: React.FC = () => {
3841 const scrollWrapperRef = useRef < HTMLDivElement > ( null ) ;
3942 const [ limit , setLimit ] = useState ( 10 ) ;
4043
41- const sortParams = useSelector ( ( state : any ) => state ?. analyzeSubmission . analyzeSubmissionSortParams || { } ) ;
42- const { page} = useSelector ( ( state : any ) => state ?. analyzeSubmission . page || 1 ) ;
43- const tenantKey = useSelector ( ( state : any ) => state . tenants ?. tenantData ?. tenantkey ) ;
44+ const sortParams = useSelector (
45+ ( state : any ) => state ?. analyzeSubmission . analyzeSubmissionSortParams ?? { }
46+ ) ;
47+ const { page } = useSelector (
48+ ( state : any ) => state ?. analyzeSubmission . page ?? 1
49+ ) ;
50+ const tenantKey = useSelector (
51+ ( state : any ) => state . tenants ?. tenantData ?. tenantkey
52+ ) ;
4453 const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${ tenantKey } /` : "/" ;
4554
46- const columns : Column [ ] = useMemo ( ( ) => [
47- { name : "Submission ID" , sortKey : "id" , width : 200 , resizable : true } ,
48- { name : "Form Name" , sortKey : "formName" , width : 200 , resizable : true } ,
49- { name : "Submitter" , sortKey : "createdBy" , width : 200 , resizable : true } ,
50- { name : "Submission Date" , sortKey : "submissionDate" , width : 180 , resizable : true } ,
51- { name : "Status" , sortKey : "applicationStatus" , width : 160 , resizable : true } ,
52- { name : "" , sortKey : "actions" , width : 100 } ,
53- ] , [ ] ) ;
55+ const columns : Column [ ] = useMemo (
56+ ( ) => [
57+ { name : "Submission ID" , sortKey : "id" , width : 200 , resizable : true } ,
58+ { name : "Form Name" , sortKey : "formName" , width : 200 , resizable : true } ,
59+ { name : "Submitter" , sortKey : "createdBy" , width : 200 , resizable : true } ,
60+ {
61+ name : "Submission Date" ,
62+ sortKey : "submissionDate" ,
63+ width : 180 ,
64+ resizable : true ,
65+ } ,
66+ {
67+ name : "Status" ,
68+ sortKey : "applicationStatus" ,
69+ width : 160 ,
70+ resizable : true ,
71+ } ,
72+ { name : "" , sortKey : "actions" , width : 100 } ,
73+ ] ,
74+ [ ]
75+ ) ;
5476
5577 const activeSortKey = sortParams . activeKey ;
56- const activeSortOrder = sortParams ?. [ activeSortKey ] ?. sortOrder || "asc" ;
78+ const activeSortOrder = sortParams ?. [ activeSortKey ] ?. sortOrder ?? "asc" ;
5779
5880 const { data } = useQuery ( {
5981 queryKey : [ "submissions" , page , limit , activeSortKey , activeSortOrder ] ,
60- queryFn : ( ) => getSubmissionList ( limit , page , activeSortOrder , activeSortKey ) ,
82+ queryFn : ( ) =>
83+ getSubmissionList ( limit , page , activeSortOrder , activeSortKey ) ,
6184 keepPreviousData : true ,
6285 staleTime : 0 ,
6386 } ) ;
6487
65- const submissions = data ?. submissions || [ ] ;
66- const totalCount = data ?. totalCount || 0 ;
88+ const submissions = data ?. submissions ?? [ ] ;
89+ const totalCount = data ?. totalCount ?? 0 ;
6790
68- const handleSort = useCallback ( ( key : string ) => {
69- const newOrder = sortParams [ key ] ?. sortOrder === "asc" ? "desc" : "asc" ;
70- const updatedSort = Object . fromEntries (
71- Object . keys ( sortParams ) . map ( ( k ) => [
72- k ,
73- { sortOrder : k === key ? newOrder : "asc" } ,
74- ] )
75- ) ;
76- dispatch ( setAnalizeSubmissionSort ( { ...updatedSort , activeKey : key } ) ) ;
77- } , [ dispatch , sortParams ] ) ;
91+ const handleSort = useCallback (
92+ ( key : string ) => {
93+ const newOrder = sortParams [ key ] ?. sortOrder === "asc" ? "desc" : "asc" ;
94+ const updatedSort = Object . fromEntries (
95+ Object . keys ( sortParams ) . map ( ( k ) => [
96+ k ,
97+ { sortOrder : k === key ? newOrder : "asc" } ,
98+ ] )
99+ ) ;
100+ dispatch ( setAnalizeSubmissionSort ( { ...updatedSort , activeKey : key } ) ) ;
101+ } ,
102+ [ dispatch , sortParams ]
103+ ) ;
78104
79105 const handlePageChange = useCallback (
80106 ( pageNumber ) => {
@@ -83,7 +109,6 @@ const TaskSubmissionList: React.FC = () => {
83109 [ dispatch , limit ]
84110 ) ;
85111
86-
87112 const renderRow = ( row : Submission ) => (
88113 < tr key = { row . id } >
89114 < td > { row . id } </ td >
@@ -112,7 +137,11 @@ const TaskSubmissionList: React.FC = () => {
112137 index : number ,
113138 columnsLength : number ,
114139 currentResizingColumn : any ,
115- handleMouseDown : ( index : number , column : Column , e : React . MouseEvent ) => void
140+ handleMouseDown : (
141+ index : number ,
142+ column : Column ,
143+ e : React . MouseEvent
144+ ) => void
116145 ) => {
117146 const isLast = index === columnsLength - 1 ;
118147 const headerKey = column . sortKey || `col-${ index } ` ;
@@ -140,11 +169,17 @@ const TaskSubmissionList: React.FC = () => {
140169 ) : (
141170 column . name && t ( column . name )
142171 ) }
143-
144172 { column . resizable && (
145173 < div
146- className = { `column-resizer ${ currentResizingColumn ?. sortKey === column . sortKey ? "resizing" : "" } ` }
174+ className = { `column-resizer ${
175+ currentResizingColumn ?. sortKey === column . sortKey
176+ ? "resizing"
177+ : ""
178+ } `}
147179 onMouseDown = { ( e ) => handleMouseDown ( index , column , e ) }
180+ tabIndex = { 0 }
181+ role = "separator"
182+ aria-orientation = "horizontal"
148183 data-testid = { `column-resizer-${ column . sortKey } ` }
149184 aria-label = { t ( "Resize {{columnName}} column" , {
150185 columnName : t ( column . name ) ,
@@ -165,15 +200,22 @@ const TaskSubmissionList: React.FC = () => {
165200 return (
166201 < div className = "container-wrapper" data-testid = "table-container-wrapper" >
167202 < div className = "table-outer-container" >
168- < div className = "table-scroll-wrapper resizable-scroll" ref = { scrollWrapperRef } >
203+ < div
204+ className = "table-scroll-wrapper resizable-scroll"
205+ ref = { scrollWrapperRef }
206+ >
169207 < div className = "resizable-table-container" >
170208 < ReusableResizableTable
171209 columns = { columns }
172210 data = { submissions }
173211 renderRow = { renderRow }
174212 renderHeaderCell = { renderHeaderCell }
175- emptyMessage = { t ( "No submissions have been found. Try a different filter combination or contact your admin." ) }
176- onColumnResize = { ( newWidths ) => console . log ( "Column resized:" , newWidths ) }
213+ emptyMessage = { t (
214+ "No submissions have been found. Try a different filter combination or contact your admin."
215+ ) }
216+ onColumnResize = { ( newWidths ) =>
217+ console . log ( "Column resized:" , newWidths )
218+ }
177219 tableClassName = "resizable-table"
178220 headerClassName = "resizable-header"
179221 containerClassName = "resizable-table-container"
0 commit comments