refactor(frontend): add CONNECTION_STATE and SUGGESTION_TYPE constants

- Add CONNECTION_STATE (disconnected, connecting, connected, failed)
- Add SUGGESTION_TYPE (toBeRecorded, toRecord)
- Update useWebRTC.js to use CONNECTION_STATE
- Update MatchChatPage.jsx to use CONNECTION_STATE
- Update RecordingTab.jsx to use SUGGESTION_TYPE
This commit is contained in:
Radosław Gierwiało
2025-11-23 22:28:54 +01:00
parent b3a6d39d7a
commit 408317b974
5 changed files with 54 additions and 28 deletions

View File

@@ -2,7 +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';
import { SUGGESTION_STATUS, SUGGESTION_TYPE } from '../../constants';
/**
* RecordingTab - Main component for managing recording partnerships
@@ -199,7 +199,7 @@ const RecordingTab = ({ slug, event, myHeats }) => {
<SuggestionCard
key={suggestion.id || suggestion.heat?.id}
suggestion={suggestion}
type="toBeRecorded"
type={SUGGESTION_TYPE.TO_BE_RECORDED}
onAccept={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.ACCEPTED)}
onReject={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.REJECTED)}
/>
@@ -225,7 +225,7 @@ const RecordingTab = ({ slug, event, myHeats }) => {
<SuggestionCard
key={suggestion.id || suggestion.heat?.id}
suggestion={suggestion}
type="toRecord"
type={SUGGESTION_TYPE.TO_RECORD}
onAccept={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.ACCEPTED)}
onReject={() => handleUpdateStatus(suggestion.id, SUGGESTION_STATUS.REJECTED)}
/>
@@ -273,8 +273,8 @@ const SuggestionCard = ({ suggestion, type, onAccept, onReject }) => {
? `${heat.division?.abbreviation || '?'} ${heat.competitionType?.abbreviation || '?'} H${heat.heatNumber}`
: 'Unknown heat';
const person = type === 'toBeRecorded' ? recorder : dancer;
const personLabel = type === 'toBeRecorded' ? 'Nagrywa Cie:' : 'Nagrywasz:';
const person = type === SUGGESTION_TYPE.TO_BE_RECORDED ? recorder : dancer;
const personLabel = type === SUGGESTION_TYPE.TO_BE_RECORDED ? 'Nagrywa Cie:' : 'Nagrywasz:';
// Status badge
const getStatusBadge = () => {