@@ -47,18 +47,18 @@ import { Icon } from '@/components/ui/icon'
4747import { Skeleton } from '@/components/ui/skeleton'
4848
4949import { readableTimestamp , formatToReadable , cn } from '@/lib/utils'
50- import { ACTIVITIES_TYPES , deviceIcons } from '@/lib/constants'
50+ import { LOG_TYPES , deviceIcons } from '@/lib/constants'
5151
52- import { getAllActivities , countActivities } from '@/server/actions/activity '
53- import type { ActivitySelect } from '@/server/types'
52+ import { getAllLogs , countLogs } from '@/server/actions/log '
53+ import type { LogSelect } from '@/server/types'
5454
5555import { useEvents , EventTypes } from '@/hooks/use-events'
5656
5757const Page = ( ) => {
5858 const { userId } = useAuth ( )
5959 const { events } = useEvents ( ( event ) => event . type === EventTypes . REPORT_IMPORTED )
6060
61- const [ activities , setActivities ] = useState < ActivitySelect [ ] > ( [ ] )
61+ const [ logs , setLogs ] = useState < LogSelect [ ] > ( [ ] )
6262 const [ isLoading , setIsLoading ] = useState < boolean > ( true )
6363 const [ searchTerm , setSearchTerm ] = useState < string > ( '' )
6464 const [ currentPage , setCurrentPage ] = useState < number > ( 1 )
@@ -79,26 +79,26 @@ const Page = () => {
7979 setDate ( undefined )
8080 }
8181
82- const fetchActivities = useCallback ( ( ) => {
83- getAllActivities ( { userId : userId as string , currentPage, searchTerm, itemsPerPage } )
82+ const fetchLogs = useCallback ( ( ) => {
83+ getAllLogs ( { userId : userId as string , currentPage, searchTerm, itemsPerPage } )
8484 . then ( ( data ) => {
85- setActivities ( data )
86- countActivities ( { userId : userId as string } ) . then ( ( count ) => setTotal ( count [ 0 ] . count ) )
85+ setLogs ( data )
86+ countLogs ( { userId : userId as string } ) . then ( ( count ) => setTotal ( count [ 0 ] . count ) )
8787 } )
8888 . catch ( ( err ) => console . log ( err ) )
8989 . finally ( ( ) => setIsLoading ( false ) )
9090 } , [ userId , currentPage , searchTerm ] )
9191
9292 useEffect ( ( ) => {
93- fetchActivities ( )
93+ fetchLogs ( )
9494 // eslint-disable-next-line react-hooks/exhaustive-deps
9595 } , [ userId , currentPage , searchTerm , filters ] )
9696
9797 useEffect ( ( ) => {
9898 if ( Array . isArray ( events ) && events . length > 0 ) {
9999 for ( const event of events ) {
100100 if ( event . type === EventTypes . REPORT_IMPORTED ) {
101- fetchActivities ( )
101+ fetchLogs ( )
102102 }
103103 }
104104 }
@@ -110,7 +110,7 @@ const Page = () => {
110110 < section className = 'w-full mx-auto pb-12 md:pb-16 lg:pb-20 gap-6 flex flex-col' >
111111 < Card className = 'w-full' >
112112 < CardHeader >
113- < CardDescription > View and filter activity actions</ CardDescription >
113+ < CardDescription > View and filter log actions</ CardDescription >
114114 </ CardHeader >
115115 < CardContent >
116116 < div className = 'w-full flex flex-col gap-6' >
@@ -121,7 +121,7 @@ const Page = () => {
121121 </ div >
122122 < Input
123123 type = 'text'
124- placeholder = 'Search activity logs...'
124+ placeholder = 'Search logs...'
125125 value = { searchTerm }
126126 onChange = { ( e ) => setSearchTerm ( e . target . value ) }
127127 className = 'pl-10 pr-4 py-2 rounded-md w-full border border-input bg-background focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary'
@@ -150,7 +150,7 @@ const Page = () => {
150150 </ SelectTrigger >
151151 < SelectContent >
152152 < SelectGroup >
153- { ACTIVITIES_TYPES . map ( ( type : string ) => (
153+ { LOG_TYPES . map ( ( type : string ) => (
154154 < SelectItem key = { type } value = { type } >
155155 { formatToReadable ( type ) }
156156 </ SelectItem >
@@ -210,7 +210,7 @@ const Page = () => {
210210 </ DropdownMenu >
211211 </ div >
212212 < div className = 'overflow-x-auto' >
213- < ActivitiesTable isLoading = { isLoading } activities = { activities } />
213+ < ActivitiesTable isLoading = { isLoading } logs = { logs } />
214214 </ div >
215215 < div className = 'flex items-center justify-between mt-6' >
216216 < ActivitiesTablePagination
@@ -227,18 +227,12 @@ const Page = () => {
227227 )
228228}
229229
230- const ActivitiesTable = ( {
231- isLoading,
232- activities
233- } : {
234- isLoading : boolean
235- activities : ActivitySelect [ ]
236- } ) => {
230+ const ActivitiesTable = ( { isLoading, logs } : { isLoading : boolean ; logs : LogSelect [ ] } ) => {
237231 return (
238232 < Table >
239233 < TableHeader >
240234 < TableRow >
241- < TableHead > Activity Type</ TableHead >
235+ < TableHead > Type</ TableHead >
242236 < TableHead > Description</ TableHead >
243237 < TableHead > Timestamp</ TableHead >
244238 < TableHead > Device</ TableHead >
@@ -249,16 +243,14 @@ const ActivitiesTable = ({
249243 < SkeletonLoader />
250244 ) : (
251245 < >
252- { activities . map ( ( activity ) => (
253- < TableRow key = { activity . id } >
254- < TableCell > { formatToReadable ( activity . type ) } </ TableCell >
255- < TableCell > { activity . description } </ TableCell >
256- < TableCell > { readableTimestamp ( activity . created . toString ( ) ) } </ TableCell >
246+ { logs . map ( ( log ) => (
247+ < TableRow key = { log . id } >
248+ < TableCell > { formatToReadable ( log . type ) } </ TableCell >
249+ < TableCell > { log . description } </ TableCell >
250+ < TableCell > { readableTimestamp ( log . created . toString ( ) ) } </ TableCell >
257251 < TableCell >
258252 < Icon
259- name = {
260- deviceIcons [ activity . device as keyof typeof deviceIcons ] as keyof typeof icons
261- }
253+ name = { deviceIcons [ log . device as keyof typeof deviceIcons ] as keyof typeof icons }
262254 size = { 20 }
263255 />
264256 </ TableCell >
0 commit comments