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 { 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 (
<div style={{ textDecoration: item.completed ? "line-through" : "" }}>
{item.title}
<button onClick={handleClick}>{item.completed === false ? 'done' : 'undo'}</button>
</div>
)
}

View File

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