Created
March 23, 2019 10:34
-
-
Save karannaoh/31133ca68cf11bd45ef731e27f974661 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 from 'react'; | |
import { Query } from 'react-apollo'; | |
import Del from './components/DeleteTodo' | |
import { Alert } from 'reactstrap'; | |
import Mark from './components/MarkDone' | |
import {TODO} from './components/queries' | |
const Todos = () => { | |
return ( | |
<div className="collection-item" > | |
<Query query={TODO}> | |
{({ loading, error, data }) => { | |
if (loading) return "Loading..."; | |
if (error) return (console.log(error)); | |
if (data.todo.length){ | |
return data.todo.map(({ id, todo, done}) => ( | |
<Alert key={id} color={done ? "success":"warning"}> | |
<span key={todo.id} > {todo} <Del id={id} /> <Mark id={id} /> </span> | |
</Alert> | |
)); | |
} | |
else{ | |
return(<div> get some work boi...</div> | |
) | |
} | |
}} | |
</Query> | |
</div> | |
) | |
} | |
export default Todos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment