import React, { useState, useEffect } from 'react'; import { TrashIcon } from './icons/TrashIcon'; import { ChevronDownIcon } from './icons/ChevronDownIcon'; interface ProofTypeManagerProps { subChannels: string[]; proofTypesBySubChannel: Record; onAddProofType: (subChannel: string, value: string) => void; onRemoveProofType: (subChannel: string, value: string) => void; disabled: boolean; } export const ProofTypeManager: React.FC = ({ subChannels, proofTypesBySubChannel, onAddProofType, onRemoveProofType, disabled }) => { const [selectedSubChannel, setSelectedSubChannel] = useState(''); const [newItem, setNewItem] = useState(''); useEffect(() => { // If subChannels are available, default to the first one. if (subChannels.length > 0 && !selectedSubChannel) { setSelectedSubChannel(subChannels[0]); } }, [subChannels, selectedSubChannel]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (newItem.trim() && selectedSubChannel) { onAddProofType(selectedSubChannel, newItem.trim()); setNewItem(''); } }; const currentProofTypes = proofTypesBySubChannel[selectedSubChannel] || []; return (

Proof Type Manager

Assign and manage specific proof types for each sub-channel.

setNewItem(e.target.value)} placeholder="New Proof Type..." className="flex-grow p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-oliver-azure focus:border-oliver-azure transition disabled:bg-gray-100 disabled:cursor-not-allowed" disabled={disabled || !selectedSubChannel} />
{currentProofTypes.length > 0 ? (
    {currentProofTypes.map((item) => (
  • {item}
  • ))}
) : (

No proof types configured for
{selectedSubChannel}.

)}
); };