import { Alert } from 'react-native';

import { Button } from './button';

export const ConfirmButton = ({
  children,
  confirmLabel,
  destructive = false,
  disabled = false,
  message,
  onConfirm,
  title,
}: {
  children: string;
  confirmLabel: string;
  destructive?: boolean;
  disabled?: boolean;
  message: string;
  onConfirm: () => void;
  title: string;
}) => (
  <Button
    disabled={disabled}
    variant={destructive ? 'danger' : 'outline'}
    onPress={() =>
      Alert.alert(title, message, [
        { style: 'cancel', text: 'Cancel' },
        {
          onPress: onConfirm,
          style: destructive ? 'destructive' : 'default',
          text: confirmLabel,
        },
      ])
    }
  >
    {children}
  </Button>
);
