Created
March 20, 2019 10:04
-
-
Save siddhant1/bbc44ae1404ee3659d5090bf01d66ded to your computer and use it in GitHub Desktop.
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
import React, { Component } from "react"; | |
import { | |
MARK_TODO_COMPLETE, | |
GET_INCOMPLETE_TODOS, | |
GET_ALL_TODOS | |
} from "../queries"; | |
import { Mutation } from "react-apollo"; | |
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | |
import { faCheck } from "@fortawesome/free-solid-svg-icons"; | |
import { Button } from "react-bootstrap"; | |
class MarkTodo extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
} | |
render() { | |
return ( | |
<Mutation | |
mutation={MARK_TODO_COMPLETE} | |
variables={this.props} | |
refetchQueries={[ | |
{ query: GET_INCOMPLETE_TODOS }, | |
{ query: GET_ALL_TODOS } | |
]} | |
> | |
{(update_todos, { data }) => ( | |
<Button | |
onClick={e => { | |
e.preventDefault(); | |
update_todos(); | |
}} | |
> | |
<FontAwesomeIcon icon={faCheck} style={{ color: "green" }} /> | |
</Button> | |
)} | |
</Mutation> | |
); | |
} | |
} | |
export default MarkTodo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment