From 185c485ec7fe192667946ece8411da0d33ecaf83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gierwia=C5=82o?= Date: Sun, 23 Nov 2025 22:11:43 +0100 Subject: [PATCH] refactor(frontend): extract MatchCard component from MatchesPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create components/matches/MatchCard.jsx (119 lines) - Create components/matches/index.js barrel export - Reduce MatchesPage.jsx from 349 → 240 lines (-31%) --- frontend/src/components/matches/MatchCard.jsx | 118 ++++++++++++++++++ frontend/src/components/matches/index.js | 1 + frontend/src/pages/MatchesPage.jsx | 115 +---------------- 3 files changed, 122 insertions(+), 112 deletions(-) create mode 100644 frontend/src/components/matches/MatchCard.jsx create mode 100644 frontend/src/components/matches/index.js diff --git a/frontend/src/components/matches/MatchCard.jsx b/frontend/src/components/matches/MatchCard.jsx new file mode 100644 index 0000000..5c4223f --- /dev/null +++ b/frontend/src/components/matches/MatchCard.jsx @@ -0,0 +1,118 @@ +import { Link } from 'react-router-dom'; +import { MessageCircle, Check, X, Loader2, Calendar, MapPin } from 'lucide-react'; + +/** + * Match card for matches list page + * Shows match details with accept/reject/chat actions + */ +const MatchCard = ({ match, onAccept, onReject, onOpenChat, processing }) => { + const isIncoming = !match.isInitiator && match.status === 'pending'; + const isOutgoing = match.isInitiator && match.status === 'pending'; + const isAccepted = match.status === 'accepted'; + + return ( +
+
+
+
+ + {match.partner.username} + +
+ +

+ {match.partner.firstName && match.partner.lastName + ? `${match.partner.firstName} ${match.partner.lastName}` + : match.partner.username} +

+ +

@{match.partner.username}

+
+
+ +
+
+ + {match.event.name} +
+
+ + {match.event.location} +
+
+ +
+ {isIncoming && ( + + Incoming Request + + )} + {isOutgoing && ( + + Sent Request + + )} + {isAccepted && ( + + Active Match + + )} +
+
+ +
+ {isIncoming && ( + <> + + + + )} + + {isOutgoing && ( + + )} + + {isAccepted && ( + + )} +
+
+
+ ); +}; + +export default MatchCard; diff --git a/frontend/src/components/matches/index.js b/frontend/src/components/matches/index.js new file mode 100644 index 0000000..ab331b7 --- /dev/null +++ b/frontend/src/components/matches/index.js @@ -0,0 +1 @@ +export { default as MatchCard } from './MatchCard'; diff --git a/frontend/src/pages/MatchesPage.jsx b/frontend/src/pages/MatchesPage.jsx index 189a200..8b4d0e3 100644 --- a/frontend/src/pages/MatchesPage.jsx +++ b/frontend/src/pages/MatchesPage.jsx @@ -1,10 +1,11 @@ import { useState, useEffect } from 'react'; -import { useNavigate, Link } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import Layout from '../components/layout/Layout'; import { useAuth } from '../contexts/AuthContext'; import { matchesAPI } from '../services/api'; -import { MessageCircle, Check, X, Loader2, Users, Calendar, MapPin } from 'lucide-react'; +import { Loader2, Users } from 'lucide-react'; import { connectSocket, disconnectSocket, getSocket } from '../services/socket'; +import { MatchCard } from '../components/matches'; const MatchesPage = () => { const { user } = useAuth(); @@ -236,114 +237,4 @@ const MatchesPage = () => { ); }; -const MatchCard = ({ match, onAccept, onReject, onOpenChat, processing }) => { - const isIncoming = !match.isInitiator && match.status === 'pending'; - const isOutgoing = match.isInitiator && match.status === 'pending'; - const isAccepted = match.status === 'accepted'; - - return ( -
-
-
-
- - {match.partner.username} - -
- -

- {match.partner.firstName && match.partner.lastName - ? `${match.partner.firstName} ${match.partner.lastName}` - : match.partner.username} -

- -

@{match.partner.username}

-
-
- -
-
- - {match.event.name} -
-
- - {match.event.location} -
-
- -
- {isIncoming && ( - - Incoming Request - - )} - {isOutgoing && ( - - Sent Request - - )} - {isAccepted && ( - - Active Match - - )} -
-
- -
- {isIncoming && ( - <> - - - - )} - - {isOutgoing && ( - - )} - - {isAccepted && ( - - )} -
-
-
- ); -}; - export default MatchesPage;