From f58d607c5d32dc2533e7681b383d62ac4d95fbc6 Mon Sep 17 00:00:00 2001 From: Harmony Date: Mon, 25 Nov 2019 13:27:34 -0500 Subject: [PATCH] Able to switch sprints --- src/App.js | 11 +++++++---- src/Items/Items.js | 8 ++++---- src/NewItem/NewItem.js | 12 ++++++------ src/boxes/Boxes.js | 4 ++-- src/cards/Cards.js | 17 +++++++++-------- src/deleteItem/DeleteItem.js | 8 ++++---- 6 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/App.js b/src/App.js index 22495fc..dab90e4 100644 --- a/src/App.js +++ b/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 ( + +

Sprint {sprint}

- - - + + +
); diff --git a/src/Items/Items.js b/src/Items/Items.js index e4874b7..5f86f9b 100644 --- a/src/Items/Items.js +++ b/src/Items/Items.js @@ -1,15 +1,15 @@ import React from 'react'; import { databaseRef } from '../store/firebase.js' -export default function Item({ item, boxId }) { +export default function Item({ item, boxId, sprint }) { const handleClick = e => { let url; if(boxId === "1"){ - url = 'retros/1/www/' + url = `retros/` + sprint + `/www/` } else if(boxId === "2"){ - url = 'retros/1/!www/' + url = `retros/` + sprint + `/!www/` } else if(boxId === "3"){ - url = 'retros/1/questions/' + url = `retros/` + sprint + `/questions/` } else { url = 'retros/1/a/' } diff --git a/src/NewItem/NewItem.js b/src/NewItem/NewItem.js index 51a5d7b..a40e46e 100644 --- a/src/NewItem/NewItem.js +++ b/src/NewItem/NewItem.js @@ -2,24 +2,24 @@ import React, {useState} from 'react'; import { databaseRef } from '../store/firebase.js' import uuid from "uuid"; -export default function NewItem({ addItem, boxId }) { +export default function NewItem({ addItem, boxId, sprint }) { const [value, setValue ] = useState(""); - +console.log(sprint); const handleSubmit = e => { e.preventDefault(); let retroRef; let url; if(boxId === "1"){ - url = 'retros/1/www' + url = `retros/` + sprint + `/www`; retroRef = databaseRef.ref(url); } else if(boxId === "2"){ - url = 'retros/1/!www' + url = `retros/` + sprint + `/!www`; retroRef = databaseRef.ref(url); } else if(boxId === "3"){ - url = 'retros/1/questions' + url = `retros/` + sprint + `/questions`; retroRef = databaseRef.ref(url); } else { - url = 'retros/1/a' + url = 'retros/1/a'; retroRef = databaseRef.ref(url); } const item = { diff --git a/src/boxes/Boxes.js b/src/boxes/Boxes.js index 5126c7c..719315b 100644 --- a/src/boxes/Boxes.js +++ b/src/boxes/Boxes.js @@ -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, boxId }) { +export default function Boxes({ sectionName, boxId, sprint }) { return (

{sectionName}

- +
) diff --git a/src/cards/Cards.js b/src/cards/Cards.js index 5e01bab..bf5dce0 100644 --- a/src/cards/Cards.js +++ b/src/cards/Cards.js @@ -4,7 +4,7 @@ import Item from '../Items/Items.js'; import NewItem from '../NewItem/NewItem.js' import DeleteItem from '../deleteItem/DeleteItem.js' -export function Cards({item, setItem, boxId}) { +export function Cards({item, setItem, boxId, sprint}) { return ( <> {item.map((i, index) => ( @@ -13,24 +13,25 @@ export function Cards({item, setItem, boxId}) { item={i} index={index} boxId={boxId} + sprint={sprint} /> - + ))} - + ) } -export default function FirebaseWrapper({boxId}) { +export default function FirebaseWrapper({boxId, sprint}) { const [cards, setCards] = useState(null) let retro; if(boxId === "1"){ - retro = databaseRef.ref('retros/1/www'); + retro = databaseRef.ref(`retros/` + sprint + `/www`); } else if(boxId === "2"){ - retro = databaseRef.ref('retros/1/!www'); + retro = databaseRef.ref(`retros/` + sprint + `/!www`); } else if(boxId === "3"){ - retro = databaseRef.ref('retros/1/questions'); + retro = databaseRef.ref(`retros/` + sprint + `/questions`); } else { retro = databaseRef.ref('retros/1/a'); } @@ -48,5 +49,5 @@ export default function FirebaseWrapper({boxId}) { if(!cards) { return
loading...
; }; - return {}}/> + return {}}/> } diff --git a/src/deleteItem/DeleteItem.js b/src/deleteItem/DeleteItem.js index 4a6f186..f8349e1 100644 --- a/src/deleteItem/DeleteItem.js +++ b/src/deleteItem/DeleteItem.js @@ -1,17 +1,17 @@ import React from 'react'; import { databaseRef } from '../store/firebase.js' -export default function DeleteItem({ item, boxId, objectId }) { +export default function DeleteItem({ item, boxId, objectId, sprint }) { // const [value, setValue ] = useState(""); const handleClick = e => { let retroRef; if(boxId === "1"){ - retroRef = databaseRef.ref(`retros/1/www/` + item.id); + retroRef = databaseRef.ref(`retros/` + sprint + `/www/` + item.id); } else if(boxId === "2"){ - retroRef = databaseRef.ref(`retros/1/!www/` + item.id); + retroRef = databaseRef.ref(`retros/` + sprint + `/!www/` + item.id); } else if(boxId === "3"){ - retroRef = databaseRef.ref(`retros/1/questions/` + item.id); + retroRef = databaseRef.ref(`retros/` + sprint + `/questions/` + item.id); } else { retroRef = databaseRef.ref(`retros/1/a/` + item.id); }