import { FC, ReactElement } from 'react'; import { useNavigate } from 'react-router'; import { useWinners } from '@imphnen-frontend-service/service'; const WinnerPage: FC = (): ReactElement => { const navigate = useNavigate(); const { data, isLoading, error } = useWinners(); const winners = data?.data ?? []; if (isLoading) { return (
Loading winners...
); } if (error) { return (
⚠️

Error Loading Winners

Unable to load winners at this time. Please try again later.

); } // Sort winners by rank const sortedWinners = [...winners].sort((a, b) => a.rank - b.rank); // Medal emojis for top 3 const getMedalEmoji = (rank: number) => { switch (rank) { case 1: return '🥇'; case 2: return '🥈'; case 3: return '🥉'; default: return '🏆'; } }; // Get rank color const getRankColor = (rank: number) => { switch (rank) { case 1: return 'from-yellow-400 to-yellow-600'; case 2: return 'from-gray-300 to-gray-500'; case 3: return 'from-amber-600 to-amber-800'; default: return 'from-blue-500 to-blue-700'; } }; return (
{/* Header */}
🏆

Hackathon Winners

Congratulations to all the winning teams!

{/* Winners List */}
{winners.length === 0 ? (
🎯

No Winners Announced Yet

Winners will be announced here once the hackathon concludes.

) : (
{/* Top 3 Winners - Mobile View */}
{[1, 2, 3].map((position) => { const winner = sortedWinners[position - 1]; if(!winner) return null; return (
{getMedalEmoji(winner.rank)}
{winner.team.logo && ( {`${winner.team.name} )}

{winner.team.name}

{winner.team.city}

); })}
{/* Top 3 Winners - Tablet/Desktop Podium View */}
{[2, 1, 3].map((position) => { const winner = sortedWinners[position - 1]; if(!winner) return null; return (
{getMedalEmoji(winner.rank)}
{/* Team Logo */} {winner.team.logo && ( {`${winner.team.name} )}

{winner.team.name}

{winner.team.city}

{/* Podium */}
#{winner.rank}
); })}
{/* Ranks 4-23: Prize Winners */} {sortedWinners.filter((w) => w.rank >= 4 && w.rank <= 23).length > 0 && (

Favorite

{sortedWinners .filter((w) => w.rank >= 4 && w.rank <= 23) .map((winner) => (
#{winner.rank}
{winner.team.logo && ( {`${winner.team.name} )}

{winner.team.name}

{winner.team.city}

🎁 Prize Winner
))}
)} {/* Rank 24+: Remaining Participants */} {sortedWinners.filter((w) => w.rank >= 24).length > 0 && (

All Participants

{sortedWinners .filter((w) => w.rank >= 24) .map((participant) => (
#{participant.rank}
{participant.team.logo && ( {`${participant.team.name} )}

{participant.team.name}

{participant.team.city}

))}
)}
)}
{/* Footer Info */} {winners.length > 0 && (

Congratulations! 🎉

Thank you to all participants for making this hackathon a success. Every project and idea contributed to an incredible showcase of innovation and creativity.

)}
); }; export default WinnerPage;