fix: correction warnings React et gestion erreurs matrice routing
- Ajout React.Fragment avec keys pour éliminer warnings - Import de React pour utiliser React.Fragment - Meilleure gestion erreurs HTTP (status check) - Messages d'erreur plus détaillés avec status code - Logging amélioré pour debugging
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import './AudioRoutingMatrix.css';
|
import './AudioRoutingMatrix.css';
|
||||||
|
|
||||||
const API_URL = import.meta.env.VITE_API_URL || '/api';
|
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000';
|
||||||
|
|
||||||
function AudioRoutingMatrix({ groups, channelNames }) {
|
function AudioRoutingMatrix({ groups, channelNames }) {
|
||||||
const [routing, setRouting] = useState({ inputToGroup: {}, groupToOutput: {}, gains: {} });
|
const [routing, setRouting] = useState({ inputToGroup: {}, groupToOutput: {}, gains: {} });
|
||||||
@@ -14,6 +14,9 @@ function AudioRoutingMatrix({ groups, channelNames }) {
|
|||||||
const loadRouting = async () => {
|
const loadRouting = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_URL}/admin/audio/routing`);
|
const res = await fetch(`${API_URL}/admin/audio/routing`);
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${res.status}`);
|
||||||
|
}
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setRouting(data.routing || { inputToGroup: {}, groupToOutput: {}, gains: {} });
|
setRouting(data.routing || { inputToGroup: {}, groupToOutput: {}, gains: {} });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -34,8 +37,9 @@ function AudioRoutingMatrix({ groups, channelNames }) {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
alert('Configuration de routing sauvegardée!');
|
alert('Configuration de routing sauvegardée!');
|
||||||
} else {
|
} else {
|
||||||
const error = await res.json();
|
const errorText = await res.text();
|
||||||
alert(`Erreur: ${error.error}`);
|
console.error('Erreur serveur:', errorText);
|
||||||
|
alert(`Erreur: ${res.status} - ${errorText}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur sauvegarde routing:', error);
|
console.error('Erreur sauvegarde routing:', error);
|
||||||
@@ -129,8 +133,8 @@ function AudioRoutingMatrix({ groups, channelNames }) {
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
{Array.from({length: 8}, (_, i) => (
|
{Array.from({length: 8}, (_, i) => (
|
||||||
<>
|
<React.Fragment key={`input-row-${i}`}>
|
||||||
<div key={`input-label-${i}`} className="matrix-label-cell">
|
<div className="matrix-label-cell">
|
||||||
{getChannelName('inputs', i)}
|
{getChannelName('inputs', i)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -143,7 +147,7 @@ function AudioRoutingMatrix({ groups, channelNames }) {
|
|||||||
{isInputRoutedToGroup(String(i), group.id) && <span className="checkmark">✓</span>}
|
{isInputRoutedToGroup(String(i), group.id) && <span className="checkmark">✓</span>}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -164,8 +168,8 @@ function AudioRoutingMatrix({ groups, channelNames }) {
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
{groups.map(group => (
|
{groups.map(group => (
|
||||||
<>
|
<React.Fragment key={`group-row-${group.id}`}>
|
||||||
<div key={`group-label-${group.id}`} className="matrix-label-cell">
|
<div className="matrix-label-cell">
|
||||||
{group.name}
|
{group.name}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -178,7 +182,7 @@ function AudioRoutingMatrix({ groups, channelNames }) {
|
|||||||
{isGroupRoutedToOutput(group.id, String(i)) && <span className="checkmark">✓</span>}
|
{isGroupRoutedToOutput(group.id, String(i)) && <span className="checkmark">✓</span>}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user