Compare commits
6 Commits
ui
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31b57f036c | ||
|
|
f58d607c5d | ||
|
|
ddaf3df1a3 | ||
|
|
4398ee2d45 | ||
|
|
3b9ee304db | ||
|
|
f5c8edd74c |
11
src/App.js
11
src/App.js
@@ -1,16 +1,19 @@
|
||||
import React from "react";
|
||||
import React, {useState} from "react";
|
||||
import { Provider } from "react-redux";
|
||||
import Boxes from "./boxes/Boxes";
|
||||
import styles from "./App.module.css";
|
||||
import setupStore from "./store/setupStore.js";
|
||||
|
||||
function App() {
|
||||
const [sprint, setSprint] = useState(1)
|
||||
return (
|
||||
<Provider store={setupStore()}>
|
||||
<button onClick={() => setSprint(sprint + 1)}>Sprint (+))</button>
|
||||
<h3>Sprint {sprint}</h3>
|
||||
<div className={styles.grid}>
|
||||
<Boxes sectionName={"What Went Well"} />
|
||||
<Boxes sectionName={"What Could Be Better"} />
|
||||
<Boxes sectionName={"Questions"} />
|
||||
<Boxes sectionName={"What Went Well"} sprint={sprint} boxId={'1'}/>
|
||||
<Boxes sectionName={"What Could Be Better"} sprint={sprint} boxId={'2'}/>
|
||||
<Boxes sectionName={"Questions"} sprint={sprint} boxId={'3'}/>
|
||||
</div>
|
||||
</Provider>
|
||||
);
|
||||
|
||||
@@ -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, sprint }) {
|
||||
const handleClick = e => {
|
||||
let url;
|
||||
if(boxId === "1"){
|
||||
url = `retros/` + sprint + `/www/`
|
||||
} else if(boxId === "2"){
|
||||
url = `retros/` + sprint + `/!www/`
|
||||
} else if(boxId === "3"){
|
||||
url = `retros/` + sprint + `/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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,47 @@
|
||||
import React, {useState} from 'react';
|
||||
import { databaseRef } from '../store/firebase.js'
|
||||
import uuid from "uuid";
|
||||
|
||||
export default function NewItem({ addItem }) {
|
||||
export default function NewItem({ addItem, boxId, sprint }) {
|
||||
const [value, setValue ] = useState("");
|
||||
|
||||
console.log(sprint);
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
if(!value) return;
|
||||
|
||||
addItem(value);
|
||||
setValue("");
|
||||
let retroRef;
|
||||
let url;
|
||||
if(boxId === "1"){
|
||||
url = `retros/` + sprint + `/www`;
|
||||
retroRef = databaseRef.ref(url);
|
||||
} else if(boxId === "2"){
|
||||
url = `retros/` + sprint + `/!www`;
|
||||
retroRef = databaseRef.ref(url);
|
||||
} else if(boxId === "3"){
|
||||
url = `retros/` + sprint + `/questions`;
|
||||
retroRef = databaseRef.ref(url);
|
||||
} else {
|
||||
url = 'retros/1/a';
|
||||
retroRef = databaseRef.ref(url);
|
||||
}
|
||||
const item = {
|
||||
completed: false,
|
||||
id: uuid.v4(),
|
||||
title: value,
|
||||
}
|
||||
let objectId = retroRef.push(item);
|
||||
console.log(objectId.key);
|
||||
databaseRef.ref(url + `/` + objectId.key + `/id`).set(objectId.key)
|
||||
setValue("")
|
||||
}
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
placeholder="stuff"
|
||||
onChange={e => setValue(e.target.value)}
|
||||
/>
|
||||
</form>
|
||||
<div>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
placeholder="stuff"
|
||||
onChange={e => setValue(e.target.value)}
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ import React from 'react';
|
||||
import styles from './Boxes.module.css'
|
||||
import Cards from '../cards/Cards.js'
|
||||
|
||||
export default function Boxes({ sectionName }) {
|
||||
export default function Boxes({ sectionName, boxId, sprint }) {
|
||||
return (
|
||||
<div>
|
||||
<h3>{sectionName}</h3>
|
||||
<div className={styles.box}>
|
||||
<Cards />
|
||||
<Cards sectionName={sectionName} boxId={boxId} sprint={sprint}/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,43 +2,40 @@ import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { databaseRef } from '../store/firebase.js'
|
||||
import Item from '../Items/Items.js';
|
||||
import NewItem from '../NewItem/NewItem.js'
|
||||
import uuid from "uuid";
|
||||
import DeleteItem from '../deleteItem/DeleteItem.js'
|
||||
|
||||
export function Cards({item, setItem}) {
|
||||
export function Cards({item, setItem, boxId, sprint}) {
|
||||
return (
|
||||
<>
|
||||
{item.map((i, index) => (
|
||||
<div key={i.id}>
|
||||
<Item
|
||||
item={i}
|
||||
index={index}
|
||||
boxId={boxId}
|
||||
sprint={sprint}
|
||||
/>
|
||||
<DeleteItem item={i} boxId={boxId} sprint={sprint}/>
|
||||
</div>
|
||||
))}
|
||||
<NewItem sprint={sprint} boxId={boxId}/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const addItem = title => {
|
||||
const newItem = [...item, {title, completed: false, id: uuid.v4()}];
|
||||
setItem(newItem)
|
||||
}
|
||||
const deleteItem = id => {
|
||||
const deleted = item.reduce((acc, current) => {
|
||||
if(current.id !== id){
|
||||
return [...acc, current];
|
||||
}
|
||||
return [...acc, {...current, completed: true}]
|
||||
}, [])
|
||||
setItem(deleted)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{item.map((i, index) => (
|
||||
<div key={i.id}>
|
||||
<Item
|
||||
item={i}
|
||||
index={index}
|
||||
/>
|
||||
<button onClick={() => deleteItem(i.id) }>x</button>
|
||||
</div>
|
||||
))}
|
||||
<NewItem addItem={addItem} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default function FirebaseWrapper() {
|
||||
export default function FirebaseWrapper({boxId, sprint}) {
|
||||
const [cards, setCards] = useState(null)
|
||||
const retroRef = useMemo(() => databaseRef.ref('retros/1'), []);
|
||||
let retro;
|
||||
if(boxId === "1"){
|
||||
retro = databaseRef.ref(`retros/` + sprint + `/www`);
|
||||
} else if(boxId === "2"){
|
||||
retro = databaseRef.ref(`retros/` + sprint + `/!www`);
|
||||
} else if(boxId === "3"){
|
||||
retro = databaseRef.ref(`retros/` + sprint + `/questions`);
|
||||
} else {
|
||||
retro = databaseRef.ref('retros/1/a');
|
||||
}
|
||||
const retroRef = useMemo(() => databaseRef.ref(retro), []);
|
||||
useEffect(() => {
|
||||
retroRef.on('value', function(snapshot) {
|
||||
const values = Object.values(snapshot.val())
|
||||
@@ -52,5 +49,5 @@ export default function FirebaseWrapper() {
|
||||
if(!cards) {
|
||||
return <div>loading...</div>;
|
||||
};
|
||||
return <Cards item={cards} setItem={()=> {}}/>
|
||||
return <Cards item={cards} boxId={boxId} sprint={sprint} setItem={()=> {}}/>
|
||||
}
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
import React, {useState} from 'react';
|
||||
import React from 'react';
|
||||
import { databaseRef } from '../store/firebase.js'
|
||||
|
||||
export default function DeleteItem({ deleteItem }) {
|
||||
export default function DeleteItem({ item, boxId, objectId, sprint }) {
|
||||
// const [value, setValue ] = useState("");
|
||||
|
||||
const handleClick = e => {
|
||||
deleteItem(value);
|
||||
setValue("");
|
||||
let retroRef;
|
||||
if(boxId === "1"){
|
||||
retroRef = databaseRef.ref(`retros/` + sprint + `/www/` + item.id);
|
||||
} else if(boxId === "2"){
|
||||
retroRef = databaseRef.ref(`retros/` + sprint + `/!www/` + item.id);
|
||||
} else if(boxId === "3"){
|
||||
retroRef = databaseRef.ref(`retros/` + sprint + `/questions/` + item.id);
|
||||
} else {
|
||||
retroRef = databaseRef.ref(`retros/1/a/` + item.id);
|
||||
}
|
||||
// const item = {
|
||||
// completed: false,
|
||||
// id: uuid.v4(),
|
||||
// title: value,
|
||||
// }
|
||||
// databaseRef.ref.remove(retroRef);
|
||||
// setValue("")
|
||||
retroRef.remove()
|
||||
}
|
||||
return (
|
||||
<button onClick={handleClick}>x</button>
|
||||
|
||||
@@ -1811,9 +1811,9 @@ acorn-walk@^6.0.1:
|
||||
integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==
|
||||
|
||||
acorn@^5.5.3:
|
||||
version "5.7.3"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
|
||||
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
|
||||
version "5.7.4"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
|
||||
integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==
|
||||
|
||||
acorn@^6.0.1, acorn@^6.0.4, acorn@^6.2.1:
|
||||
version "6.3.0"
|
||||
|
||||
Reference in New Issue
Block a user