added ability to cross items off

This commit is contained in:
Harmony
2019-11-25 10:24:32 -05:00
parent 4398ee2d45
commit ddaf3df1a3
2 changed files with 17 additions and 1 deletions

View File

@@ -1,9 +1,24 @@
import React from 'react'; import React from 'react';
import { databaseRef } from '../store/firebase.js'
export default function Item({ item }) { export default function Item({ item, boxId }) {
const handleClick = e => {
let url;
if(boxId === "1"){
url = 'retros/1/www/'
} else if(boxId === "2"){
url = 'retros/1/!www/'
} else if(boxId === "3"){
url = 'retros/1/questions/'
} else {
url = 'retros/1/a/'
}
databaseRef.ref(url + item.id + `/completed`).set(item.completed === false ? true : false)
}
return ( return (
<div style={{ textDecoration: item.completed ? "line-through" : "" }}> <div style={{ textDecoration: item.completed ? "line-through" : "" }}>
{item.title} {item.title}
<button onClick={handleClick}>{item.completed === false ? 'done' : 'undo'}</button>
</div> </div>
) )
} }

View File

@@ -12,6 +12,7 @@ export function Cards({item, setItem, boxId}) {
<Item <Item
item={i} item={i}
index={index} index={index}
boxId={boxId}
/> />
<DeleteItem item={i} boxId={boxId} /> <DeleteItem item={i} boxId={boxId} />
</div> </div>