Vulcan/packages/nova-base-components/lib/posts/PostsNewForm.jsx

42 lines
1.2 KiB
React
Raw Normal View History

import { Components, registerComponent, getRawComponent, getFragment, withMessages } from 'meteor/nova:core';
import Posts from "meteor/nova:posts";
import React, { PropTypes, Component } from 'react';
2016-06-10 10:25:38 +09:00
import { intlShape } from 'react-intl';
2016-06-14 10:01:44 +09:00
import { withRouter } from 'react-router'
2016-04-14 10:12:35 +09:00
const PostsNewForm = (props, context) => {
return (
<Components.ShowIf
2016-12-01 16:09:54 +09:00
check={Posts.options.mutations.new.check}
failureComponent={<Components.UsersAccountForm />}
2016-11-04 14:14:19 +01:00
>
<div className="posts-new-form">
<Components.SmartForm
2016-11-04 14:14:19 +01:00
collection={Posts}
mutationFragment={getFragment('PostsPage')}
2016-11-04 14:14:19 +01:00
successCallback={post => {
props.closeModal();
// props.router.push({pathname: Posts.getPageUrl(post)});
2016-11-04 14:14:19 +01:00
props.flash(context.intl.formatMessage({id: "posts.created_message"}), "success");
}}
/>
</div>
</Components.ShowIf>
);
};
2016-11-05 18:37:46 +09:00
PostsNewForm.propTypes = {
closeModal: React.PropTypes.func,
2016-11-05 18:37:46 +09:00
router: React.PropTypes.object,
2016-11-07 11:46:58 +09:00
flash: React.PropTypes.func,
2016-11-05 18:37:46 +09:00
}
2016-04-14 10:12:35 +09:00
PostsNewForm.contextTypes = {
2016-11-08 14:56:48 +09:00
closeCallback: React.PropTypes.func,
2016-06-10 10:25:38 +09:00
intl: intlShape
};
PostsNewForm.displayName = "PostsNewForm";
registerComponent('PostsNewForm', PostsNewForm, withRouter, withMessages);