mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
\o/ get rid of state warning on modal by wrapping in a container
This commit is contained in:
parent
d878b8466e
commit
72ea1ab654
1 changed files with 31 additions and 20 deletions
|
@ -1,29 +1,40 @@
|
|||
import React, { PropTypes, Component } from 'react';
|
||||
import { composeWithTracker } from 'react-komposer';
|
||||
import { Button, Modal } from 'react-bootstrap';
|
||||
import Router from '../router.js';
|
||||
|
||||
import NovaForm from "meteor/nova:forms";
|
||||
|
||||
const UserProfileCheck = ({ currentUser }) => {
|
||||
return currentUser && !Users.hasCompletedProfile(currentUser) ?
|
||||
(<Modal bsSize='large' show={ true }>
|
||||
<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() }>Log Out</Button>
|
||||
</Modal>)
|
||||
: (null);
|
||||
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);
|
||||
};
|
||||
|
||||
const UserProfileCheck = composeWithTracker(composerUserProfileCheck)(UserProfileCheckModal);
|
||||
|
||||
module.exports = UserProfileCheck;
|
||||
export default UserProfileCheck;
|
Loading…
Add table
Reference in a new issue