Adding create community and post buttons from sidebar.

- Fixes #148
This commit is contained in:
Dessalines 2019-05-08 09:07:34 -07:00
parent 2ebdfc8425
commit 26af8fd4a6
4 changed files with 10 additions and 3 deletions

View file

@ -26,7 +26,9 @@ export class CreatePost extends Component<any, any> {
}
get prevCommunityName(): string {
if (this.props.location.state) {
if (this.props.match.params.name) {
return this.props.match.params.name;
} else if (this.props.location.state) {
let lastLocation = this.props.location.state.prevPath;
if (lastLocation.includes("/c/")) {
return lastLocation.split("/c/")[1];

View file

@ -136,6 +136,8 @@ export class Main extends Component<any, MainState> {
</ul>
</div>
}
<Link class="btn btn-sm btn-secondary btn-block mb-3"
to="/create_community">Create a Community</Link>
{this.sidebar()}
</div>
}

View file

@ -117,10 +117,12 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
</ul>
<div>
{community.subscribed
? <button class="btn btn-sm btn-secondary" onClick={linkEvent(community.id, this.handleUnsubscribe)}>Unsubscribe</button>
: <button class="btn btn-sm btn-secondary" onClick={linkEvent(community.id, this.handleSubscribe)}>Subscribe</button>
? <button class="btn btn-sm btn-secondary btn-block mb-3" onClick={linkEvent(community.id, this.handleUnsubscribe)}>Unsubscribe</button>
: <button class="btn btn-sm btn-secondary btn-block mb-3" onClick={linkEvent(community.id, this.handleSubscribe)}>Subscribe</button>
}
</div>
<Link class="btn btn-sm btn-secondary btn-block mb-3"
to={`/create_post/c/${community.name}`}>Create a Post</Link>
{community.description &&
<div>
<hr />

View file

@ -41,6 +41,7 @@ class Index extends Component<any, any> {
<Route path={`/home/type/:type/sort/:sort/page/:page`} component={Main} />
<Route exact path={`/`} component={Main} />
<Route path={`/login`} component={Login} />
<Route path={`/create_post/c/:name`} component={CreatePost} />
<Route path={`/create_post`} component={CreatePost} />
<Route path={`/create_community`} component={CreateCommunity} />
<Route path={`/communities/page/:page`} component={Communities} />