Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joe Lewis
committed
Dec 3, 2018
1 parent
eed5bbd
commit 413a9f3
Showing
6 changed files
with
195 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, {Component} from 'react'; | ||
import {createBrowserHistory} from 'history'; | ||
import {Menu} from 'antd'; | ||
import {Link} from "react-router-dom"; | ||
import Model from '../models.js' | ||
import $ from 'jquery'; | ||
|
||
class HomeMenu extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
// this.history = createBrowserHistory() | ||
// window.historyy = this.history; | ||
this.state = { | ||
selectedKeys: [] | ||
} | ||
} | ||
|
||
componentWillMount() { | ||
var self = this; | ||
window.j = $; | ||
$(window).on('RefreshMenu', function() { | ||
self.setState({selectedKeys: []}) | ||
}) | ||
} | ||
|
||
componentWillUnmount() { | ||
this.unlisten(); | ||
} | ||
|
||
onSelect(item) { | ||
this.setState({selectedKeys: [item.key]}) | ||
} | ||
|
||
render() { | ||
return (<Menu | ||
// theme="dark" | ||
mode="horizontal" | ||
defaultSelectedKeys={[]} | ||
selectedKeys={this.state.selectedKeys} | ||
style={{ lineHeight: '64px' }} | ||
className="writango-menu-container" | ||
onSelect={this.onSelect.bind(this)} | ||
> | ||
<Menu.Item key="posts" ><Link to={"/writes/"+Model.session.user.id}>Posts</Link></Menu.Item> | ||
<Menu.Item key="drafts">Drafts</Menu.Item> | ||
<Menu.Item key="write">Write</Menu.Item> | ||
{/* <Menu.Item key="3">nav 3</Menu.Item> */} | ||
</Menu> | ||
) | ||
} | ||
} | ||
|
||
export default HomeMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, {Component} from "react"; | ||
import Model from "../models.js" | ||
import { List, Card, Icon } from "antd"; | ||
class PostList extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
posts: [] | ||
} | ||
} | ||
|
||
componentWillMount() { | ||
var self = this; | ||
Model.loadPosts(this.props.match.params.username).then(() => { | ||
self.setState({ | ||
posts: Model.posts | ||
}) | ||
}) | ||
} | ||
|
||
render() { | ||
return ( | ||
<Card title="Posts" style={{minHeight: '100vh'}}> | ||
<div className="no-post-placeholder"> | ||
<p><Icon type="smile" style={{margin: '0 10px'}}/>You have no posts yet. <a href="#">Start Writing!</a></p> | ||
</div> | ||
</Card> | ||
|
||
) | ||
} | ||
} | ||
|
||
export default PostList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
import $ from 'jquery'; | ||
/** | ||
* Client DB | ||
* Holds the information necessary for components | ||
* TODO: Use a proper state management library | ||
*/ | ||
var model = { | ||
session: {}, | ||
posts: [], | ||
drafts: [], | ||
currentDoc: {} | ||
}; | ||
|
||
var session = {}; | ||
|
||
var loadSession = function() { | ||
model.loadSession = function() { | ||
return $.get('/session/get').done((resp) => { | ||
session.session_key = resp.session_key; | ||
session.user = resp.user; | ||
model.session.session_key = resp.session_key; | ||
model.session.user = resp.user; | ||
}) | ||
} | ||
|
||
window.session = session; | ||
model.loadPosts = function(userkey) { | ||
return $.get('/posts/@'+userkey).done(resp => { | ||
model.posts = resp.posts; | ||
}) | ||
}; | ||
|
||
|
||
model.loadDrafts = function() { | ||
return $.get('/drafts').done(resp => { | ||
model.drafts = resp.drafts; | ||
}) | ||
}; | ||
|
||
window.model = model; | ||
|
||
export default { | ||
session, | ||
loadSession | ||
}; | ||
export default model; |