added ability to cross items off
This commit is contained in:
@@ -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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user