Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
464743b
Merge pull request #3 from goblin-sharks-ECRI-38/main
seanflynn5 Feb 4, 2023
031da52
Initialize components for login page
khendrix12 Feb 4, 2023
660057b
Merge branch 'dev' into KevSean/feature-branch
khendrix12 Feb 4, 2023
213bc2b
Merge pull request #4 from goblin-sharks-ECRI-38/KevSean/feature-page
seanflynn5 Feb 4, 2023
cb571c1
signup and login backend completed
jm-roman Feb 4, 2023
4695a0f
Merge branch 'dev' into johnsheng/auth
jm-roman Feb 4, 2023
cc7b8df
Merge pull request #5 from goblin-sharks-ECRI-38/johnsheng/auth
shengli356 Feb 4, 2023
514a67e
Add logic to display data from backend in table component
khendrix12 Feb 4, 2023
efbf359
Merge branch 'dev' into KevSean/db-functionality
khendrix12 Feb 4, 2023
9530279
Merge pull request #6 from goblin-sharks-ECRI-38/KevSean/db-functiona…
seanflynn5 Feb 4, 2023
b42e062
fix api call format in FeaturePageContainer
khendrix12 Feb 6, 2023
e1c1d1a
Merge pull request #7 from goblin-sharks-ECRI-38/KevSean/db-functiona…
khendrix12 Feb 6, 2023
1620cdb
added favorites
Feb 6, 2023
02e14ef
Merge branch 'dev' into sheng-logout
Feb 6, 2023
d926cd9
Merge pull request #8 from goblin-sharks-ECRI-38/sheng-logout
jm-roman Feb 6, 2023
bdbbf68
Initialize react structure for login page
khendrix12 Feb 6, 2023
9f2f8fb
Merge pull request #9 from goblin-sharks-ECRI-38/KevSean/login-feature
seanflynn5 Feb 6, 2023
655d2f9
mimum change made
Feb 6, 2023
cae8889
Merge pull request #10 from goblin-sharks-ECRI-38/more-style
jm-roman Feb 6, 2023
78b6a83
Change login from div to form
khendrix12 Feb 6, 2023
d2c9211
Merge branch 'dev' into KevSean/login-feature-tuning
khendrix12 Feb 6, 2023
7ffb4f3
Merge pull request #11 from goblin-sharks-ECRI-38/KevSean/login-featu…
seanflynn5 Feb 6, 2023
8e6aecc
styling finished
Feb 6, 2023
354ac97
Reconfigure style after changing input box to form
khendrix12 Feb 6, 2023
0d641f6
Merge branch 'dev' into css
Feb 6, 2023
763d02f
Merge branch 'dev' into KevSean/login-feature-fix-styling
khendrix12 Feb 6, 2023
c32610b
Merge pull request #13 from goblin-sharks-ECRI-38/css
jm-roman Feb 6, 2023
c2e2bd7
Merge pull request #14 from goblin-sharks-ECRI-38/KevSean/login-featu…
seanflynn5 Feb 6, 2023
1b8d863
final
Feb 6, 2023
4939abf
Merge pull request #16 from goblin-sharks-ECRI-38/final-css
jm-roman Feb 6, 2023
974be95
Merge pull request #1 from ECRI38-Pantless-Thundergeese/dev
zahara-aviv Feb 7, 2023
3fd6d8e
clean comments and code of main server file and add catch all route
juliendevlin Feb 7, 2023
68ac924
Establishes new alcheameal database with updated user scheam and cont…
Chanduh Feb 7, 2023
81002be
refactor createUser method from userController
juliendevlin Feb 7, 2023
146558a
Create Signup Page and navigate to the feature page after signup.
jshwatsoro Feb 7, 2023
e0f3f0b
enable setting of jwt cookie upon successful signup
juliendevlin Feb 8, 2023
1d2b28f
added unit tests for the server functionality
zahara-aviv Feb 8, 2023
300c814
re-commented out the call to populateDB()
zahara-aviv Feb 8, 2023
751fffa
Merge pull request #2 from ECRI38-Pantless-Thundergeese/zahara/AM-26-…
zahara-aviv Feb 8, 2023
957da27
Adds first and last name to user schema
Chanduh Feb 8, 2023
fc2713d
enable setting of jwt cookie upon successful login
juliendevlin Feb 8, 2023
462b957
set mongo strict query to true and supress deprecation warning
juliendevlin Feb 8, 2023
f026c1e
add controller to verify cookies
juliendevlin Feb 8, 2023
88aff92
add controller to remove session cookies
juliendevlin Feb 8, 2023
d164815
mobile friendly styling
zahara-aviv Feb 8, 2023
07c837d
Merge pull request #3 from ECRI38-Pantless-Thundergeese/zahara/AM-21-…
zahara-aviv Feb 8, 2023
1fd0702
fix cookie controller bugs and add auth verification and logout endpo…
juliendevlin Feb 8, 2023
c00fae8
Merge branch 'dev' of https://github.com/ECRI38-Pantless-Thundergeese…
juliendevlin Feb 8, 2023
66b8588
styling updates for dropdown menu
zahara-aviv Feb 8, 2023
40084b1
Merge pull request #4 from ECRI38-Pantless-Thundergeese/zahara/AM-21-…
zahara-aviv Feb 8, 2023
1c1a3f4
revised login page UI/UX - button effects, default ENTER, error messages
zahara-aviv Feb 8, 2023
00f93b8
Merge pull request #5 from ECRI38-Pantless-Thundergeese/zahara/AM-5-s…
zahara-aviv Feb 8, 2023
22bb50d
refactor getFacts to remove for loop from within async func
Chanduh Feb 8, 2023
ebfbd34
fix bug when verifying session cookie
juliendevlin Feb 8, 2023
0a7eee3
merge dev with session cookie changes
juliendevlin Feb 8, 2023
d95d34c
Prepping for merge with dev
Chanduh Feb 8, 2023
6553e87
Create card and cardlist components to render on the front end
jshwatsoro Feb 8, 2023
aa36a2d
Merge pull request #6 from ECRI38-Pantless-Thundergeese/session-cookies
juliendevlin Feb 8, 2023
c39169e
Merge and break dev
Chanduh Feb 8, 2023
9c6de1d
Update mongo connect
Chanduh Feb 8, 2023
b2c3425
Merge branch 'dev' into chanda/db
Chanduh Feb 8, 2023
72fe320
Adds functionality to add a favorite to the favorite array on the user
Chanduh Feb 8, 2023
07bd2b6
update the card container and card to render on front end
jshwatsoro Feb 8, 2023
12f450d
added ability for user to persist a logIn/refresh serves main page. R…
zahara-aviv Feb 8, 2023
6c4fa93
deletes from the fav array
Chanduh Feb 8, 2023
aa6d386
Highlights old/new code temp until fully tested
Chanduh Feb 8, 2023
7648e0a
Add a Profile Page and an Edit Profile Button, download react-select
Jackson2taLL Feb 8, 2023
9911ab3
Update the card and cardlist to render on the page
jshwatsoro Feb 8, 2023
6c8089d
Modularizes allergy and fav controllers
Chanduh Feb 8, 2023
6cca179
Adds bones for diet and blacklist controllers
Chanduh Feb 8, 2023
c5615df
Merge branch 'dev' into jackson/profile
Jackson2taLL Feb 8, 2023
6f58b50
Update card and cardlist to render the cards and nutrition facts
jshwatsoro Feb 8, 2023
88e364d
fix merge errors from previous commit
Jackson2taLL Feb 8, 2023
96a1d63
Merge pull request #7 from ECRI38-Pantless-Thundergeese/jackson/profile
Jackson2taLL Feb 8, 2023
d376362
Merge branch 'dev' into josh/frontend
jshwatsoro Feb 8, 2023
e544c30
Merge pull request #8 from ECRI38-Pantless-Thundergeese/josh/frontend
jshwatsoro Feb 8, 2023
b49a3d1
Mega merges
Chanduh Feb 8, 2023
f215b13
Merge pull request #9 from ECRI38-Pantless-Thundergeese/chanda/db
Chanduh Feb 8, 2023
3b06903
Merge branch 'dev' into zahara/AM-21-mobile-styling
zahara-aviv Feb 8, 2023
9c5dda1
try to fix merging errors
zahara-aviv Feb 8, 2023
dcbed84
update and console log in the card
jshwatsoro Feb 8, 2023
1190e27
add routes for get all preferences and patch all preferences
juliendevlin Feb 8, 2023
d240164
Adds a getAllergy and updateProfile ctrlr
Chanduh Feb 8, 2023
87bdc98
add routes to add and delete individual user preferences
juliendevlin Feb 8, 2023
1eb7fa3
Added deleteUser functionality
Chanduh Feb 8, 2023
00308f6
Adds ctrlr to get profile
Chanduh Feb 8, 2023
914b8b5
create seperate router file for profile
juliendevlin Feb 8, 2023
ed6bb05
update profile all routes and add individual get routes
juliendevlin Feb 8, 2023
4f31349
Merge pull request #10 from ECRI38-Pantless-Thundergeese/routing
juliendevlin Feb 8, 2023
7cc784e
Cleans up ctrlr funcs pre merge
Chanduh Feb 8, 2023
64f0aa6
Merge branch 'dev' into chanda/db
Chanduh Feb 8, 2023
d6d830c
refactor
jshwatsoro Feb 8, 2023
dd9b0f8
major overhaul to fix the routing and frontend issues...
zahara-aviv Feb 8, 2023
1c7f253
Merge branch 'dev' into zahara/AM-21-mobile-styling
zahara-aviv Feb 8, 2023
3245cfa
Merge pull request #11 from ECRI38-Pantless-Thundergeese/zahara/AM-21…
zahara-aviv Feb 8, 2023
69e47ea
Debugs and ensures working routes / controllers
Chanduh Feb 8, 2023
f0c50e4
Returns preferences not password from ctrlr
Chanduh Feb 9, 2023
9d403ab
Merge branch 'dev' into chanda/db
Chanduh Feb 9, 2023
d784532
did not update any files
jshwatsoro Feb 9, 2023
66b7ca8
Merge pull request #12 from ECRI38-Pantless-Thundergeese/chanda/db
Chanduh Feb 9, 2023
e32e2ec
Bonesafies the food filter
Chanduh Feb 9, 2023
3c56f3a
Finish the card and cardlist component
jshwatsoro Feb 9, 2023
f563f1a
Co-authored-by: Jackson Ta <Jackson2taLL@users.noreply.github.com>
jshwatsoro Feb 9, 2023
d566ed2
Merge pull request #13 from ECRI38-Pantless-Thundergeese/josh/frontend
jshwatsoro Feb 9, 2023
038116c
add Google OAuth functionality
juliendevlin Feb 9, 2023
740d83e
merged in dev
juliendevlin Feb 9, 2023
ec9e9f0
Merge pull request #14 from ECRI38-Pantless-Thundergeese/julien/googl…
juliendevlin Feb 9, 2023
2fb560a
responsive styling + input standardized inputs
zahara-aviv Feb 9, 2023
66f256d
Merge branch 'dev' into zahara/AM-21-mobile-styling
zahara-aviv Feb 9, 2023
3edb451
minor fix after merge.
zahara-aviv Feb 9, 2023
a7b8565
merged in the oauth + styling.
zahara-aviv Feb 9, 2023
43594e2
Merge pull request #15 from ECRI38-Pantless-Thundergeese/zahara/AM-21…
zahara-aviv Feb 9, 2023
7a99ecf
updated requests for profile editting
Jackson2taLL Feb 9, 2023
1a061a4
downloaded dependencies
Jackson2taLL Feb 9, 2023
f693aca
Half of filter cntrl
Chanduh Feb 9, 2023
23c4a8c
write oauth first and last name to dB
juliendevlin Feb 9, 2023
71f3334
Merge branch 'dev' into julien/google-oauth
juliendevlin Feb 9, 2023
b1cb0e0
Merge pull request #16 from ECRI38-Pantless-Thundergeese/julien/googl…
juliendevlin Feb 9, 2023
ef95336
add configuration to deliver assets in production mode
juliendevlin Feb 9, 2023
347cd0d
Filters out allergy related foods
Chanduh Feb 9, 2023
db874b3
enable app to run successfully in both build and developments modes
juliendevlin Feb 9, 2023
9d0fea3
edit profile pre-populates saved data
Jackson2taLL Feb 9, 2023
4ec481a
updated gitignore to ignore build folder
juliendevlin Feb 9, 2023
6e565d0
delete build folder
juliendevlin Feb 9, 2023
007887c
Updates user schema & ctrls to firstName/lastName
Chanduh Feb 9, 2023
0730d56
Merge branch 'dev' into jackson/profile
Jackson2taLL Feb 9, 2023
aced5fa
Merge pull request #17 from ECRI38-Pantless-Thundergeese/jackson/profile
Jackson2taLL Feb 9, 2023
e38306d
Merge branch 'dev' into julien/production-build
juliendevlin Feb 9, 2023
7a26ac0
Merge pull request #18 from ECRI38-Pantless-Thundergeese/julien/produ…
juliendevlin Feb 9, 2023
f4884c2
Filters out diet VIOLATORS, hides api key
Chanduh Feb 9, 2023
809f959
Merge branch 'dev' into chanda/db
Chanduh Feb 9, 2023
9e05e4a
Merge pull request #19 from ECRI38-Pantless-Thundergeese/chanda/db
Chanduh Feb 9, 2023
3941bdd
Includes old timey crtlr for non-users also
Chanduh Feb 9, 2023
c918d8d
Merge branch 'dev' into chanda/db
Chanduh Feb 9, 2023
e6090b5
Merge pull request #20 from ECRI38-Pantless-Thundergeese/chanda/db
Chanduh Feb 9, 2023
e1b55f8
front end updates...
zahara-aviv Feb 9, 2023
bb78e29
oauth bug with process.env
zahara-aviv Feb 9, 2023
17055c0
merged to dev
zahara-aviv Feb 9, 2023
3d6da19
merge with dev, for real this time.
zahara-aviv Feb 9, 2023
f7f7c27
Merge pull request #21 from ECRI38-Pantless-Thundergeese/zahara/AM-21…
zahara-aviv Feb 9, 2023
c47e1e1
prepare for merge
Chanduh Feb 9, 2023
eb3252b
fix the signup button and update button
Jackson2taLL Feb 9, 2023
d72f1cd
Merge pull request #22 from ECRI38-Pantless-Thundergeese/jackson/profile
Jackson2taLL Feb 9, 2023
28910e7
makes shit work
Chanduh Feb 9, 2023
a3e178a
Merge branch 'dev' into chanda/db
Chanduh Feb 9, 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
35 changes: 16 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb"
],
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"react"
],
"rules": {
}
"root": true,
"ignorePatterns": ["**/test", "**/__tests__"],
"env": {
"node": true,
"es2021": true
},
"extends": ["eslint:recommended", "prettier"],
"parserOptions": { "sourceType": "module" },
"rules": {
"indent": ["warn", 2],
"no-unused-vars": ["off", { "vars": "local" }],
"prefer-const": "warn",
"quotes": ["warn", "single"],
"space-infix-ops": "warn"
},
"plugins": ["prettier"]
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ typings/
# TypeScript cache
*.tsbuildinfo

