import React from 'react';
import { Text, View } from 'react-native';
import colors from '../../config/colors.json';

const FormMessage = ({ error, successMsg }) => {
  if (error) {
    return (
      <View>
        <Text style={styles.errorTextStyle}>
          {error}
        </Text>
      </View>
    );
  } else if (successMsg) {
    return (
      <View>
        <Text style={styles.successTextStyle}>
          {successMsg}
        </Text>
      </View>
    );
  }
  return <View style={{ height: 40 }} />;
};

const styles = {
  errorTextStyle: {
    fontSize: 20,
    alignSelf: 'center',
    color: colors.red,
    marginVertical: 10
  },
  successTextStyle: {
    fontSize: 20,
    alignSelf: 'center',
    color: colors.darkGreen,
    marginVertical: 10
  }
};

export { FormMessage };
