import React, { useEffect } from 'react' import { useAppDispatch, useAppSelector } from '../stores/hooks' import { fetch } from '../stores/trials/trialsSlice' import BaseButton from './BaseButton' import BaseButtons from './BaseButtons' import { mdiEye, mdiPlus } from '@mdi/js' import Link from 'next/link' const RecentTrialsTable = () => { const dispatch = useAppDispatch() const { trials, loading } = useAppSelector((state) => state.trials) useEffect(() => { dispatch(fetch({ query: '?limit=5' })) }, [dispatch]) const getStatusColor = (status: string) => { switch (status) { case 'active': return 'bg-emerald-100 text-emerald-800 border-emerald-200' case 'planned': return 'bg-blue-100 text-blue-800 border-blue-200' case 'completed': return 'bg-purple-100 text-purple-800 border-purple-200' case 'draft': return 'bg-gray-100 text-gray-800 border-gray-200' default: return 'bg-gray-50 text-gray-600 border-gray-200' } } return (

Recent Trials

{loading && trials.length === 0 ? ( ) : trials.length > 0 ? ( trials.slice(0, 5).map((trial: any) => ( )) ) : ( )}
Trial Name Code Status Created
Loading trials...
{trial.name} {trial.code || '-'} {trial.status} {new Date(trial.createdAt).toLocaleDateString()}

No trials found in the system.

) } export default RecentTrialsTable