parent
2ebdfc8425
commit
26af8fd4a6
4 changed files with 10 additions and 3 deletions
|
@ -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];
|
||||
|
|
|
@ -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>
|
||||
}
|
||||
|
|
|
@ -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 />
|
||||
|
|
|
@ -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} />
|
||||
|
|
Reference in a new issue