Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final pull from dev to main #17

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c8003d7
Merge branch 'dev' of https://github.com/WCRI56-Team-GS/Scratch-Proje…
n8ngo Mar 4, 2023
a70a641
Merge branch 'dev' of https://github.com/WCRI56-Team-GS/Scratch-Proje…
Mar 4, 2023
2dff85d
Progress on UseContext Hooks not rendering yet
n8ngo Mar 4, 2023
10a9f52
Merge pull request #4 from WCRI56-Team-GS/sammichael/login
gacetta Mar 4, 2023
730ffdb
Merge branch 'dev' of https://github.com/WCRI56-Team-GS/Scratch-Proje…
Mar 4, 2023
8560c0f
rendering login and signup pages
n8ngo Mar 4, 2023
123486b
feat: userController.verifyUser functioning
gacetta Mar 4, 2023
5ea1376
Progress implementing RRouter, added column and modal components
n8ngo Mar 5, 2023
368bb50
Merge branch 'dev' of https://github.com/WCRI56-Team-GS/Scratch-Proje…
n8ngo Mar 5, 2023
31f0442
Merge branch 'dev' into nathan/login
n8ngo Mar 5, 2023
0fe23d5
feat: isLoggedIn and createNewUser in process
gacetta Mar 5, 2023
0c4e62f
Merge pull request #6 from WCRI56-Team-GS/nathan/login
pkg415 Mar 5, 2023
e613dee
feat: isLoggedIn and createNewUser in process
gacetta Mar 5, 2023
7ddd268
Merge branch 'dev' of https://github.com/WCRI56-Team-GS/Scratch-Proje…
Mar 5, 2023
262fd59
Complete signin middleware
samhhenderson Mar 6, 2023
1d7aafe
Co-authored-by: Nathan Ngo <n8ngo@users.noreply.github.com>
samhhenderson Mar 6, 2023
44593f3
Signup backend ready for frontend integration
samhhenderson Mar 6, 2023
fee4e0f
Merge pull request #8 from WCRI56-Team-GS/sammichael/login
joyxek Mar 6, 2023
a35d1f5
made some changes to modals and changed state
Mar 6, 2023
70000c6
Merge branch 'dev' into joyce/loginmodals
samhhenderson Mar 6, 2023
657e1b6
Merge pull request #10 from WCRI56-Team-GS/joyce/loginmodals
samhhenderson Mar 6, 2023
31d5a6a
feat: complete isLoggedIn middleware
gacetta Mar 6, 2023
25ef012
modals can open and close and is rendering
Mar 6, 2023
e7f6a6a
Merge pull request #11 from WCRI56-Team-GS/michael/isLoggedIn
samhhenderson Mar 6, 2023
f3bb3cd
Merge branch 'dev' into joyce/mondaybranch
n8ngo Mar 6, 2023
7e9928e
Merge pull request #12 from WCRI56-Team-GS/joyce/mondaybranch
n8ngo Mar 6, 2023
9d15e03
Co-authored-by: Nathan Ngo <nathanngo8796@gmail.com>
samhhenderson Mar 6, 2023
2b36cf2
Merge branch 'dev' into sam/boardAPI
samhhenderson Mar 6, 2023
583c7cc
Merge pull request #13 from WCRI56-Team-GS/sam/boardAPI
n8ngo Mar 6, 2023
a480160
columns are rendering from database and logout button works;
Mar 6, 2023
b8bc488
added logout functionality, styling and rendering of cards and columns;
Mar 7, 2023
1ce461f
Merge pull request #14 from WCRI56-Team-GS/joyce/loginfetches
n8ngo Mar 7, 2023
9f1f1bc
Add column functionality
n8ngo Mar 7, 2023
b219483
Merge pull request #15 from WCRI56-Team-GS/nathan/teampush
gacetta Mar 7, 2023
379b8c5
Added session verification
n8ngo Mar 7, 2023
62405ad
updated stylesheets
n8ngo Mar 7, 2023
7c1c820
Merge pull request #16 from WCRI56-Team-GS/nathan/teampush
samhhenderson Mar 7, 2023
f07101e
Added files folder with sample database docs and excalidraw
samhhenderson Mar 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Document</title><script defer="defer" src="bundle.js"></script></head><body><h1>index.html</h1><div id="app"></div><script src="./build/bundle.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Document</title><script defer="defer" src="bundle.js"></script></head><body><div id="app"></div><script src="./build/bundle.js"></script></body></html>
126 changes: 113 additions & 13 deletions client/App.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,121 @@
import React from 'react';
import { useState, useEffect, createContext } from 'react';
import LoginPage from './LoginPage'

