import { useNavigation } from '@react-navigation/native';
import React, { FC } from 'react';
import { View } from 'react-native';

import { NavProps } from '../Routes/Routes';
import Button from './Button';

type props = {
  onClose?: () => void;
  onSubmit: () => void;
  submitText?: string;
};

const FormButtons: FC<props> = ({ onClose, onSubmit, submitText = 'Uložit' }) => {
  const navigation = useNavigation<NavProps>();

  return (
    <View className="mt-4 flex-row justify-between">
      <Button
        variant="ternary"
        onPress={() => {
          onClose && onClose();
          navigation.goBack();
        }}
      >
        Zrušit
      </Button>
      <Button
        variant="primary"
        onPress={() => {
          onSubmit();
        }}
      >
        {submitText}
      </Button>
    </View>
  );
};

export default FormButtons;
