1- import TableTagList from '@/components/table-tag-list/TableTagList' ;
2- import { Badge } from '@/components/ui/badge' ;
3- import { DataTableColumnHeader } from '@/components/ui/DataTable/DataTableColumnHeader' ;
4- import { cn } from '@/lib/utils' ;
5- import { ArrowTopRightOnSquareIcon , ChevronRightIcon } from '@heroicons/react/24/outline' ;
6- import { Link } from '@tanstack/react-router' ;
7- import { format } from 'date-fns' ;
8-
91import { DateTimeFormat } from '@/common/formats' ;
102import {
113 CitizenReportFollowUpStatus ,
124 FormSubmissionFollowUpStatus ,
135 IncidentReportFollowUpStatus ,
146 QuickReportFollowUpStatus ,
157} from '@/common/types' ;
8+ import TableTagList from '@/components/table-tag-list/TableTagList' ;
9+ import { Badge } from '@/components/ui/badge' ;
1610import { Button } from '@/components/ui/button' ;
1711import type { RowData } from '@/components/ui/DataTable/DataTable' ;
12+ import { DataTableColumnHeader } from '@/components/ui/DataTable/DataTableColumnHeader' ;
13+ import { cn } from '@/lib/utils' ;
14+ import { ArrowTopRightOnSquareIcon , ChevronRightIcon } from '@heroicons/react/24/outline' ;
15+ import { Link } from '@tanstack/react-router' ;
1816import type { ColumnDef } from '@tanstack/react-table' ;
17+ import { format } from 'date-fns' ;
18+ import { ArrowDown , ArrowUp , ArrowUpDown } from 'lucide-react' ;
19+ import MediaFilesCell from '../components/MediaFilesCell/MediaFilesCell' ;
1920import { CitizenReportsAggregatedByForm , type CitizenReportByEntry } from '../models/citizen-report' ;
2021import { SubmissionType } from '../models/common' ;
2122import {
@@ -27,7 +28,6 @@ import { IncidentReportByEntry, IncidentReportByForm, IncidentReportByObserver }
2728import { type QuickReport } from '../models/quick-report' ;
2829import type { QuestionExtraData } from '../types' ;
2930import { mapIncidentCategory , mapIncidentReportLocationType , mapQuickReportLocationType } from './helpers' ;
30- import MediaFilesCell from '../components/MediaFilesCell/MediaFilesCell' ;
3131
3232export const formSubmissionsByEntryColumnDefs : ColumnDef < FormSubmissionByEntry & RowData > [ ] = [
3333 {
@@ -518,35 +518,49 @@ export const formSubmissionsByFormColumnDefs: ColumnDef<FormSubmissionByForm & R
518518
519519export const answerExtraInfoColumnDefs : ColumnDef < QuestionExtraData > [ ] = [
520520 {
521- header : ( { column } ) => < DataTableColumnHeader title = 'Type' column = { column } className = 'w-[70px]' /> ,
522- accessorFn : ( row ) => row . type ,
523- id : 'type' ,
524- enableSorting : true ,
525- enableGlobalFilter : true ,
526- cell : ( { row } ) => < div className = 'w-[80px]' > { row . original . type } </ div > ,
527- size : 80 , // fixed width in px
528- minSize : 60 , // minimum allowed width
529- maxSize : 120 , // optional max width
521+ accessorKey : 'type' ,
522+ header : ( ) => < div className = 'w-[90px]' > Type</ div > ,
523+ cell : ( { row } ) => < div className = 'w-[80px]' > { row . getValue ( 'type' ) } </ div > ,
524+ size : 80 ,
525+ enableResizing : false ,
530526 } ,
531527 {
532- header : ( { column } ) => < DataTableColumnHeader title = 'Time submitted' className = 'w-[70px]' column = { column } /> ,
533- accessorFn : ( row ) => row . timeSubmitted ,
534- id : 'timeSubmitted' ,
535- enableSorting : true ,
536- enableGlobalFilter : true ,
537- cell : ( { row } ) => < div className = 'w-[80px]' > { format ( row . original . timeSubmitted , DateTimeFormat ) } </ div > ,
538- size : 80 , // fixed width in px
539- minSize : 60 , // minimum allowed width
540- maxSize : 120 , // optional max width
528+ accessorKey : 'timeSubmitted' ,
529+ header : ( { column } ) => {
530+ const isSorted = column . getIsSorted ( ) ;
531+
532+ return (
533+ < Button variant = 'ghost' onClick = { ( ) => column . toggleSorting ( column . getIsSorted ( ) === 'asc' ) } >
534+ Time submitted
535+ { isSorted === 'asc' ? (
536+ < ArrowUp className = 'w-4 h-4' />
537+ ) : isSorted === 'desc' ? (
538+ < ArrowDown className = 'w-4 h-4' />
539+ ) : (
540+ < ArrowUpDown className = 'w-4 h-4' />
541+ ) }
542+ </ Button >
543+ ) ;
544+ } ,
545+ cell : ( { row } ) => {
546+ const formatted = format ( row . original . timeSubmitted , DateTimeFormat ) ;
547+
548+ return < div className = '' > { formatted } </ div > ;
549+ } ,
550+ size : 80 ,
551+ enableResizing : false ,
541552 } ,
553+
542554 {
543- header : ( { column } ) => < DataTableColumnHeader title = 'Preview' column = { column } /> ,
544555 id : 'preview' ,
545556 enableSorting : false ,
546557 enableGlobalFilter : false ,
547558 cell : ( { row } ) => (
548- < div > { row . original . type === 'Note' ? row . original . text : < MediaFilesCell attachment = { row . original } /> } </ div >
559+ < div className = 'w-full' >
560+ { row . original . type === 'Note' ? row . original . text : < MediaFilesCell attachment = { row . original } /> }
561+ </ div >
549562 ) ,
563+ size : 300 ,
550564 } ,
551565] ;
552566
0 commit comments