const UserContext = createContext();
import { useState, useEffect } from 'react';
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import LoginPage from './components/LoginPage.jsx';
import SignUpPage from './components/SignUpPage.jsx';
import HomePage from './components/HomePage.jsx';


const App = () => {
const [ user, setUser ] = useState("");

const [ signUpToggle, setSignUpToggle ] = useState(false);
const [ user, setUser ] = useState(''); //<-- Switch to an empty string when ready
const [ password, setPassword ] = useState("")
const [ isLoggedIn, setLogin ] = useState(false); //<--- Switch to false when ready
const [loginError, setLoginError] = useState(false);


//SIGN-UP / SIGN-IN TOGGLE
const toggle = () => {
setSignUpToggle(!signUpToggle);
}

useEffect(() => {
if (loginError === true) alert('Incorrect username or password. Please try again');
},[loginError])

return (
<UserContext.Provider value={user}>
<LoginPage user={user} />
<div>
<h1>{`Hello ${user}!`}</h1>
</div>
</UserContext.Provider>
)
<>
{isLoggedIn ? (<HomePage user={user} isLoggedIn={isLoggedIn} setLogin={setLogin}/>) :
(signUpToggle ? (
<SignUpPage
user={user}
setUser={setUser}
password={password}
setPassword={setPassword}
toggle={toggle}
isLoggedIn={isLoggedIn}
setLogin={setLogin}
/>
) : (
<LoginPage
user={user}
setUser={setUser}
password={password}
setPassword={setPassword}
toggle={toggle}
isLoggedIn={isLoggedIn}
setLogin={setLogin}
setLoginError={setLoginError}
/>
)
)}
{/* {loginError ? (<div>Incorrect username or password. Please try again</div>) : <></>} */}

</>
);
}

export default App;

/*notes on the routing:
//the first Route has a path of "/" (which maybe should change?)
// and it renders the Login Page
//the next Routes are nested in that first Route

// do we need to add a catchall for undefined URLs, like <Route path="*" element={<NoPage />} />
// & then import a NoPage & have an error msg?
*/


/*
Routing:
<SignUpPage />
<LoginPage />
<HomePage />

<Router>
<Routes>
<Route
path="/login"
element={
<LoginPage
user={user}
setUser={setUser}
password={password}
setPassword={setPassword}
toggle={toggle}
isLoggedIn={isLoggedIn}
setLogin={setLogin}
/>
}
/>
<Route
path="/signup"
element={
<SignUpPage
user={user}
setUser={setUser}
password={password}
setPassword={setPassword}
toggle={toggle}
isLoggedIn={isLoggedIn}
setLogin={setLogin}
/>
}
/>
<Route
path='/home'
element={
<HomePage
/>} />
</Routes>
</Router>

*/

export default App;
/* tried useContext()
const [signUpToggle, setSignUpToggle]= useContext(UserProvider)
console.log('SIGNUPTOGGLE from app: ',signUpToggle)
console.log('UserProvider from APP.jsx', UserProvider)
*/
27 changes: 27 additions & 0 deletions client/UserContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* tried useContext()

import React, { useContext, useState, createContext } from 'react';

export const UserContext = React.createContext();

