diff --git a/apps/frontend/app/dashboard/page.tsx b/apps/frontend/app/dashboard/page.tsx new file mode 100644 index 0000000..ce58ebc --- /dev/null +++ b/apps/frontend/app/dashboard/page.tsx @@ -0,0 +1,85 @@ +'use client'; + +import { useState } from 'react'; +import StatusTabs from '@/component/dashboard/StatusTabs'; +import EscrowList from '@/component/dashboard/EscrowList'; +import EscrowFilters from '@/component/dashboard/EscrowFilters'; +import { useEscrows } from '../../hooks/useEscrows'; +import { IEscrow } from '@/types/escrow'; + +export default function DashboardPage() { + const [activeTab, setActiveTab] = useState<'all' | 'active' | 'pending' | 'completed' | 'disputed'>('all'); + const [searchQuery, setSearchQuery] = useState(''); + const [sortBy, setSortBy] = useState<'date' | 'amount' | 'deadline'>('date'); + const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc'); + + const { + data: escrowsData, + isLoading, + isError, + hasNextPage, + fetchNextPage, + isFetchingNextPage + } = useEscrows({ + status: activeTab, + search: searchQuery, + sortBy, + sortOrder + }); + + // Flatten the paginated data + const flatEscrows = escrowsData?.pages.flatMap((page: any) => page.escrows) || []; + + // Handle tab changes + const handleTabChange = (tab: 'all' | 'active' | 'pending' | 'completed' | 'disputed') => { + setActiveTab(tab); + }; + + // Handle search + const handleSearchChange = (query: string) => { + setSearchQuery(query); + }; + + // Handle sort change + const handleSortChange = (field: 'date' | 'amount' | 'deadline', order: 'asc' | 'desc') => { + setSortBy(field); + setSortOrder(order); + }; + + return ( +
+ Manage all your escrow agreements in one place +
+