ChemPal Documentation - v1.18.0
    Preparing search index...
    • Chip in the results header showing how many searched suppliers finished cleanly. Clicking it lists every supplier by outcome, so a failed or throttled supplier is visible instead of silently missing from the table.

      Returns null | Element

      The chip and its popover, or nothing when no outcomes are known.

      <SupplierStatusChip outcomes={supplierOutcomes} />
      
      export function SupplierStatusChip({ outcomes }: SupplierStatusChipProps) {
      const [anchor, setAnchor] = useState<HTMLElement | null>(null);
      const groups = useMemo(() => groupOutcomes(outcomes), [outcomes]);
      if (outcomes.length === 0) return null;

      const problems = outcomes.filter((o) => PROBLEM_STATUSES.includes(o.status)).length;
      const responded = outcomes.length - problems;

      return (
      <>
      <Chip
      size="small"
      variant="outlined"
      color={problems > 0 ? 'warning' : 'default'}
      label={i18n('supplier_status_summary', [String(responded), String(outcomes.length)])}
      onClick={(event) => setAnchor(event.currentTarget)}
      aria-label={i18n('supplier_status_aria')}
      aria-haspopup="dialog"
      />
      <Popover
      open={anchor !== null}
      anchorEl={anchor}
      onClose={() => setAnchor(null)}
      anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
      >
      <Box sx={{ p: 1.5, maxWidth: 360, maxHeight: 360, overflowY: 'auto' }}>
      {groups.map(({ status, items }) => (
      <Box key={status} sx={{ mb: 1, '&:last-child': { mb: 0 } }}>
      <Typography variant="subtitle2">
      {statusHeading(status)} ({items.length})
      </Typography>
      <Typography variant="body2" color="text.secondary">
      {items
      .map((item) =>
      item.resultCount > 0 ? `${item.supplier} (${item.resultCount})` : item.supplier,
      )
      .join(', ')}
      </Typography>
      </Box>
      ))}
      </Box>
      </Popover>
      </>
      );
      }