Vulcan/packages/nova-base-components/lib/users/UsersEditForm.jsx

40 lines
1.3 KiB
React
Raw Normal View History

import { Components, registerComponent, withCurrentUser, withMessages } from 'meteor/nova:core';
import React, { PropTypes, Component } from 'react';
import { FormattedMessage, intlShape } from 'react-intl';
2016-06-23 15:00:58 +09:00
import Users from 'meteor/nova:users';
2016-11-09 11:55:28 +09:00
const UsersEditForm = (props, context) => {
return (
<Components.ShowIf
check={Users.options.mutations.edit.check}
document={props.terms.documentId ? {_id: props.terms.documentId} : {slug: props.terms.slug}}
failureComponent={<FormattedMessage id="app.noPermission"/>}
>
<div className="page users-edit-form">
<h2 className="page-title users-edit-form-title"><FormattedMessage id="users.edit_account"/></h2>
<Components.SmartForm
collection={Users}
{...props.terms}
2016-12-08 10:23:12 +01:00
successCallback={user => {
props.flash(context.intl.formatMessage({id: "users.edit_success"}, {name: Users.getDisplayName(user)}), 'success')
}}
2016-12-08 11:03:20 +09:00
showRemove={true}
/>
</div>
</Components.ShowIf>
);
};
2016-12-08 11:03:20 +09:00
2016-11-09 11:55:28 +09:00
UsersEditForm.propTypes = {
terms: React.PropTypes.object, // a user is defined by its unique _id or its unique slug
};
2016-02-23 11:34:40 +09:00
2016-11-09 11:55:28 +09:00
UsersEditForm.contextTypes = {
intl: intlShape
};
2016-11-09 11:55:28 +09:00
UsersEditForm.displayName = "UsersEditForm";
registerComponent('UsersEditForm', UsersEditForm, withMessages, withCurrentUser);