22
33import React from 'react' ;
44import { useTranslation } from '@/hooks/use-translation' ;
5- import {
6- Select ,
7- SelectContent ,
8- SelectItem ,
9- SelectTrigger ,
10- SelectValue
11- } from '@/components/ui/select' ;
5+ import { SelectWrapper } from '@/components/ui/select-wrapper' ;
126import { formatDistanceToNow } from 'date-fns' ;
137import { Loader2 } from 'lucide-react' ;
148import { TypographySmall , TypographyMuted } from '@/components/ui/typography' ;
159import { DahboardUtilityHeader } from '@/components/layout/dashboard-page-header' ;
1610import PaginationWrapper from '@/components/ui/pagination' ;
17- import {
18- Table ,
19- TableBody ,
20- TableCell ,
21- TableHead ,
22- TableHeader ,
23- TableRow
24- } from '@/components/ui/table' ;
11+ import { DataTable , TableColumn } from '@/components/ui/data-table' ;
2512import { ActivityMessage } from '@/redux/types/audit' ;
2613import useActivities , {
2714 ActivityListProps ,
@@ -77,18 +64,13 @@ function ActivityList({
7764 searchPlaceHolder = "Search activities..."
7865 >
7966 { showFilters && (
80- < Select value = { resourceType } onValueChange = { handleResourceTypeChange } >
81- < SelectTrigger className = "w-full sm:w-48" >
82- < SelectValue placeholder = "Filter by resource" />
83- </ SelectTrigger >
84- < SelectContent >
85- { resourceTypeOptions . map ( ( option ) => (
86- < SelectItem key = { option . value } value = { option . value } >
87- { option . label }
88- </ SelectItem >
89- ) ) }
90- </ SelectContent >
91- </ Select >
67+ < SelectWrapper
68+ value = { resourceType }
69+ onValueChange = { handleResourceTypeChange }
70+ options = { resourceTypeOptions }
71+ placeholder = "Filter by resource"
72+ className = "w-full sm:w-48"
73+ />
9274 ) }
9375 </ DahboardUtilityHeader >
9476 { isLoading ? (
@@ -102,38 +84,7 @@ function ActivityList({
10284 </ div >
10385 ) : activities . length > 0 ? (
10486 < >
105- < div className = "rounded-md border" >
106- < Table >
107- < TableHeader >
108- < TableRow >
109- < TableHead className = "w-[50px]" > </ TableHead >
110- < TableHead > Message</ TableHead >
111- < TableHead > Timestamp</ TableHead >
112- </ TableRow >
113- </ TableHeader >
114- < TableBody >
115- { activities . map ( ( activity : ActivityMessage ) => (
116- < TableRow key = { activity . id } >
117- < TableCell >
118- < div
119- className = { `h-3 w-3 rounded-full ${ getActionColor ( activity . action_color ) } ` }
120- > </ div >
121- </ TableCell >
122- < TableCell className = "max-w-md" >
123- < TypographySmall className = "text-foreground" >
124- { activity . message }
125- </ TypographySmall >
126- </ TableCell >
127- < TableCell >
128- < TypographyMuted className = "text-xs" >
129- { formatDistanceToNow ( new Date ( activity . timestamp ) , { addSuffix : true } ) }
130- </ TypographyMuted >
131- </ TableCell >
132- </ TableRow >
133- ) ) }
134- </ TableBody >
135- </ Table >
136- </ div >
87+ < ActivitiesTable activities = { activities } />
13788
13889 { totalPages > 1 && (
13990 < div className = "mt-6 flex justify-center" >
@@ -155,3 +106,50 @@ function ActivityList({
155106 </ div >
156107 ) ;
157108}
109+
110+ function ActivitiesTable ( { activities } : { activities : ActivityMessage [ ] } ) {
111+ const columns : TableColumn < ActivityMessage > [ ] = [
112+ {
113+ key : 'indicator' ,
114+ title : '' ,
115+ width : '50px' ,
116+ render : ( _ , activity ) => (
117+ < div
118+ className = { `h-3 w-3 rounded-full ${ getActionColor ( activity . action_color ) } ` }
119+ />
120+ )
121+ } ,
122+ {
123+ key : 'message' ,
124+ title : 'Message' ,
125+ dataIndex : 'message' ,
126+ className : 'max-w-md' ,
127+ render : ( message ) => (
128+ < TypographySmall className = "text-foreground" >
129+ { message }
130+ </ TypographySmall >
131+ )
132+ } ,
133+ {
134+ key : 'timestamp' ,
135+ title : 'Timestamp' ,
136+ dataIndex : 'timestamp' ,
137+ render : ( timestamp ) => (
138+ < TypographyMuted className = "text-xs" >
139+ { formatDistanceToNow ( new Date ( timestamp ) , { addSuffix : true } ) }
140+ </ TypographyMuted >
141+ )
142+ }
143+ ] ;
144+
145+ return (
146+ < div className = "rounded-md border" >
147+ < DataTable
148+ data = { activities }
149+ columns = { columns }
150+ showBorder = { false }
151+ hoverable = { false }
152+ />
153+ </ div >
154+ ) ;
155+ }
0 commit comments