1 import { Component } from 'inferno';
2 import { PostForm } from './post-form';
3 import { WebSocketService } from '../services';
4 import { i18n } from '../i18next';
5 import { T } from 'inferno-i18next';
7 export class CreatePost extends Component<any, any> {
9 constructor(props: any, context: any) {
10 super(props, context);
11 this.handlePostCreate = this.handlePostCreate.bind(this);
15 document.title = `${i18n.t('create_post')} - ${WebSocketService.Instance.site.name}`;
20 <div class="container">
22 <div class="col-12 col-lg-6 offset-lg-3 mb-4">
23 <h5><T i18nKey="create_post">#</T></h5>
24 <PostForm onCreate={this.handlePostCreate} prevCommunityName={this.prevCommunityName} />
31 get prevCommunityName(): string {
32 if (this.props.match.params.name) {
33 return this.props.match.params.name;
34 } else if (this.props.location.state) {
35 let lastLocation = this.props.location.state.prevPath;
36 if (lastLocation.includes("/c/")) {
37 return lastLocation.split("/c/")[1];
43 handlePostCreate(id: number) {
44 this.props.history.push(`/post/${id}`);