forked from VulcanJS/Vulcan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostsNewForm.jsx
41 lines (36 loc) · 1.24 KB
/
PostsNewForm.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Components, registerComponent, getRawComponent, getFragment, withMessages } from 'meteor/nova:core';
import Posts from "meteor/nova:posts";
import React, { PropTypes, Component } from 'react';
import { intlShape } from 'react-intl';
import { withRouter } from 'react-router'
const PostsNewForm = (props, context) => {
return (
<Components.ShowIf
check={Posts.options.mutations.new.check}
failureComponent={<Components.UsersAccountForm />}
>
<div className="posts-new-form">
<Components.SmartForm
collection={Posts}
mutationFragment={getFragment('PostsPage')}
successCallback={post => {
props.closeModal();
// props.router.push({pathname: Posts.getPageUrl(post)});
props.flash(context.intl.formatMessage({id: "posts.created_message"}), "success");
}}
/>
</div>
</Components.ShowIf>
);
};
PostsNewForm.propTypes = {
closeModal: React.PropTypes.func,
router: React.PropTypes.object,
flash: React.PropTypes.func,
}
PostsNewForm.contextTypes = {
closeCallback: React.PropTypes.func,
intl: intlShape
};
PostsNewForm.displayName = "PostsNewForm";
registerComponent('PostsNewForm', PostsNewForm, withRouter, withMessages);