function UserProvider({ children }) {
const [ signUpToggle, setSignUpToggle ] = useState(true);
const [ user, setUser ] = useState("");
const [ password, setPassword ] = useState("")



return (
<UserContext.Provider value={[signUpToggle, setSignUpToggle]}>
<UserContext.Provider value={[ user, setUser ]}>
<UserContext.Provider value={[ password, setPassword ]}>
{children}
</UserContext.Provider>
</UserContext.Provider>
</UserContext.Provider>
)
}

export default UserProvider;

*/
23 changes: 23 additions & 0 deletions client/components/Column.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { Component } from "react";
import { useState, useEffect } from "react";
// import { CardModal } from "./Modals";



function Column ({columnName, cards, setShowCardModal}) {
const renderCards = cards.map((card, index) => {
return (<div key={index} className='card'>{card.cardText}</div>);
})

return (
<div className='columnCont'>
<div>{columnName}</div>
<div className='cardCont'>
{renderCards}
</div>
<button onClick={() => setShowCardModal(true)}>ADD CARD</button>
</div>
);
}

export default Column;
110 changes: 110 additions & 0 deletions client/components/HomePage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React, { Component } from "react";
import { useState, useEffect } from "react";
import { ColumnModal, CardModal } from './Modals.jsx';
import Column from './Column.jsx'

function HomePage({user, isLoggedIn, setLogin}) {
// state to render a column creation modal
const [ showColumnModal, setShowColumnModal ] = useState(false)
// state to render a card creation modal
const [ showCardModal, setShowCardModal ] = useState(false)
// const [columnsState, setColumns] = useState(null);
const [ boardData, setBoardData ] = useState([]);
const [ currBoardID, setCurrBoardID] = useState('');

//render columns and cards within
// [
// {
// "_id": "640635f9e846af21bdd5652e",
// "boardName": "testBoard",
// "columns": [
// {
// "_id": "64065a6f664404268f5fc975",
// "columnName": "col1",
// "cards": [
// {
// "_id": "64065a6f664404268f5fc976",
// "cardText": "hello, I'm a card!"
// }
// ]
// }
// ]
// }
// ]
//This is real code do not delete:
let renderColumns = [];

useEffect(() => {

fetch('/api', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({username: user})
}).then((res) => res.json())
.then((data) => {
setBoardData(data);
setCurrBoardID(data[0]._id)
})
.catch((error) => {
console.log('Error fetching boardData in APP.jsx:', error)
})
},[isLoggedIn])

console.log('BOARD DATA', boardData)


if (boardData.length !== 0) {
renderColumns = boardData[0].columns.map((column, index) => {
return (<Column key={index} columnName={column.columnName} cards={column.cards} setShowCardModal={setShowCardModal}/>)
})
}
let overlay = null;

if (showColumnModal || showCardModal) overlay = <div className="overlay"></div>
else overlay = null;

return (
<div className='homeCont'>

{overlay}

<header className='homeHeader'>
<h1> Home Page </h1>
<button className="logOut" onClick={() => (setLogin(false))}>LOG OUT</button>

</header>

<div className='boardDisplay'>
<div className="modal-box">
{/* when showModal is set to true a column modal will render */}
{/* having issues with page re-rendering when state is updated. modal does not stay up */}
{/* {showColumnModal && <ColumnModal showColumnModal={showColumnModal} setShowColumnModal={setShowColumnModal} />} */}
{showColumnModal ? (<ColumnModal
showColumnModal={showColumnModal}
setShowColumnModal={setShowColumnModal}
showCardModal={showCardModal}
setShowCardModal={setShowCardModal}
boardData={boardData}
currBoardID={currBoardID}
setBoardData={setBoardData} />)
: (<></>)
}
{showCardModal ? (<CardModal
showCardModal={showCardModal}
setShowCardModal={setShowCardModal} />)
: (<></>)
}
</div>
<div className="column-container">
{renderColumns}
</div>
<div>
<button className="addColumn" onClick={() => setShowColumnModal(true)}>ADD COLUMN</button>
</div>
</div>
</div>
);

}

export default HomePage;
Loading