diff --git a/frontend/src/components/layout/Navbar.jsx b/frontend/src/components/layout/Navbar.jsx
index e6c956d..7d38cef 100644
--- a/frontend/src/components/layout/Navbar.jsx
+++ b/frontend/src/components/layout/Navbar.jsx
@@ -5,6 +5,7 @@ import Avatar from '../common/Avatar';
import { useState, useEffect } from 'react';
import { matchesAPI } from '../../services/api';
import { connectSocket, disconnectSocket, getSocket } from '../../services/socket';
+import { MATCH_STATUS } from '../../constants';
const Navbar = () => {
const { user, logout } = useAuth();
@@ -48,7 +49,7 @@ const Navbar = () => {
const loadPendingMatches = async () => {
try {
- const result = await matchesAPI.getMatches(null, 'pending');
+ const result = await matchesAPI.getMatches(null, MATCH_STATUS.PENDING);
// Only count incoming requests (where user is not the initiator)
const incomingCount = (result.data || []).filter(m => !m.isInitiator).length;
setPendingMatchesCount(incomingCount);
diff --git a/frontend/src/components/matches/MatchCard.jsx b/frontend/src/components/matches/MatchCard.jsx
index 5c4223f..8a6a387 100644
--- a/frontend/src/components/matches/MatchCard.jsx
+++ b/frontend/src/components/matches/MatchCard.jsx
@@ -1,14 +1,15 @@
import { Link } from 'react-router-dom';
import { MessageCircle, Check, X, Loader2, Calendar, MapPin } from 'lucide-react';
+import { MATCH_STATUS } from '../../constants';
/**
* 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';
+ const isIncoming = !match.isInitiator && match.status === MATCH_STATUS.PENDING;
+ const isOutgoing = match.isInitiator && match.status === MATCH_STATUS.PENDING;
+ const isAccepted = match.status === MATCH_STATUS.ACCEPTED;
return (
diff --git a/frontend/src/components/recordings/RecordingTab.jsx b/frontend/src/components/recordings/RecordingTab.jsx
index 44f809a..530dc57 100644
--- a/frontend/src/components/recordings/RecordingTab.jsx
+++ b/frontend/src/components/recordings/RecordingTab.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import { Video, VideoOff, Clock, CheckCircle, XCircle, AlertTriangle, RefreshCw } from 'lucide-react';
import { matchingAPI } from '../../services/api';
import Avatar from '../common/Avatar';
+import { SUGGESTION_STATUS } from '../../constants';
/**
* RecordingTab - Main component for managing recording partnerships
@@ -199,8 +200,8 @@ const RecordingTab = ({ slug, event, myHeats }) => {
key={suggestion.id || suggestion.heat?.id}
suggestion={suggestion}
type="toBeRecorded"
- onAccept={() => handleUpdateStatus(suggestion.id, 'accepted')}
- onReject={() => handleUpdateStatus(suggestion.id, 'rejected')}
+ onAccept={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.ACCEPTED)}
+ onReject={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.REJECTED)}
/>
))}
@@ -225,8 +226,8 @@ const RecordingTab = ({ slug, event, myHeats }) => {
key={suggestion.id || suggestion.heat?.id}
suggestion={suggestion}
type="toRecord"
- onAccept={() => handleUpdateStatus(suggestion.id, 'accepted')}
- onReject={() => handleUpdateStatus(suggestion.id, 'rejected')}
+ onAccept={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.ACCEPTED)}
+ onReject={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.REJECTED)}
/>
))}
@@ -278,21 +279,21 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
// Status badge
const getStatusBadge = () => {
switch (status) {
- case 'accepted':
+ case SUGGESTION_STATUS.ACCEPTED:
return (
Zaakceptowano
);
- case 'rejected':
+ case SUGGESTION_STATUS.REJECTED:
return (
Odrzucono
);
- case 'not_found':
+ case SUGGESTION_STATUS.NOT_FOUND:
return (
@@ -305,7 +306,7 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
};
// No recorder found
- if (status === 'not_found') {
+ if (status === SUGGESTION_STATUS.NOT_FOUND) {
return (
@@ -346,7 +347,7 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
- {status === 'pending' ? (
+ {status === SUGGESTION_STATUS.PENDING ? (
<>
diff --git a/frontend/src/pages/MatchesPage.jsx b/frontend/src/pages/MatchesPage.jsx
index 8b4d0e3..c4d4102 100644
--- a/frontend/src/pages/MatchesPage.jsx
+++ b/frontend/src/pages/MatchesPage.jsx
@@ -6,13 +6,14 @@ import { matchesAPI } from '../services/api';
import { Loader2, Users } from 'lucide-react';
import { connectSocket, disconnectSocket, getSocket } from '../services/socket';
import { MatchCard } from '../components/matches';
+import { MATCH_STATUS, MATCH_FILTER } from '../constants';
const MatchesPage = () => {
const { user } = useAuth();
const navigate = useNavigate();
const [matches, setMatches] = useState([]);
const [loading, setLoading] = useState(true);
- const [filter, setFilter] = useState('all'); // 'all', 'pending', 'accepted'
+ const [filter, setFilter] = useState(MATCH_FILTER.ALL);
const [processingMatchId, setProcessingMatchId] = useState(null);
useEffect(() => {
@@ -108,20 +109,20 @@ const MatchesPage = () => {
};
const handleOpenChat = (match) => {
- if (match.status === 'accepted' && match.roomId) {
+ if (match.status === MATCH_STATUS.ACCEPTED && match.roomId) {
navigate(`/matches/${match.slug}/chat`);
}
};
// Filter matches based on selected filter
const filteredMatches = matches.filter(match => {
- if (filter === 'all') return true;
+ if (filter === MATCH_FILTER.ALL) return true;
return match.status === filter;
});
// Separate pending incoming matches (where user is recipient)
- const pendingIncoming = filteredMatches.filter(m => m.status === 'pending' && !m.isInitiator);
- const otherMatches = filteredMatches.filter(m => !(m.status === 'pending' && !m.isInitiator));
+ const pendingIncoming = filteredMatches.filter(m => m.status === MATCH_STATUS.PENDING && !m.isInitiator);
+ const otherMatches = filteredMatches.filter(m => !(m.status === MATCH_STATUS.PENDING && !m.isInitiator));
return (
@@ -136,9 +137,9 @@ const MatchesPage = () => {
{/* Filter Tabs */}
diff --git a/frontend/src/pages/RatePartnerPage.jsx b/frontend/src/pages/RatePartnerPage.jsx
index dbb992f..73a5136 100644
--- a/frontend/src/pages/RatePartnerPage.jsx
+++ b/frontend/src/pages/RatePartnerPage.jsx
@@ -3,6 +3,7 @@ import { useParams, useNavigate } from 'react-router-dom';
import Layout from '../components/layout/Layout';
import { matchesAPI } from '../services/api';
import { Star, Loader2 } from 'lucide-react';
+import { MATCH_STATUS } from '../constants';
const RatePartnerPage = () => {
const { slug } = useParams();
@@ -24,7 +25,7 @@ const RatePartnerPage = () => {
setMatch(result.data);
// Check if this match can be rated
- if (result.data.status !== 'accepted' && result.data.status !== 'completed') {
+ if (result.data.status !== MATCH_STATUS.ACCEPTED && result.data.status !== MATCH_STATUS.COMPLETED) {
alert('This match must be accepted before rating.');
navigate('/matches');
return;