Able to switch sprints
This commit is contained in:
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"} boxId={'1'}/>
|
||||
<Boxes sectionName={"What Could Be Better"} boxId={'2'}/>
|
||||
<Boxes sectionName={"Questions"} boxId={'3'}/>
|
||||
<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,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/'
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 (
|
||||
<div>
|
||||
<h3>{sectionName}</h3>
|
||||
<div className={styles.box}>
|
||||
<Cards sectionName={sectionName} boxId={boxId}/>
|
||||
<Cards sectionName={sectionName} boxId={boxId} sprint={sprint}/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
<DeleteItem item={i} boxId={boxId} />
|
||||
<DeleteItem item={i} boxId={boxId} sprint={sprint}/>
|
||||
</div>
|
||||
))}
|
||||
<NewItem boxId={boxId}/>
|
||||
<NewItem sprint={sprint} boxId={boxId}/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
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 <div>loading...</div>;
|
||||
};
|
||||
return <Cards item={cards} boxId={boxId} setItem={()=> {}}/>
|
||||
return <Cards item={cards} boxId={boxId} sprint={sprint} setItem={()=> {}}/>
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user