Skip to content

Commit e4a1c3a

Browse files
committed
Pagination improvement
1 parent a291068 commit e4a1c3a

File tree

1 file changed

+44
-31
lines changed

1 file changed

+44
-31
lines changed

frontend-react/src/components/Dashboard.tsx

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -430,40 +430,53 @@ export const Dashboard: React.FC = () => {
430430
<div className="space-y-8">
431431
{/* Results Header */}
432432
<div className="bg-white/80 backdrop-blur-xl rounded-2xl shadow-xl border border-white/50 px-8 py-6">
433-
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
434-
<div>
435-
<h2 className="text-2xl font-bold text-gray-900 mb-2">
436-
{selectedNetwork !== 'all' && (
437-
<span className="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gradient-to-r from-[#1B1EA9] to-[#FF2DAF] text-white mr-2">
438-
{selectedNetwork.toUpperCase()}
439-
</span>
440-
)}
441-
{selectedMessageType === 'all' ? 'All Messages' :
442-
selectedMessageType.split('_').map(word =>
443-
word.charAt(0).toUpperCase() + word.slice(1)
444-
).join(' ')
445-
}
446-
</h2>
447-
{pagination && (
448-
<p className="text-gray-600">
449-
{pagination.totalItems > 0 ? (
450-
<>
451-
Showing <span className="font-semibold text-gray-900">
452-
{((pagination.currentPage - 1) * pagination.pageSize + 1).toLocaleString()}-{Math.min(pagination.currentPage * pagination.pageSize, pagination.totalItems).toLocaleString()}
453-
</span> of{' '}
454-
<span className="font-semibold text-gray-900">{pagination.totalItems.toLocaleString()}</span> messages
455-
</>
456-
) : (
457-
<span className="font-semibold text-gray-900">0 messages</span>
433+
<div className="flex flex-col gap-6">
434+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
435+
<div>
436+
<h2 className="text-2xl font-bold text-gray-900 mb-2">
437+
{selectedNetwork !== 'all' && (
438+
<span className="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gradient-to-r from-[#1B1EA9] to-[#FF2DAF] text-white mr-2">
439+
{selectedNetwork.toUpperCase()}
440+
</span>
458441
)}
459-
</p>
442+
{selectedMessageType === 'all' ? 'All Messages' :
443+
selectedMessageType.split('_').map(word =>
444+
word.charAt(0).toUpperCase() + word.slice(1)
445+
).join(' ')
446+
}
447+
</h2>
448+
{pagination && (
449+
<p className="text-gray-600">
450+
{pagination.totalItems > 0 ? (
451+
<>
452+
Showing <span className="font-semibold text-gray-900">
453+
{((pagination.currentPage - 1) * pagination.pageSize + 1).toLocaleString()}-{Math.min(pagination.currentPage * pagination.pageSize, pagination.totalItems).toLocaleString()}
454+
</span> of{' '}
455+
<span className="font-semibold text-gray-900">{pagination.totalItems.toLocaleString()}</span> messages
456+
</>
457+
) : (
458+
<span className="font-semibold text-gray-900">0 messages</span>
459+
)}
460+
</p>
461+
)}
462+
</div>
463+
464+
{loading && (
465+
<div className="flex items-center gap-3 bg-[#1B1EA9]/10 px-4 py-2 rounded-full">
466+
<div className="animate-spin rounded-full h-5 w-5 border-2 border-[#1B1EA9] border-t-transparent"></div>
467+
<span className="text-sm font-medium text-[#1B1EA9]">Updating...</span>
468+
</div>
460469
)}
461470
</div>
462471

463-
{loading && (
464-
<div className="flex items-center gap-3 bg-[#1B1EA9]/10 px-4 py-2 rounded-full">
465-
<div className="animate-spin rounded-full h-5 w-5 border-2 border-[#1B1EA9] border-t-transparent"></div>
466-
<span className="text-sm font-medium text-[#1B1EA9]">Updating...</span>
472+
{/* Top Pagination */}
473+
{pagination && data.length > 0 && (
474+
<div className="flex justify-center pt-2 border-t border-gray-200/50">
475+
<PaginationComponent
476+
pagination={pagination}
477+
onPageChange={setCurrentPage}
478+
className="[&>div:first-child]:hidden"
479+
/>
467480
</div>
468481
)}
469482
</div>
@@ -513,7 +526,7 @@ export const Dashboard: React.FC = () => {
513526
</div>
514527
)}
515528

516-
{/* Pagination */}
529+
{/* Bottom Pagination */}
517530
{pagination && data.length > 0 && (
518531
<div className="flex justify-center">
519532
<div className="bg-white/80 backdrop-blur-xl rounded-2xl shadow-xl border border-white/50 p-2">

0 commit comments

Comments
 (0)