diff --git a/apps/hackathon/src/app/teams/browse/page.tsx b/apps/hackathon/src/app/teams/browse/page.tsx index d086b5e..223da24 100644 --- a/apps/hackathon/src/app/teams/browse/page.tsx +++ b/apps/hackathon/src/app/teams/browse/page.tsx @@ -14,7 +14,33 @@ import { zodResolver } from '@hookform/resolvers/zod'; import { CitySelect } from '../../../components/city-select'; import { Icon } from '@iconify/react'; -const TEAMS_PER_PAGE = 12; +const DEFAULT_PER_PAGE = 12; +const PER_PAGE_OPTIONS = [6, 12, 24, 48]; + +// Skeleton card component for loading state +const TeamCardSkeleton: FC = () => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+); const BrowseTeamsPage: FC = (): ReactElement => { const navigate = useNavigate(); @@ -24,6 +50,7 @@ const BrowseTeamsPage: FC = (): ReactElement => { const [selectedTeamId, setSelectedTeamId] = useState(null); const [showJoinModal, setShowJoinModal] = useState(false); const [currentPage, setCurrentPage] = useState(1); + const [perPage, setPerPage] = useState(DEFAULT_PER_PAGE); // Debounce search term and reset page useEffect(() => { @@ -45,7 +72,7 @@ const BrowseTeamsPage: FC = (): ReactElement => { isFetching, } = useTeams({ page: currentPage, - limit: TEAMS_PER_PAGE, + limit: perPage, search: debouncedSearch, city: selectedCity || undefined, visibility: ETeamVisibility.PUBLIC, @@ -177,16 +204,17 @@ const BrowseTeamsPage: FC = (): ReactElement => { {/* Teams Count */} {!isLoading && total > 0 && (
- Showing {(currentPage - 1) * TEAMS_PER_PAGE + 1}- - {Math.min(currentPage * TEAMS_PER_PAGE, total)} of {total} teams + Showing {(currentPage - 1) * perPage + 1}- + {Math.min(currentPage * perPage, total)} of {total} teams
)} {/* Teams List */} - {isLoading ? ( -
- -

Loading teams...

+ {isLoading || isFetching ? ( +
+ {Array.from({ length: perPage }).map((_, index) => ( + + ))}
) : teams.length === 0 ? (
@@ -199,7 +227,7 @@ const BrowseTeamsPage: FC = (): ReactElement => {
) : ( <> -
+
{teams.map((team: any) => (
{
{/* Pagination */} - {totalPages > 1 && ( + {(totalPages > 1 || total > 6) && (
-
- + {totalPages > 1 && ( +
+ -
- {getPageNumbers().map((page, index) => - typeof page === 'string' ? ( - - ... - - ) : ( - - ) - )} +
+ {getPageNumbers().map((page, index) => + typeof page === 'string' ? ( + + ... + + ) : ( + + ) + )} +
+ +
+ )} - +
+ {totalPages > 1 && ( + + Page {currentPage} of {totalPages} + + )} + +
+ Show: + +
- - - Page {currentPage} of {totalPages} -
)}