2016-04-15 11:09:19 +02:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-04-16 18:02:21 +02:00
|
|
|
import { composeWithTracker } from 'react-komposer';
|
2016-04-15 12:00:53 +02:00
|
|
|
import { Button, Modal } from 'react-bootstrap';
|
2016-04-16 18:02:21 +02:00
|
|
|
import Router from '../router.js';
|
2016-04-15 11:09:19 +02:00
|
|
|
|
|
|
|
import NovaForm from "meteor/nova:forms";
|
|
|
|
|
2016-04-16 18:02:21 +02:00
|
|
|
function composerUserProfileCheck(props, onData) {
|
|
|
|
const currentUser = props.currentUser;
|
|
|
|
const show = currentUser && !Users.hasCompletedProfile(currentUser) ? true : false; // force a bool value
|
|
|
|
onData(null, { currentUser, show });
|
|
|
|
}
|
|
|
|
|
|
|
|
const UserProfileCheckModal = ({currentUser, show}) => {
|
|
|
|
return !!currentUser ?
|
|
|
|
(
|
|
|
|
<Modal bsSize='small' show={ show }>
|
|
|
|
<Modal.Header>
|
|
|
|
<Modal.Title>Complete your Profile</Modal.Title>
|
|
|
|
</Modal.Header>
|
|
|
|
<Modal.Body>
|
|
|
|
<NovaForm
|
|
|
|
currentUser={ currentUser }
|
|
|
|
collection={ Meteor.users }
|
|
|
|
document={ currentUser }
|
|
|
|
methodName="users.edit"
|
|
|
|
labelFunction={ (fieldName)=>Telescope.utils.getFieldLabel(fieldName, Meteor.users) }
|
|
|
|
successCallback={ (user) => Telescope.callbacks.runAsync("profileCompletedAsync", user) }
|
|
|
|
fields={ ["telescope.email"] }
|
|
|
|
/>
|
|
|
|
</Modal.Body>
|
|
|
|
<Button bsStyle="primary" className="complete-profile-logout" onClick={ () => Meteor.logout(() => Router.go('/')) }>Log Out</Button>
|
|
|
|
</Modal>
|
|
|
|
) : (null);
|
2016-04-15 11:09:19 +02:00
|
|
|
};
|
|
|
|
|
2016-04-16 18:02:21 +02:00
|
|
|
const UserProfileCheck = composeWithTracker(composerUserProfileCheck)(UserProfileCheckModal);
|
|
|
|
|
2016-04-15 11:09:19 +02:00
|
|
|
module.exports = UserProfileCheck;
|
|
|
|
export default UserProfileCheck;
|