-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResultsTable.tsx
77 lines (74 loc) · 3.15 KB
/
ResultsTable.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import { Download, Loader2 } from 'lucide-react';
import { SearchResult } from '../types';
interface ResultsTableProps {
results: SearchResult[];
onDownload: () => void;
}
export function ResultsTable({ results, onDownload }: ResultsTableProps) {
if (results.length === 0) return null;
return (
<div className="space-y-4">
<div className="flex justify-between items-center">
<h2 className="text-lg font-semibold text-gray-900">Results</h2>
<button
onClick={onDownload}
className="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
>
<Download className="h-4 w-4 mr-2" />
Download CSV
</button>
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Entity
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Extracted Information
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{results.map((result, index) => (
<tr key={index}>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{result.entity}
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{result.status === 'processing' ? (
<div className="flex items-center">
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
Processing...
</div>
) : result.status === 'error' ? (
<span className="text-red-500">{result.error}</span>
) : (
result.extractedInfo
)}
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
${result.status === 'completed' ? 'bg-green-100 text-green-800'
: result.status === 'error' ? 'bg-red-100 text-red-800'
: result.status === 'processing' ? 'bg-yellow-100 text-yellow-800'
: 'bg-gray-100 text-gray-800'
}`}
>
{result.status.charAt(0).toUpperCase() + result.status.slice(1)}
</span>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}