1 import { Component } from 'inferno';
2 import { PostForm } from './post-form';
3 import { WebSocketService } from '../services';
5 export class CreatePost extends Component<any, any> {
7 constructor(props: any, context: any) {
9 this.handlePostCreate = this.handlePostCreate.bind(this);
13 document.title = `Create Post - ${WebSocketService.Instance.site.name}`;
18 <div class="container">
20 <div class="col-12 col-lg-6 offset-lg-3 mb-4">
21 <h5>Create a Post</h5>
22 <PostForm onCreate={this.handlePostCreate} prevCommunityName={this.prevCommunityName} />
29 get prevCommunityName(): string {
30 if (this.props.match.params.name) {
31 return this.props.match.params.name;
32 } else if (this.props.location.state) {
33 let lastLocation = this.props.location.state.prevPath;
34 if (lastLocation.includes("/c/")) {
35 return lastLocation.split("/c/")[1];
41 handlePostCreate(id: number) {
42 this.props.history.push(`/post/${id}`);