Files
Eventment/app/components/AppHeader/HeaderContentLeft.js
2019-08-08 20:55:19 -04:00

42 lines
1.0 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import BackIcon from './IconButtons/BackIcon.js';
import EventsIcon from './IconButtons/EventsIcon.js';
export default function HeaderContentLeft({ activeRoute, hasMultipleEvents, navigation }) {
const _goBack = () => {
if (hasActiveEvent) {
navigation.goBack();
return false;
}
console.log('nowhere to go...');
};
const _showEvents = () => {
navigation.navigate('Events');
return false;
};
if (activeRoute === 'Events') {
return <EventsIcon action={_goBack} />;
}
if (activeRoute === 'Profile') {
return <BackIcon action={_goBack} />;
}
return <EventsIcon action={hasMultipleEvents ? _showEvents : null} />;
}
HeaderContentLeft.propTypes = {
activeRoute: PropTypes.string.isRequired,
hasMultipleEvents: PropTypes.bool,
navigation: PropTypes.func.isRequired,
};
HeaderContentLeft.defaultProps = {
hasMultipleEvents: false,
};