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 { Provider } from "react-redux";
|
||||||
import Boxes from "./boxes/Boxes";
|
import Boxes from "./boxes/Boxes";
|
||||||
import styles from "./App.module.css";
|
import styles from "./App.module.css";
|
||||||
import setupStore from "./store/setupStore.js";
|
import setupStore from "./store/setupStore.js";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
const [sprint, setSprint] = useState(1)
|
||||||
return (
|
return (
|
||||||
<Provider store={setupStore()}>
|
<Provider store={setupStore()}>
|
||||||
|
<button onClick={() => setSprint(sprint + 1)}>Sprint (+))</button>
|
||||||
|
<h3>Sprint {sprint}</h3>
|
||||||
<div className={styles.grid}>
|
<div className={styles.grid}>
|
||||||
<Boxes sectionName={"What Went Well"} boxId={'1'}/>
|
<Boxes sectionName={"What Went Well"} sprint={sprint} boxId={'1'}/>
|
||||||
<Boxes sectionName={"What Could Be Better"} boxId={'2'}/>
|
<Boxes sectionName={"What Could Be Better"} sprint={sprint} boxId={'2'}/>
|
||||||
<Boxes sectionName={"Questions"} boxId={'3'}/>
|
<Boxes sectionName={"Questions"} sprint={sprint} boxId={'3'}/>
|
||||||
</div>
|
</div>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { databaseRef } from '../store/firebase.js'
|
import { databaseRef } from '../store/firebase.js'
|
||||||
|
|
||||||
export default function Item({ item, boxId }) {
|
export default function Item({ item, boxId, sprint }) {
|
||||||
const handleClick = e => {
|
const handleClick = e => {
|
||||||
let url;
|
let url;
|
||||||
if(boxId === "1"){
|
if(boxId === "1"){
|
||||||
url = 'retros/1/www/'
|
url = `retros/` + sprint + `/www/`
|
||||||
} else if(boxId === "2"){
|
} else if(boxId === "2"){
|
||||||
url = 'retros/1/!www/'
|
url = `retros/` + sprint + `/!www/`
|
||||||
} else if(boxId === "3"){
|
} else if(boxId === "3"){
|
||||||
url = 'retros/1/questions/'
|
url = `retros/` + sprint + `/questions/`
|
||||||
} else {
|
} else {
|
||||||
url = 'retros/1/a/'
|
url = 'retros/1/a/'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,24 @@ import React, {useState} from 'react';
|
|||||||
import { databaseRef } from '../store/firebase.js'
|
import { databaseRef } from '../store/firebase.js'
|
||||||
import uuid from "uuid";
|
import uuid from "uuid";
|
||||||
|
|
||||||
export default function NewItem({ addItem, boxId }) {
|
export default function NewItem({ addItem, boxId, sprint }) {
|
||||||
const [value, setValue ] = useState("");
|
const [value, setValue ] = useState("");
|
||||||
|
console.log(sprint);
|
||||||
const handleSubmit = e => {
|
const handleSubmit = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let retroRef;
|
let retroRef;
|
||||||
let url;
|
let url;
|
||||||
if(boxId === "1"){
|
if(boxId === "1"){
|
||||||
url = 'retros/1/www'
|
url = `retros/` + sprint + `/www`;
|
||||||
retroRef = databaseRef.ref(url);
|
retroRef = databaseRef.ref(url);
|
||||||
} else if(boxId === "2"){
|
} else if(boxId === "2"){
|
||||||
url = 'retros/1/!www'
|
url = `retros/` + sprint + `/!www`;
|
||||||
retroRef = databaseRef.ref(url);
|
retroRef = databaseRef.ref(url);
|
||||||
} else if(boxId === "3"){
|
} else if(boxId === "3"){
|
||||||
url = 'retros/1/questions'
|
url = `retros/` + sprint + `/questions`;
|
||||||
retroRef = databaseRef.ref(url);
|
retroRef = databaseRef.ref(url);
|
||||||
} else {
|
} else {
|
||||||
url = 'retros/1/a'
|
url = 'retros/1/a';
|
||||||
retroRef = databaseRef.ref(url);
|
retroRef = databaseRef.ref(url);
|
||||||
}
|
}
|
||||||
const item = {
|
const item = {
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import React from 'react';
|
|||||||
import styles from './Boxes.module.css'
|
import styles from './Boxes.module.css'
|
||||||
import Cards from '../cards/Cards.js'
|
import Cards from '../cards/Cards.js'
|
||||||
|
|
||||||
export default function Boxes({ sectionName, boxId }) {
|
export default function Boxes({ sectionName, boxId, sprint }) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3>{sectionName}</h3>
|
<h3>{sectionName}</h3>
|
||||||
<div className={styles.box}>
|
<div className={styles.box}>
|
||||||
<Cards sectionName={sectionName} boxId={boxId}/>
|
<Cards sectionName={sectionName} boxId={boxId} sprint={sprint}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import Item from '../Items/Items.js';
|
|||||||
import NewItem from '../NewItem/NewItem.js'
|
import NewItem from '../NewItem/NewItem.js'
|
||||||
import DeleteItem from '../deleteItem/DeleteItem.js'
|
import DeleteItem from '../deleteItem/DeleteItem.js'
|
||||||
|
|
||||||
export function Cards({item, setItem, boxId}) {
|
export function Cards({item, setItem, boxId, sprint}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{item.map((i, index) => (
|
{item.map((i, index) => (
|
||||||
@@ -13,24 +13,25 @@ export function Cards({item, setItem, boxId}) {
|
|||||||
item={i}
|
item={i}
|
||||||
index={index}
|
index={index}
|
||||||
boxId={boxId}
|
boxId={boxId}
|
||||||
|
sprint={sprint}
|
||||||
/>
|
/>
|
||||||
<DeleteItem item={i} boxId={boxId} />
|
<DeleteItem item={i} boxId={boxId} sprint={sprint}/>
|
||||||
</div>
|
</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)
|
const [cards, setCards] = useState(null)
|
||||||
let retro;
|
let retro;
|
||||||
if(boxId === "1"){
|
if(boxId === "1"){
|
||||||
retro = databaseRef.ref('retros/1/www');
|
retro = databaseRef.ref(`retros/` + sprint + `/www`);
|
||||||
} else if(boxId === "2"){
|
} else if(boxId === "2"){
|
||||||
retro = databaseRef.ref('retros/1/!www');
|
retro = databaseRef.ref(`retros/` + sprint + `/!www`);
|
||||||
} else if(boxId === "3"){
|
} else if(boxId === "3"){
|
||||||
retro = databaseRef.ref('retros/1/questions');
|
retro = databaseRef.ref(`retros/` + sprint + `/questions`);
|
||||||
} else {
|
} else {
|
||||||
retro = databaseRef.ref('retros/1/a');
|
retro = databaseRef.ref('retros/1/a');
|
||||||
}
|
}
|
||||||
@@ -48,5 +49,5 @@ export default function FirebaseWrapper({boxId}) {
|
|||||||
if(!cards) {
|
if(!cards) {
|
||||||
return <div>loading...</div>;
|
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 React from 'react';
|
||||||
import { databaseRef } from '../store/firebase.js'
|
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 [value, setValue ] = useState("");
|
||||||
|
|
||||||
const handleClick = e => {
|
const handleClick = e => {
|
||||||
let retroRef;
|
let retroRef;
|
||||||
if(boxId === "1"){
|
if(boxId === "1"){
|
||||||
retroRef = databaseRef.ref(`retros/1/www/` + item.id);
|
retroRef = databaseRef.ref(`retros/` + sprint + `/www/` + item.id);
|
||||||
} else if(boxId === "2"){
|
} else if(boxId === "2"){
|
||||||
retroRef = databaseRef.ref(`retros/1/!www/` + item.id);
|
retroRef = databaseRef.ref(`retros/` + sprint + `/!www/` + item.id);
|
||||||
} else if(boxId === "3"){
|
} else if(boxId === "3"){
|
||||||
retroRef = databaseRef.ref(`retros/1/questions/` + item.id);
|
retroRef = databaseRef.ref(`retros/` + sprint + `/questions/` + item.id);
|
||||||
} else {
|
} else {
|
||||||
retroRef = databaseRef.ref(`retros/1/a/` + item.id);
|
retroRef = databaseRef.ref(`retros/1/a/` + item.id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user