import React from 'react';
import PropTypes from 'prop-types';
import { Text, View } from 'react-native';

import CreateProfile from '../components/Profile/CreateProfile.js';

import styles from './Register.styles.js';

export default function Register({ doRegistration, navigation }) {
    const title = 'Register';

    const _doRegistration = (profile) => {
        if (!profile) {
            return;
        }

        doRegistration(profile);
    };

    return (
        <View style={styles.container}>
            <Text style={styles.heading}>{title}</Text>
            <CreateProfile
                cancelEditAction={() => navigation.goBack()}
                saveProfileAction={_doRegistration}
                showPasswordEntry
            />
        </View>
    );
}

Register.propTypes = {
    doRegistration: PropTypes.func.isRequired,
};
