import React from "react";
import { TouchableOpacity } from "react-native";

import { View } from "../View";
import { ButtonPropsType } from "./Button";

const BaseButton = (props: ButtonPropsType) => {
  const {
    accessibilityLabel,
    accessibilityRole,
    disabled,
    href,
    onPress,
    children,
    style,
    ...rest
  } = props;
  return href ? (
    <View
      accessibilityLabel={accessibilityLabel}
      accessibilityRole={accessibilityRole}
      style={style}
      {...rest}
    >
      {children}
    </View>
  ) : (
    <TouchableOpacity
      accessibilityLabel={accessibilityLabel}
      accessibilityRole={accessibilityRole}
      disabled={disabled}
      onPress={onPress}
      style={style}
      {...rest}
    >
      {children}
    </TouchableOpacity>
  );
};

export default BaseButton;
