Compare commits

...

8 Commits
ui ... master

Author SHA1 Message Date
Harmony
e158b5ccd6 switching between sprints 2020-03-30 15:41:10 -04:00
Harmony
aafba656c8 Bit o stylin' 2020-03-30 10:21:16 -04:00
Harmony
17de3426e2 can login with google to view boxes 2020-03-02 10:13:01 -05:00
Harmony
f58d607c5d Able to switch sprints 2019-11-25 13:27:34 -05:00
Harmony
ddaf3df1a3 added ability to cross items off 2019-11-25 10:24:32 -05:00
Harmony
4398ee2d45 Can delete any item from db except last one in list 2019-11-25 10:04:50 -05:00
Harmony
3b9ee304db writing to each box 2019-11-15 14:27:56 -05:00
Harmony
f5c8edd74c Reading from each box and writing to one 2019-11-15 11:43:03 -05:00
17 changed files with 14937 additions and 67 deletions

14647
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3,10 +3,12 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@reach/router": "^1.2.1",
"firebase": "^7.2.2", "firebase": "^7.2.2",
"node-sass": "^4.13.0", "node-sass": "^4.13.0",
"react": "^16.11.0", "react": "^16.11.0",
"react-dom": "^16.11.0", "react-dom": "^16.11.0",
"react-firebaseui": "^4.1.0",
"react-redux": "^7.1.1", "react-redux": "^7.1.1",
"react-scripts": "3.2.0", "react-scripts": "3.2.0",
"redux": "^4.0.4", "redux": "^4.0.4",

View File

@@ -1,16 +1,48 @@
import React from "react"; import React, {useState, useEffect} from "react";
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import firebase from'firebase'
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { Router } from "@reach/router";
import Boxes from "./boxes/Boxes"; import Boxes from "./boxes/Boxes";
import styles from "./App.module.css"; import SignedIn from "./SignedIn/SignedIn.js";
import setupStore from "./store/setupStore.js"; import setupStore from "./store/setupStore.js";
const config = {
apiKey: "AIzaSyC5krz4RBiT87RK7cEidh3n-A4H63uGcyM",
authDomain: "retrod-7e2cd.firebaseapp.com",
};
const uiConfig = {
signInFlow: 'popup',
signInSuccessUrl: '/',
signInOptions: [
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
]
};
function App() { function App() {
const [sprint, setSprint] = useState(1);
const [isSignedIn, setSignIn] = useState(false)
useEffect(() => {
firebase.auth().onAuthStateChanged(user => {
setSignIn(!!user)
})
})
return ( return (
<Provider store={setupStore()}> <Provider store={setupStore()}>
<div className={styles.grid}> <Router>
<Boxes sectionName={"What Went Well"} /> <Boxes exact path={`/` + sprint} />
<Boxes sectionName={"What Could Be Better"} /> </Router>
<Boxes sectionName={"Questions"} /> <div>
{isSignedIn ? (
<>
<SignedIn/>
</>
) : (
<>
<h1>You're Not Signed In</h1>
<StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()}/>
</>
)
}
</div> </div>
</Provider> </Provider>
); );

View File

@@ -1,9 +1,25 @@
import React from 'react'; import React from 'react';
import { databaseRef } from '../store/firebase.js'
import styles from "./items.module.css";
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 ( return (
<div style={{ textDecoration: item.completed ? "line-through" : "" }}> <div className={styles.flexItem}>
{item.title} <p style={{ textDecoration: item.completed ? "line-through" : "" }}>{item.title}</p>
<button onClick={handleClick}>{item.completed === false ? <p className={styles.checkmark}></p> : <p className={styles.redx}>x</p>}</button>
</div> </div>
) )
} }

View File

@@ -0,0 +1,15 @@
.flexItem{
display: flex;
justify-content: space-between;
}
button{
background: none;
border: none;
}
.checkmark{
color: green;
cursor: pointer;
}
.redx{
color: red;
}

View File

@@ -1,16 +1,37 @@
import React, {useState} from 'react'; 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(""); const [value, setValue ] = useState("");
const handleSubmit = e => { const handleSubmit = e => {
e.preventDefault(); e.preventDefault();
if(!value) return; let retroRef;
let url;
addItem(value); if(boxId === "1"){
setValue(""); 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);
databaseRef.ref(url + `/` + objectId.key + `/id`).set(objectId.key)
setValue("")
} }
return ( return (
<div>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<input <input
type="text" type="text"
@@ -19,5 +40,6 @@ export default function NewItem({ addItem }) {
onChange={e => setValue(e.target.value)} onChange={e => setValue(e.target.value)}
/> />
</form> </form>
</div>
) )
} }

21
src/SignedIn/SignedIn.js Normal file
View File

@@ -0,0 +1,21 @@
import React from "react";
import firebase from'firebase';
import SprintSelect from "../sprintSelect/SprintSelect"
import styles from "./signedIn.module.css";
export default function SignedIn() {
return (
<div>
<div className={styles.alignRight}>
<div className={styles.marginRight}>
<p>{firebase.auth().currentUser.displayName}</p>
<div>
<img align="right" className={styles.profilePicture} alt='user profile' src={firebase.auth().currentUser.photoURL} />
</div>
<button className={styles.signOutButton} onClick={() => firebase.auth().signOut()}>Sign Out</button>
</div>
</div>
<SprintSelect />
</div>
)
}

View File

