import { ActionRow, Button } from '../../core';

export type ViewEditorActionsProps = {
  mode: 'create' | 'edit';
  onCancel: () => void;
  onSubmit: () => void | Promise<void>;
  disabled?: boolean;
  busy?: boolean;
  t: (key: string, fallback?: string, values?: Record<string, any>) => string;
};

export function ViewEditorActions({ mode, onCancel, onSubmit, disabled = false, busy = false, t }: ViewEditorActionsProps) {
  return (
    <ActionRow className="ask-pt-2">
      <Button variant="ghost" onClick={onCancel} disabled={busy}>
        {t('common.cancel', 'Cancel')}
      </Button>
      <Button variant="primary" onClick={onSubmit} disabled={disabled || busy}>
        {busy
          ? t('views.creating', 'Creating…')
          : mode === 'edit' ? t('common.save', 'Save') : t('ui.add_view', 'Create')}
      </Button>
    </ActionRow>
  );
}
