-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Create and Delete mutations for Post
- Loading branch information
1 parent
311ff6c
commit 40a657d
Showing
7 changed files
with
119 additions
and
7 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
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
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,27 @@ | ||
import React, { Component } from 'react'; | ||
import { List, Row, Button, Icon, Col } from 'antd'; | ||
const Item = List.Item; | ||
|
||
const Controls = () => ( | ||
<Row gutter={16}> | ||
<Button> | ||
<Icon type="edit" /> | ||
</Button> | ||
<Button> | ||
<Icon type="delete" /> | ||
</Button> | ||
</Row> | ||
); | ||
|
||
export default ({ item }) => ( | ||
<Item actions={[(<Col> | ||
<Controls /> | ||
</Col>)]}> | ||
<Row> | ||
<Item.Meta | ||
title={<a href="#">{item.title}</a>} | ||
description={item.truncatedcontent} | ||
/> | ||
</Row> | ||
</Item> | ||
); |
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,48 @@ | ||
import React, { Component } from 'react'; | ||
import { graphql } from 'react-apollo'; | ||
import gql from 'graphql-tag'; | ||
import { Spin, Icon, Alert, List } from 'antd'; | ||
|
||
import ShortBlogpost from './ShortBlogpost'; | ||
|
||
const query = gql` | ||
query { | ||
allPosts{ | ||
_id, | ||
title, | ||
truncatedcontent | ||
} | ||
} | ||
`; | ||
|
||
|
||
const loader = <Icon type="loading" style={{ fontSize: 24 }} spin />; | ||
|
||
class ShortBlogpostContainer extends Component { | ||
render() { | ||
const { error, loading, allPosts } = this.props.data; | ||
|
||
if (error) { | ||
return <Alert message="Something happened" type="error" /> | ||
} | ||
|
||
if (loading) { | ||
return <Spin indicator={loader} />; | ||
} | ||
|
||
return ( | ||
<div> | ||
<List | ||
className="list" | ||
itemLayout="horizontal" | ||
dataSource={allPosts} | ||
renderItem={item => ( | ||
<ShortBlogpost item={item} /> | ||
)} | ||
/> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default graphql(query)(props => <ShortBlogpostContainer {...props}/>); |
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