import type { ReactNode } from 'react';
import React from 'react';
import type { StyleProp, ViewStyle } from 'react-native';
import type { ActionIntent } from './StyledSwipeable';
import { StyledRectButton } from './StyledSwipeable';

export interface SwipeableActionProps {
  /**
   * Visual intent color applied to action.
   */
  intent?: ActionIntent;
  /**
   * Callback when the action button is pressed.
   */
  onPress?: () => void;
  /**
   * Action button's content
   */
  children?: ReactNode;
  /**
   * Additional style.
   */
  style?: StyleProp<ViewStyle>;
  /**
   * Testing id of the component.
   */
  testID?: string;
}

const SwipeableAction = ({
  intent = 'primary',
  onPress,
  style,
  children,
  testID,
}: SwipeableActionProps) => (
  <StyledRectButton
    onPress={onPress}
    themeIntent={intent}
    style={style}
    testID={testID}
  >
    {children}
  </StyledRectButton>
);

export default SwipeableAction;
