import React, { useEffect, useState } from 'react'; import { proteinApi } from '../../../api/protein'; interface FunctionPanelProps { pdbId: string; chainId: string; } const FunctionPanel: React.FC = ({ pdbId, chainId }) => { const [functions, setFunctions] = useState(null); const [loading, setLoading] = useState(true); const [notFound, setNotFound] = useState(false); useEffect(() => { let cancelled = false; setLoading(true); setNotFound(false); setFunctions(null); proteinApi.getChainFunctions(pdbId, chainId) .then(fns => { if (!cancelled) setFunctions(fns); }) .catch(() => { if (!cancelled) setNotFound(true); }) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, [pdbId, chainId]); return (
{/* Header */}

Ranked Functions

{functions && ( {functions.length} annotation{functions.length !== 1 ? 's' : ''} )}
{/* Scrollable body */}
{loading && (

Loading functions…

)} {!loading && (notFound || (functions && functions.length === 0)) && (

No functional annotation available

)} {!loading && functions && functions.length > 0 && (
    {functions.map((fn, idx) => (
  1. {idx + 1} {fn}
  2. ))}
)}
); }; export default FunctionPanel;