# ignore vscode
.vscode/

# Optional npm cache directory
.npm

Expand Down Expand Up @@ -102,3 +105,6 @@ dist

# TernJS port file
.tern-port

# Build folder
public/
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
singleQuote: true,
jsxSingleQuote: true
}
236 changes: 236 additions & 0 deletions __tests__/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
const request = require('supertest');
const { AILMENTS } = require('../constants');
const app = require('../server/server');
const Illness = require('../server/models/illnessModels');
const User = require('../server/models/userModel');
// const NODE_ENV = process.env.NODE_ENV;
// added a test database that is cloned from development

describe('Server Route Testing', () => {
// console.log(`Mode = ${process.env.NODE_ENV}`);

const favorite = 'stuff';
const food = 'stuff';
let server;
// added manually in the db b/c beforeAll is terrible...
// const ailment1 = new Illness({ ailment: 'test1', foods: [] });
// const ailment2 = new Illness({ ailment: 'test2' });
beforeAll((done) => {
server = app.listen(done);
});
afterAll((done) => {
User.deleteOne({ username: 'test' }).catch((err) => {});
User.deleteOne({ username: 'usertest' }).catch((err) => {});
server.close(done);
});

test('GET /', (done) => {
request(app)
.get('/')
.expect('Content-Type', /tet\/html/)
.expect(200);
done();
});

test('POST /search', (done) => {
AILMENTS.forEach((elem, i) =>
request(app)
.post('/search')
.expect('Content-Type', /json/)
.send({
ailment: elem,
})
.expect(200)
);
done();
});

test('Error Handling /search: ', (done) => {
request(app)
.post('/search')
.expect('Content-Type', /json/)
.send({}) //empty body
.expect(500);
request(app)
.post('/search')
.expect('Content-Type', /json/)
.send({ ailment: 'N/A' }) //search not found
.expect(500);
request(app)
.post('/search')
.expect('Content-Type', /json/)
.send({ ailment: 'test1' }) //empty food array
.expect(500);
request(app)
.post('/search')
.expect('Content-Type', /json/)
.send({ ailment: 'test2' }) //no food element
.expect(500);
done();
});

test('GET /signup', (done) => {
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({
username: 'test',
password: 'test',
})
.expect(200);
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({
username: 'usertest',
password: 'test',
})
.expect(200);
done();
});

test('Error Handling /signup: ', (done) => {
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({}) //empty body
.expect(500);
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({ username: 'test' }) //no password field
.expect(500);
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({ password: 'test' }) //no username field
.expect(500);
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({ username: '', password: 'test' }) //empty username field
.expect(500);
request(app)
.post('/signup')
.expect('Content-Type', /json/)
.send({ username: 'test', password: '' }) //empty password field
.expect(500);
done();
});

test('POST /login', (done) => {
request(app)
.post('/login')
.expect('Content-Type', /json/)
.send({
username: 'test',
password: 'test',
})
.expect(200);
done();
});

test('Error Handling /login: ', (done) => {
request(app)
.post('/login')
.expect('Content-Type', /json/)
.send({}) //empty body
.expect(500);
request(app)
.post('/login')
.expect('Content-Type', /json/)
.send({ username: 'test' }) //no password field
.expect(500);
request(app)
.post('/login')
.expect('Content-Type', /json/)
.send({ password: 'test' }) //no username field
.expect(500);
request(app)
.post('/login')
.expect('Content-Type', /json/)
.send({ username: '', password: 'test' }) //empty username field
.expect(500);
request(app)
.post('/login')
.expect('Content-Type', /json/)
.send({ username: 'test', password: '' }) //empty password field
.expect(500);
done();
});

test('PATCH /user/addfav', (done) => {
request(app)
.post('/user/addfav/test')
.expect('Content-Type', /json/)
.send({
favorite,
})
.expect(200);
done();
});

test('Error Handling /user/addfav: ', (done) => {
request(app)
.post('/user/addfav/test')
.expect('Content-Type', /json/)
.send({}) //empty body
.expect(500);
request(app)
.post('/user/addfav/not-a-user')
.expect('Content-Type', /json/)
.send({ favorite: 'test' }) //bad username
.expect(500);
request(app)
.post('/user/addfav/test')
.expect('Content-Type', /json/)
.send({ favorite: '' }) //empty field
.expect(500);
done();
});

test('GET /user', (done) => {
request(app)
.post('/user/test')
.expect('Content-Type', /json/)
.expect(200)
.expect((res) => expect(res.body).toEqual(favorite));
done();
});

test('Error Handling /user: ', (done) => {
request(app)
.post('/user/not-a-user') //not a user
.expect('Content-Type', /json/)
.expect(500);
request(app)
.post('/user/usertest') //no favorite element
.expect('Content-Type', /json/)
.expect(500);
done();
});

test('PATCH /user/deletefav', (done) => {
request(app)
.post('/user/deletefav/test')
.expect('Content-Type', /json/)
.send({
food,
})
.expect(200)
.expect((res) => expect(res.body).toEqual(''));
done();
});

test('Error Handling /user/deletefav: ', (done) => {
request(app)
.post('/user/deletefav/not-a-user') //not a user
.expect('Content-Type', /json/)
.expect(500);
request(app)
.post('/user/deletefav/usertest') //no favorite element
.expect('Content-Type', /json/)
.expect(500);
done();
});
});
65 changes: 63 additions & 2 deletions client/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,70 @@
import React from 'react';
import FeatureContainer from '../containers/FeaturePageContainer';
import Login from './Login';
import Profile from './Profile';
import Signup from './Signup';
import { useSelector, useDispatch } from 'react-redux';
import { setAppPage, setOAuthEnable } from '../slices';

function App(props) {
const appPage = useSelector((state) => state.control.appPage);
const oAuthEnabled = useSelector((state) => state.control.oAuthEnabled);
const dispatch = useDispatch();

const handleGoogleSignIn = () => {
fetch('/oauth/google/redirect')
.then((res) => res.json())
.then((data) => (window.location.href = data.redirect));
};

const header = (
<section className='header'>
<img
onClick={() => {
dispatch(setAppPage('/'));
}}
className='logo'
src={require('../images/logo.png')}
/>
</section>
);

const getCurrentPage = () => {
switch (appPage) {
case '/signup':
return (
<Signup
appPage={appPage}
oAuth={oAuthEnabled}
oAuthHandler={handleGoogleSignIn}
/>
);
case '/profile':
return <Profile appPage={appPage} />;
case '/feature':
return (
<FeatureContainer
appPage={appPage}
oAuth={oAuthEnabled}
oAuthHandler={handleGoogleSignIn}
/>
);
default: //'/':
return (
<Login
appPage={appPage}
oAuth={oAuthEnabled}
oAuthHandler={handleGoogleSignIn}
/>
);
}
};

function App() {
return (
<FeatureContainer />
<div>
{header}
{getCurrentPage()}
</div>
);
}

Expand Down
Loading