@@ -0,0 +1,25 @@
body{
background: lightseagreen;
}
.alignRight{
width: 100%;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.marginRight{
margin-right: 1rem;
}
.signOutButton{
background: none;
border: none;
text-decoration: underline;
cursor: pointer;
width: 100%;
text-align: right;
padding: 0;
margin-top: 1rem;
}
.alignRight .profilePicture{
max-width: 50px;
}

View File

@@ -2,12 +2,11 @@ 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 }) { export default function Boxes({ sectionName, boxId, sprint }) {
return ( return (
<div> <div>
<h3>{sectionName}</h3>
<div className={styles.box}> <div className={styles.box}>
<Cards /> <Cards sectionName={sectionName} boxId={boxId} sprint={sprint} />
</div> </div>
</div> </div>
) )

View File

@@ -1,3 +1,4 @@
.box{ .box{
border: .15rem solid black; border: .15rem solid black;
background: lightgrey;
} }

View File

@@ -2,43 +2,42 @@ import React, { useState, useEffect, useMemo } from 'react';
import { databaseRef } from '../store/firebase.js' import { databaseRef } from '../store/firebase.js'
import Item from '../Items/Items.js'; import Item from '../Items/Items.js';
import NewItem from '../NewItem/NewItem.js' import NewItem from '../NewItem/NewItem.js'
import uuid from "uuid"; import DeleteItem from '../deleteItem/DeleteItem.js'
import styles from "./cards.module.css";
export function Cards({item, setItem}) {
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)
}
export function Cards({item, setItem, boxId, sprint, sectionName, sprint_id}) {
return ( return (
<> <>
<h3>{sectionName}</h3>
{item.map((i, index) => ( {item.map((i, index) => (
<div key={i.id}> <div className={i.sprint_id === sprint ? styles.cardBackground : styles.hide} key={i.id}>
<Item <Item
item={i} item={i}
index={index} index={index}
boxId={boxId}
sprint={sprint}
/> />
<button onClick={() => deleteItem(i.id) }>x</button> <DeleteItem item={i} boxId={boxId} sprint={sprint}/>
</div> </div>
))} ))}
<NewItem addItem={addItem} /> <NewItem sprint={sprint} boxId={boxId}/>
</> </>
) )
} }
export default function FirebaseWrapper() { export default function FirebaseWrapper({sectionName, boxId, sprint}) {
const [cards, setCards] = useState(null) 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(() => { useEffect(() => {
retroRef.on('value', function(snapshot) { retroRef.on('value', function(snapshot) {
const values = Object.values(snapshot.val()) const values = Object.values(snapshot.val())
@@ -52,5 +51,5 @@ export default function FirebaseWrapper() {
if(!cards) { if(!cards) {
return <div>loading...</div>; return <div>loading...</div>;
}; };
return <Cards item={cards} setItem={()=> {}}/> return <Cards sectionName={sectionName} item={cards} boxId={boxId} sprint={sprint} setItem={()=> {}}/>
} }

View File

@@ -0,0 +1,8 @@
.cardBackground{
background: white;
margin: .5em;
padding: 1em;
}
.hide{
display: none;
}

View File

@@ -1,12 +1,31 @@
import React, {useState} from 'react'; import React from 'react';
import { databaseRef } from '../store/firebase.js'
import styles from "./deleteItem.module.css";
export default function DeleteItem({ deleteItem }) { export default function DeleteItem({ item, boxId, objectId, sprint }) {
// const [value, setValue ] = useState("");
const handleClick = e => { const handleClick = e => {
deleteItem(value); let retroRef;
setValue(""); 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 ( return (
<button onClick={handleClick}>x</button> <button className={styles.deleteButton} onClick={handleClick}>DELETE</button>
) )
} }

View File

@@ -0,0 +1,10 @@
.deleteButton{
color: darkred;
width: 100%;
display: flex;
justify-content: flex-end;
font-size: .5em;
font-weight: bolder;
letter-spacing: 1px;
cursor: pointer;
}

View File

@@ -0,0 +1,54 @@
import React, { useState, useEffect, useMemo } from 'react';
import Boxes from "../boxes/Boxes";
import { databaseRef } from '../store/firebase.js'
import styles from "../sprintSelect/sprintSelect.module.css";
export function SprintSelect({item}) {
const [sprint, setSprint] = useState(1);
let sprintArray = [];
let sortedSprint;
sortedSprint = item.map((i, index) => (
sprintArray.push(i.sprint_id)
))
.reduce((unique, item) => {
return unique.includes(item) ? unique : [...unique, item]
}, [])
.sort();
let dropdownSprint;
dropdownSprint = sortedSprint.map((i, index) => (
<option onClick={() => setSprint(i)}>{i}</option>
));
return (
<div>
<label>Choose Sprint:</label>
<select>
{dropdownSprint}
</select>
<h3>Sprint {sprint}</h3>
<div className={styles.grid}>
<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>
</div>
)
}
export default function FirebaseWrapper() {
const [cards, setCards] = useState(null)
let retro = databaseRef.ref(`retros/1/www`);
const retroRef = useMemo(() => databaseRef.ref(retro), []);
useEffect(() => {
retroRef.on('value', function(snapshot) {
const values = Object.values(snapshot.val())
setCards(values)
});
return () => {
retroRef.off();
}
}, [retroRef]);
if(!cards) {
return <div>loading...</div>;
};
return <SprintSelect item={cards} setItem={()=> {}}/>
}