import { IconHome, IconRefresh } from '@douyinfe/semi-icons';
import { Button } from '@douyinfe/semi-ui';

export function MapRetryAction({ onRetry, label = '重新加载地图' }: { onRetry: () => void; label?: string }) {
  return <Button
    className="v2-map-retry-action"
    theme="light"
    type="danger"
    size="small"
    icon={<IconRefresh />}
    aria-label={label}
    onClick={onRetry}
  >
    {label}
  </Button>;
}

export function RecoveryActions({
  primaryLabel,
  onPrimary,
  secondaryLabel,
  onSecondary,
  showHome = true
}: {
  primaryLabel: string;
  onPrimary: () => void;
  secondaryLabel?: string;
  onSecondary?: () => void;
  showHome?: boolean;
}) {
  return <footer className="v2-recovery-actions">
    <Button theme="solid" type="primary" icon={<IconRefresh />} aria-label={primaryLabel} onClick={onPrimary}>{primaryLabel}</Button>
    {secondaryLabel && onSecondary ? <Button theme="light" icon={<IconRefresh />} aria-label={secondaryLabel} onClick={onSecondary}>{secondaryLabel}</Button> : null}
    {showHome ? <Button theme="borderless" type="tertiary" icon={<IconHome />} aria-label="返回全局监控" onClick={() => window.location.assign('/monitor')}>返回全局监控</Button> : null}
  </footer>;
}
