refactor(frontend): replace status string literals with constants

- Create constants/statuses.js with MATCH_STATUS, SUGGESTION_STATUS, MATCH_FILTER
- Update MatchCard, MatchesPage, HistoryPage, RatePartnerPage to use MATCH_STATUS
- Update RecordingTab to use SUGGESTION_STATUS
- Update Navbar to use MATCH_STATUS for API calls
This commit is contained in:
Radosław Gierwiało
2025-11-23 22:21:12 +01:00
parent 93ff331bfb
commit b3a6d39d7a
8 changed files with 64 additions and 29 deletions

View File

@@ -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)}
/>
))}
</div>
@@ -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)}
/>
))}
</div>
@@ -278,21 +279,21 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
// Status badge
const getStatusBadge = () => {
switch (status) {
case 'accepted':
case SUGGESTION_STATUS.ACCEPTED:
return (
<span className="inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-green-100 text-green-800 rounded">
<CheckCircle className="w-3 h-3" />
Zaakceptowano
</span>
);
case 'rejected':
case SUGGESTION_STATUS.REJECTED:
return (
<span className="inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-red-100 text-red-800 rounded">
<XCircle className="w-3 h-3" />
Odrzucono
</span>
);
case 'not_found':
case SUGGESTION_STATUS.NOT_FOUND:
return (
<span className="inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-amber-100 text-amber-800 rounded">
<AlertTriangle className="w-3 h-3" />
@@ -305,7 +306,7 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
};
// No recorder found
if (status === 'not_found') {
if (status === SUGGESTION_STATUS.NOT_FOUND) {
return (
<div className="flex items-center justify-between p-3 bg-amber-50 border border-amber-200 rounded-lg">
<div className="flex items-center gap-3">
@@ -346,7 +347,7 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
</div>
<div className="flex items-center gap-2">
{status === 'pending' ? (
{status === SUGGESTION_STATUS.PENDING ? (
<>
<button
onClick={onAccept}