Compare commits

...

139 Commits

Author SHA1 Message Date
af6f9cd131 append 2022-04-09 15:34:24 -05:00
fd916a8d63 Merge branch 'main' of https://github.com/csc309-winter-2022/team58 into develop 2022-04-09 15:33:31 -05:00
f65fbd70aa Fixed unset mongodb uri environment variable. 2022-04-08 13:26:31 -05:00
Arjun Sahni
1c704cb606
Merge pull request #10 from csc309-winter-2022/develop
Develop
2022-04-07 23:01:46 -04:00
Arjun Sahni
eee941ffcc
Merge pull request #9 from csc309-winter-2022/rentals
Rentals
2022-04-07 22:21:43 -04:00
Sahni-Arjun
0d5e9351ab merge 2022-04-07 22:21:05 -04:00
Sahni-Arjun
a01b9a0f48 added rentals page 2022-04-07 22:16:48 -04:00
88c0de660e Start of profile page. 2022-04-07 20:59:30 -05:00
5948ed561c Removed extra pardon button for matches. 2022-04-07 20:51:32 -05:00
753669c0af If the user session has expired, update context appropriately. 2022-04-07 20:47:12 -05:00
90040f9049 Admin display connected to backend. 2022-04-07 20:43:31 -05:00
9c4696b797 Fixed date issue with models. 2022-04-07 20:23:32 -05:00
5d2528da5f Fixed database check. 2022-04-07 19:22:35 -05:00
a0a347e0c2 Authentication guard will now always refresh user identity. 2022-04-07 18:00:14 -05:00
e7d689cdde Finished sign up page. 2022-04-07 17:59:55 -05:00
f9fef07b9a Made change to api call to reflect server-side changes. 2022-04-07 17:59:12 -05:00
eb4e4b2444 Added suspension mechanism. 2022-04-07 17:57:08 -05:00
2e8ba9c5b1 Separated public recent matches and user recent matches endpoints. 2022-04-07 17:36:57 -05:00
92289c87b3 Auth. guard now only renders child if authenticated. 2022-04-07 15:37:45 -05:00
525c2b6d5a Authentication guard now takes in a access level prop. 2022-04-07 13:51:38 -05:00
0e218750f8 Removed unecessary async declaration. 2022-04-07 13:38:29 -05:00
fa8552d488 Fixed login route and authentication guards. 2022-04-07 13:36:49 -05:00
ef66904c60 Merge branch 'develop' of https://github.com/csc309-winter-2022/team58 into develop 2022-04-06 22:54:22 -05:00
b575fc7fde Login endpoint now returns the user profile. 2022-04-06 22:53:20 -05:00
Arjun Sahni
da3dc6fdad
Merge pull request #8 from csc309-winter-2022/admin_page
Admin page
2022-04-06 23:00:08 -04:00
Sahni-Arjun
26abdd6aa5 comment 2022-04-06 22:57:53 -04:00
f98b003808 Implemented component version of authentication guard. 2022-04-06 21:18:48 -05:00
Sahni-Arjun
468f1cfa31 Merge branch 'develop' into admin_page 2022-04-06 22:15:09 -04:00
6856cd3b71 Eslint no longer complains about linebreaks. 2022-04-06 21:14:40 -05:00
Sahni-Arjun
7c8e37aea8 finished admin frontend 2022-04-06 22:09:03 -04:00
c738e8044a eslint no fails compiles due to unused imports. 2022-04-06 21:03:30 -05:00
499cbf3409 Fixed api client url error. 2022-04-06 20:35:41 -05:00
Sahni-Arjun
54b01f81c5 Admin page 2022-04-06 19:34:21 -04:00
Arjun Sahni
24f085e17a
Update README.md 2022-04-05 21:59:20 -04:00
fdbd372430 Merge branch 'main' of https://github.com/csc309-winter-2022/team58 2022-04-05 20:54:46 -05:00
30894c59c4 Merge branch 'develop' of https://github.com/csc309-winter-2022/team58 into develop 2022-04-05 20:54:29 -05:00
34bbfb3d5d Final changes. 2022-04-05 20:54:26 -05:00
Hansi Xu
9f1df7f7f4 Merge branch 'restructure' into develop 2022-04-05 21:48:51 -04:00
Hansi Xu
f6a8cebbec Merge branch 'signup-page' into restructure 2022-04-05 21:48:32 -04:00
Hansi Xu
5a49a1e4f8 Moved signup to pages 2022-04-05 21:48:08 -04:00
Piyush Sharma
096eadce13
Update README.md 2022-04-05 21:45:01 -04:00
Hansi Xu
1fd60e39d4 Merge branch 'restructure' into develop 2022-04-05 21:40:49 -04:00
Hansi Xu
332e4e94d8 Merge branch 'signup-page' into restructure 2022-04-05 21:40:21 -04:00
Hansi Xu
d86570996e updating the signup page 2022-04-05 21:39:48 -04:00
Hansi Xu
c691b710b7 Merge branch 'restructure' into develop 2022-04-05 21:18:15 -04:00
Hansi Xu
6c79a4e9b3 Merge branch 'signup-page' into restructure 2022-04-05 21:16:49 -04:00
Hansi Xu
559973de5a Create signup.js 2022-04-05 21:15:39 -04:00
6cd421ba01 Fixed sport display. 2022-04-05 20:13:55 -05:00
0a2d513d3c Merge branch 'main' of https://github.com/csc309-winter-2022/team58 2022-04-05 20:04:49 -05:00
bb911173ec Merge branch 'develop' 2022-04-05 20:03:30 -05:00
911e5a2c79 Merge branch 'Dashboard' into restructure 2022-04-05 20:00:28 -05:00
999f884694 Login now displays an error message on a failed login. 2022-04-05 19:51:13 -05:00
Piyush Sharma
8f46ad77b8 Added cards and scroll styling 2022-04-05 20:17:50 -04:00
c4c4031e4c Login complete. 2022-04-05 19:14:11 -05:00
5c393cb73d Changed layout to a be a function component. 2022-04-05 18:47:06 -05:00
Sahni-Arjun
94d3369d4e admin page 2022-04-05 19:29:44 -04:00
4aced5ed2d Added "api/" prefix to api routes.
Client updated to reflect changes.
2022-04-05 17:24:41 -05:00
b2c4178482 Fixed broken recent matches endpoint. 2022-04-05 16:19:05 -05:00
8a7fbd074b Began integrating dashboard.
Also fixed match controller populate calls.
2022-04-05 14:52:19 -05:00
e4db4ab403 Merge branch 'restructure' into login-page 2022-04-05 14:22:28 -05:00
67c1b9e821 Added route guards and login page template. 2022-04-05 14:20:50 -05:00
Piyush Sharma
fe3039b4f3
Merge pull request #7 from csc309-winter-2022/Dashboard
Dashboard
2022-04-05 15:19:46 -04:00
Piyush Sharma
d5a11d214c Updated Dashboard 2022-04-05 14:51:15 -04:00
Piyush Sharma
2877fc3fd7 Merge remote-tracking branch 'origin/restructure' into Dashboard 2022-04-05 13:19:19 -04:00
Piyush Sharma
879cbac17f Added Dashboard 2022-04-05 13:16:09 -04:00
0b42dde699 Added mongo starts scripts. 2022-04-05 12:11:06 -05:00
b447dcd985 Fixed broken import. 2022-04-05 12:00:55 -05:00
98ea02b56c Added rental controller to server routes. 2022-04-05 11:54:06 -05:00
8f96a2e5c9 Multiple changes, basic rental CRUD backend implemented.
All responses are now in their own object with context name.

Added limit to user based recent results for matches.

Moved all code in endpoints inside try and catch.

Renamed authentication guard function.
2022-04-05 11:50:35 -05:00
a7885ecf53 Added padding to horizontal scrollers. 2022-04-05 03:44:04 -05:00
6cedd74473 Recent match endpoint now populates all references. 2022-04-05 03:41:20 -05:00
d17fe1d912 Fixed extra comma on stringified items. 2022-04-05 03:30:59 -05:00
c1589b9758 Welcome page now shows current matches. 2022-04-05 03:28:12 -05:00
Sahni-Arjun
859147ea3d comment 2022-04-05 03:50:11 -04:00
Piyush Sharma
2831e2a39e Added route 2022-04-05 02:19:17 -04:00
Piyush Sharma
f38867598e Setup Dashboard Page 2022-04-05 02:19:08 -04:00
f8abf7cd48 Changed carousel images to be more fitting. 2022-04-05 01:06:54 -05:00
8464c4debc Changed carousel images to larger images and restyled. 2022-04-05 01:00:25 -05:00
dd6dc787e9 Match controller now returns user recents if authenticated. 2022-04-05 00:21:34 -05:00
0f480af1f0 Merge branch 'restructure' of https://github.com/csc309-winter-2022/team58 into restructure 2022-04-04 22:50:29 -05:00
7dd862e134 Added U and D endpoints. 2022-04-04 22:50:26 -05:00
Piyush Sharma
489387ec9f
Merge pull request #6 from csc309-winter-2022/carousel
New Carousel
2022-04-04 23:30:36 -04:00
Piyush Sharma
900f98615d Change indicator colour 2022-04-04 23:28:23 -04:00
Piyush Sharma
3124f05544 Added New Carousel 2022-04-04 23:06:59 -04:00
ba566040b1 Rewrite phase 1.
Started improved client code structure.

Implemented session based authentication serverside.

Implemented user, match, and sport database models serverside.

Implemented Controllers for variety of C and R operations of CRUD.
2022-04-04 20:15:43 -05:00
c345cea888 Added CORS for development environment. 2022-04-04 20:00:12 -05:00
8a3de628a6 Created a recent endpoint for matches.
Added a field to record creation time of a match.

Additionally performed some minor refactoring.
2022-04-01 11:16:24 -05:00
19bbca36ca Refactored schemas, naming, and instantiation files. 2022-04-01 10:27:58 -05:00
8231f9db67 Minor progress on client side redesign. 2022-04-01 05:38:27 -05:00
c6b15074fb Created some create and read endpoints. 2022-04-01 05:38:27 -05:00
22c5a8a83d Created authorization related middleware. 2022-04-01 05:38:26 -05:00
59cb5e27f8 User, match, sport schemas added. 2022-04-01 05:38:26 -05:00
30e921f0ea Added Node packages. 2022-04-01 05:38:26 -05:00
98956a4c5d Updated .gitignore. 2022-04-01 05:38:26 -05:00
22291958d1 Set up linting for server project. 2022-04-01 05:38:26 -05:00
abf238b1fb Created untested GameInfoCard.
With required data structures and functions.
2022-03-28 00:28:09 -05:00
2fed0619a0 Added routing and set up main layout. 2022-03-27 23:26:34 -05:00
eea74dab09 Began mass reorganizing of project and code structure. 2022-03-07 21:09:52 -06:00
8492c82e4f Merge branch 'main' of https://github.com/csc309-winter-2022/team58 2022-03-07 21:05:15 -06:00
1e62ba70d1 Changed to showing visible participate button. 2022-03-07 20:51:25 -06:00
fba8212aeb Fixed access to dashboard page. 2022-03-07 20:49:43 -06:00
5c7e26a1a9 Added package-lock.json to .gitignore. 2022-03-07 20:37:10 -06:00
Sahni-Arjun
df2071439d changes 2022-03-06 21:59:05 -05:00
Arjun Sahni
e773477fb0
Merge pull request #5 from csc309-winter-2022/develop
Develop
2022-03-06 21:51:05 -05:00
Arjun Sahni
196c36444d
Update README.md 2022-03-06 21:50:24 -05:00
6a9e677043 Created user dashboard. 2022-03-06 20:49:13 -06:00
Hansi Xu
329cc7c74f Merge branch 'main' of https://github.com/csc309-winter-2022/team58 2022-03-06 21:37:58 -05:00
Hansi Xu
30c407563d Fixed chat 2022-03-06 21:37:30 -05:00
Piyush Sharma
4f338a2005 Merge branch 'main' of https://github.com/csc309-winter-2022/team58 2022-03-06 21:35:14 -05:00
Piyush Sharma
b717c94e4e Added comment 2022-03-06 21:35:10 -05:00
caed17bc8e Added user dashboard. 2022-03-06 20:31:17 -06:00
Piyush Sharma
c7cd9481f3
Update README.md 2022-03-06 21:25:18 -05:00
d402a67266 Merged with latest dev branch. 2022-03-06 20:25:07 -06:00
Piyush Sharma
340acfa2ed Updated Readme 2022-03-06 21:22:50 -05:00
c1fe10ddc8 Removed package-lock.json. 2022-03-06 20:14:50 -06:00
Sahni-Arjun
532b5d3876 minor changes 2022-03-06 21:13:11 -05:00
38d9267bff Initial commit of static interfaces. 2022-03-06 20:12:31 -06:00
Sahni-Arjun
528cb80c1f minor changes, added navbar to admin 2022-03-06 21:01:56 -05:00
Arjun Sahni
a1ed8d14fa
Merge pull request #4 from csc309-winter-2022/develop
Develop
2022-03-06 20:52:17 -05:00
Arjun Sahni
641eca074f
Merge pull request #3 from csc309-winter-2022/admin
admin functionality
2022-03-06 20:51:53 -05:00
Sahni-Arjun
ae1c05c944 admin functionality 2022-03-06 20:49:04 -05:00
Hansi Xu
7ea36e01e5 Merge branch 'develop' 2022-03-06 20:32:40 -05:00
Hansi Xu
9c583ce5e0 Merge branch 'chat' into develop 2022-03-06 20:31:41 -05:00
Piyush Sharma
61c138f5c3
Merge pull request #2 from csc309-winter-2022/develop
Merging authentication and homepage into main branch
2022-03-06 20:27:55 -05:00
Piyush Sharma
d9b0c827c8
Merge pull request #1 from csc309-winter-2022/authentication
Added Sign in/up, Home, and Navbar
2022-03-06 20:24:01 -05:00
Piyush Sharma
e1befed115 Added Homepage and Navbar 2022-03-06 20:22:23 -05:00
Hansi Xu
0a1323da8a Finally fixed input 2022-03-06 18:15:21 -05:00
Hansi Xu
7e17e1c9e9 Adding profile pics for phase1 (hard coded contacts) 2022-03-06 16:22:26 -05:00
Hansi Xu
ab80301f31 Adding chat components 2022-03-06 15:57:04 -05:00
Hansi Xu
c332594b40 Revert "The chat component"
This reverts commit fa8c2e7cf9.
2022-03-06 15:53:19 -05:00
Hansi Xu
fa8c2e7cf9 The chat component 2022-03-06 15:40:56 -05:00
Piyush Sharma
4c75dc2c75 Cleaned up files 2022-03-05 18:51:36 -05:00
ffe8dad9ff Added simple suggested matches template. 2022-03-02 03:08:33 -06:00
1e0f79387a Some template design for horizontal Match information. 2022-03-02 02:24:36 -06:00
Piyush Sharma
1b86e6260f Added Routing and Sign in/up Pages 2022-03-01 13:32:42 -05:00
Hansi Xu
e4608b1982 Fixed first commit 2022-02-27 17:46:16 -05:00
Hansi Xu
cce32d2267 Did a quick create-react-app
"What's with all these vulnerabilities?"
2022-02-21 17:02:07 -05:00
Hansi Xu
75725c2124 First commit
Just setting up
2022-02-21 16:46:40 -05:00
mark-kazakevich
489cffca6d
Initial commit 2022-02-13 22:00:36 -05:00
108 changed files with 40340 additions and 204 deletions

2
.gitignore vendored
View File

@ -347,3 +347,5 @@ sketch
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
server/public/
server/mongo-data/

View File

@ -1,3 +1,31 @@
# Sports Matcher
# team58
Sports Matcher is an application that allows users to connect with other athletes, schedule sports meets, and rent sports equipment!
**Built Using**
It is built using the React framework and React Bootstrap library. It uses MongoDB for the database, Express for the server, and Axios for requests.
**Instructions**
To use Sports Matcher, please go to https://hidden-bayou-86321.herokuapp.com
From here you can Sign In or Sign Up.
Signing in as 'admin' will take you to the admin page. You will be able to see a list of current matches, users and suspended users. You will need to click the appropriate button for the correct table to appear.
Every page has a navbar at the top. There is a chat and profile icon. Clicking on the chat icon will take you to the chat page. From the profile icon you can sign out.
**Functionality**
Our app has a fully functioning backend which supports the CRUD functionality for the following entites
1. We have a User entity which has the following attributes: Name, Email and Password, Sports and levels, Griends, Auth level, and suspended status
2. We have a Match which supports the following attributes: Players, Date, Sport and skill, and Location
We also support searching the database for the above entites.
1. Matches can be searched for. They can be sorted and filtered based on location, friends, skill level and date.
2. Users can also be searched for
A CSC309 Project.

View File

@ -1,11 +0,0 @@
const prod = {
env: "production",
api_host: ""
};
const dev = {
env: "development",
api_host: "http://localhost:5000", // web server localhost port
};
// export the appropriate environment
export default process.env.NODE_ENV === "production" ? prod : dev;

436
client/package-lock.json generated
View File

@ -11,8 +11,12 @@
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.2.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.4"
},
@ -2815,6 +2819,57 @@
"node": ">= 8"
}
},
"node_modules/@popperjs/core": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.4.tgz",
"integrity": "sha512-q/ytXxO5NKvyT37pmisQAItCFqA7FD/vNb8dgaJy3/630Fsc+Mz9/9f2SziBoIZ30TJooXyTwZmhi1zjXmObYg==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@react-aria/ssr": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.1.2.tgz",
"integrity": "sha512-amXY11ImpokvkTMeKRHjsSsG7v1yzzs6yeqArCyBIk60J3Yhgxwx9Cah+Uu/804ATFwqzN22AXIo7SdtIaMP+g==",
"dependencies": {
"@babel/runtime": "^7.6.2"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0-rc.1"
}
},
"node_modules/@restart/hooks": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.4.5.tgz",
"integrity": "sha512-tLGtY0aHeIfT7aPwUkvQuhIy3+q3w4iqmUzFLPlOAf/vNUacLaBt1j/S//jv/dQhenRh8jvswyMojCwmLvJw8A==",
"dependencies": {
"dequal": "^2.0.2"
},
"peerDependencies": {
"react": ">=16.8.0"
}
},
"node_modules/@restart/ui": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@restart/ui/-/ui-1.2.0.tgz",
"integrity": "sha512-oIh2t3tG8drZtZ9SlaV5CY6wGsUViHk8ZajjhcI+74IQHyWy+AnxDv8rJR5wVgsgcgrPBUvGNkC1AEdcGNPaLQ==",
"dependencies": {
"@babel/runtime": "^7.13.16",
"@popperjs/core": "^2.10.1",
"@react-aria/ssr": "^3.0.1",
"@restart/hooks": "^0.4.0",
"@types/warning": "^3.0.0",
"dequal": "^2.0.2",
"dom-helpers": "^5.2.0",
"uncontrollable": "^7.2.1",
"warning": "^4.0.3"
},
"peerDependencies": {
"react": ">=16.14.0",
"react-dom": ">=16.14.0"
}
},
"node_modules/@rollup/plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
@ -3497,6 +3552,11 @@
"@types/node": "*"
}
},
"node_modules/@types/invariant": {
"version": "2.2.35",
"resolved": "https://registry.npmjs.org/@types/invariant/-/invariant-2.2.35.tgz",
"integrity": "sha512-DxX1V9P8zdJPYQat1gHyY0xj3efl8gnMVjiM9iCY6y27lj+PoQWkgjt8jDqmovPqULkKVpKRg8J36iQiA+EtEg=="
},
"node_modules/@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
@ -3595,6 +3655,14 @@
"@types/react": "*"
}
},
"node_modules/@types/react-transition-group": {
"version": "4.4.4",
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.4.tgz",
"integrity": "sha512-7gAPz7anVK5xzbeQW9wFBDg7G++aPLAFY0QaSMOou9rJZpbuI58WAuJrgu+qR92l61grlnCUe7AFX8KGahAgug==",
"dependencies": {
"@types/react": "*"
}
},
"node_modules/@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
@ -3656,6 +3724,11 @@
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz",
"integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg=="
},
"node_modules/@types/warning": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz",
"integrity": "sha1-DSUBJorY+ZYrdA04fEZU9fjiPlI="
},
"node_modules/@types/ws": {
"version": "8.5.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
@ -4453,6 +4526,14 @@
"node": ">=4"
}
},
"node_modules/axios": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
"dependencies": {
"follow-redirects": "^1.14.8"
}
},
"node_modules/axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
@ -4861,6 +4942,18 @@
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
},
"node_modules/bootstrap": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz",
"integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/bootstrap"
},
"peerDependencies": {
"@popperjs/core": "^2.10.2"
}
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -5122,6 +5215,11 @@
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz",
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA=="
},
"node_modules/classnames": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
},
"node_modules/clean-css": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.4.tgz",
@ -6002,6 +6100,14 @@
"node": ">= 0.6"
}
},
"node_modules/dequal": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz",
"integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==",
"engines": {
"node": ">=6"
}
},
"node_modules/destroy": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
@ -6140,6 +6246,15 @@
"utila": "~0.4"
}
},
"node_modules/dom-helpers": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",
"integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",
"dependencies": {
"@babel/runtime": "^7.8.7",
"csstype": "^3.0.2"
}
},
"node_modules/dom-serializer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
@ -7969,6 +8084,14 @@
"he": "bin/he"
}
},
"node_modules/history": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz",
"integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==",
"dependencies": {
"@babel/runtime": "^7.7.6"
}
},
"node_modules/hoopy": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
@ -8329,6 +8452,14 @@
"node": ">= 0.4"
}
},
"node_modules/invariant": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
"dependencies": {
"loose-envify": "^1.0.0"
}
},
"node_modules/ip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
@ -12924,6 +13055,23 @@
"react-is": "^16.13.1"
}
},
"node_modules/prop-types-extra": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.1.tgz",
"integrity": "sha512-59+AHNnHYCdiC+vMwY52WmvP5dM3QLeoumYuEyceQDi9aEhtwN9zIQ2ZNo25sMyXnbh32h+P1ezDsUpUH3JAew==",
"dependencies": {
"react-is": "^16.3.2",
"warning": "^4.0.0"
},
"peerDependencies": {
"react": ">=0.14.0"
}
},
"node_modules/prop-types-extra/node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"node_modules/prop-types/node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
@ -13097,6 +13245,33 @@
"node": ">=14"
}
},
"node_modules/react-bootstrap": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.2.2.tgz",
"integrity": "sha512-zfVGUU14BMZo7KqR1QHXBAqpbWa6bu4S9dZ6O4rd/hDZi1tiNeGkISbuBednb1TxyXrOwpvnvlHNk3OuYQNq6w==",
"dependencies": {
"@babel/runtime": "^7.17.2",
"@restart/hooks": "^0.4.5",
"@restart/ui": "^1.2.0",
"@types/invariant": "^2.2.35",
"@types/prop-types": "^15.7.4",
"@types/react": ">=16.14.8",
"@types/react-transition-group": "^4.4.4",
"@types/warning": "^3.0.0",
"classnames": "^2.3.1",
"dom-helpers": "^5.2.1",
"invariant": "^2.2.4",
"prop-types": "^15.8.1",
"prop-types-extra": "^1.1.0",
"react-transition-group": "^4.4.2",
"uncontrollable": "^7.2.1",
"warning": "^4.0.3"
},
"peerDependencies": {
"react": ">=16.14.0",
"react-dom": ">=16.14.0"
}
},
"node_modules/react-dev-utils": {
"version": "12.0.0",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.0.tgz",
@ -13237,6 +13412,11 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
"node_modules/react-lifecycles-compat": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"node_modules/react-refresh": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
@ -13245,6 +13425,30 @@
"node": ">=0.10.0"
}
},
"node_modules/react-router": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.2.tgz",
"integrity": "sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==",
"dependencies": {
"history": "^5.2.0"
},
"peerDependencies": {
"react": ">=16.8"
}
},
"node_modules/react-router-dom": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.2.tgz",
"integrity": "sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==",
"dependencies": {
"history": "^5.2.0",
"react-router": "6.2.2"
},
"peerDependencies": {
"react": ">=16.8",
"react-dom": ">=16.8"
}
},
"node_modules/react-scripts": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.0.tgz",
@ -13317,6 +13521,21 @@
}
}
},
"node_modules/react-transition-group": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz",
"integrity": "sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg==",
"dependencies": {
"@babel/runtime": "^7.5.5",
"dom-helpers": "^5.0.1",
"loose-envify": "^1.4.0",
"prop-types": "^15.6.2"
},
"peerDependencies": {
"react": ">=16.6.0",
"react-dom": ">=16.6.0"
}
},
"node_modules/readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
@ -14998,6 +15217,20 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/uncontrollable": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.2.1.tgz",
"integrity": "sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==",
"dependencies": {
"@babel/runtime": "^7.6.3",
"@types/react": ">=16.9.11",
"invariant": "^2.2.4",
"react-lifecycles-compat": "^3.0.4"
},
"peerDependencies": {
"react": ">=15.0.0"
}
},
"node_modules/unicode-canonical-property-names-ecmascript": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
@ -15184,6 +15417,14 @@
"makeerror": "1.0.12"
}
},
"node_modules/warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"dependencies": {
"loose-envify": "^1.0.0"
}
},
"node_modules/watchpack": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz",
@ -18004,6 +18245,43 @@
}
}
},
"@popperjs/core": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.4.tgz",
"integrity": "sha512-q/ytXxO5NKvyT37pmisQAItCFqA7FD/vNb8dgaJy3/630Fsc+Mz9/9f2SziBoIZ30TJooXyTwZmhi1zjXmObYg=="
},
"@react-aria/ssr": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.1.2.tgz",
"integrity": "sha512-amXY11ImpokvkTMeKRHjsSsG7v1yzzs6yeqArCyBIk60J3Yhgxwx9Cah+Uu/804ATFwqzN22AXIo7SdtIaMP+g==",
"requires": {
"@babel/runtime": "^7.6.2"
}
},
"@restart/hooks": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.4.5.tgz",
"integrity": "sha512-tLGtY0aHeIfT7aPwUkvQuhIy3+q3w4iqmUzFLPlOAf/vNUacLaBt1j/S//jv/dQhenRh8jvswyMojCwmLvJw8A==",
"requires": {
"dequal": "^2.0.2"
}
},
"@restart/ui": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@restart/ui/-/ui-1.2.0.tgz",
"integrity": "sha512-oIh2t3tG8drZtZ9SlaV5CY6wGsUViHk8ZajjhcI+74IQHyWy+AnxDv8rJR5wVgsgcgrPBUvGNkC1AEdcGNPaLQ==",
"requires": {
"@babel/runtime": "^7.13.16",
"@popperjs/core": "^2.10.1",
"@react-aria/ssr": "^3.0.1",
"@restart/hooks": "^0.4.0",
"@types/warning": "^3.0.0",
"dequal": "^2.0.2",
"dom-helpers": "^5.2.0",
"uncontrollable": "^7.2.1",
"warning": "^4.0.3"
}
},
"@rollup/plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
@ -18493,6 +18771,11 @@
"@types/node": "*"
}
},
"@types/invariant": {
"version": "2.2.35",
"resolved": "https://registry.npmjs.org/@types/invariant/-/invariant-2.2.35.tgz",
"integrity": "sha512-DxX1V9P8zdJPYQat1gHyY0xj3efl8gnMVjiM9iCY6y27lj+PoQWkgjt8jDqmovPqULkKVpKRg8J36iQiA+EtEg=="
},
"@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
@ -18591,6 +18874,14 @@
"@types/react": "*"
}
},
"@types/react-transition-group": {
"version": "4.4.4",
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.4.tgz",
"integrity": "sha512-7gAPz7anVK5xzbeQW9wFBDg7G++aPLAFY0QaSMOou9rJZpbuI58WAuJrgu+qR92l61grlnCUe7AFX8KGahAgug==",
"requires": {
"@types/react": "*"
}
},
"@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
@ -18652,6 +18943,11 @@
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz",
"integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg=="
},
"@types/warning": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz",
"integrity": "sha1-DSUBJorY+ZYrdA04fEZU9fjiPlI="
},
"@types/ws": {
"version": "8.5.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
@ -19218,6 +19514,14 @@
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.1.tgz",
"integrity": "sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw=="
},
"axios": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
"requires": {
"follow-redirects": "^1.14.8"
}
},
"axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
@ -19542,6 +19846,12 @@
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
},
"bootstrap": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz",
"integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==",
"requires": {}
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -19723,6 +20033,11 @@
"resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz",
"integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA=="
},
"classnames": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
},
"clean-css": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.4.tgz",
@ -20358,6 +20673,11 @@
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
},
"dequal": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz",
"integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug=="
},
"destroy": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
@ -20473,6 +20793,15 @@
"utila": "~0.4"
}
},
"dom-helpers": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",
"integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",
"requires": {
"@babel/runtime": "^7.8.7",
"csstype": "^3.0.2"
}
},
"dom-serializer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
@ -21784,6 +22113,14 @@
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
},
"history": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz",
"integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==",
"requires": {
"@babel/runtime": "^7.7.6"
}
},
"hoopy": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
@ -22048,6 +22385,14 @@
"side-channel": "^1.0.4"
}
},
"invariant": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
"requires": {
"loose-envify": "^1.0.0"
}
},
"ip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
@ -25232,6 +25577,22 @@
}
}
},
"prop-types-extra": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.1.tgz",
"integrity": "sha512-59+AHNnHYCdiC+vMwY52WmvP5dM3QLeoumYuEyceQDi9aEhtwN9zIQ2ZNo25sMyXnbh32h+P1ezDsUpUH3JAew==",
"requires": {
"react-is": "^16.3.2",
"warning": "^4.0.0"
},
"dependencies": {
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
}
}
},
"proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
@ -25347,6 +25708,29 @@
"whatwg-fetch": "^3.6.2"
}
},
"react-bootstrap": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.2.2.tgz",
"integrity": "sha512-zfVGUU14BMZo7KqR1QHXBAqpbWa6bu4S9dZ6O4rd/hDZi1tiNeGkISbuBednb1TxyXrOwpvnvlHNk3OuYQNq6w==",
"requires": {
"@babel/runtime": "^7.17.2",
"@restart/hooks": "^0.4.5",
"@restart/ui": "^1.2.0",
"@types/invariant": "^2.2.35",
"@types/prop-types": "^15.7.4",
"@types/react": ">=16.14.8",
"@types/react-transition-group": "^4.4.4",
"@types/warning": "^3.0.0",
"classnames": "^2.3.1",
"dom-helpers": "^5.2.1",
"invariant": "^2.2.4",
"prop-types": "^15.8.1",
"prop-types-extra": "^1.1.0",
"react-transition-group": "^4.4.2",
"uncontrollable": "^7.2.1",
"warning": "^4.0.3"
}
},
"react-dev-utils": {
"version": "12.0.0",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.0.tgz",
@ -25453,11 +25837,33 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
"react-lifecycles-compat": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"react-refresh": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
"integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A=="
},
"react-router": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.2.tgz",
"integrity": "sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==",
"requires": {
"history": "^5.2.0"
}
},
"react-router-dom": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.2.tgz",
"integrity": "sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==",
"requires": {
"history": "^5.2.0",
"react-router": "6.2.2"
}
},
"react-scripts": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.0.tgz",
@ -25513,6 +25919,17 @@
"workbox-webpack-plugin": "^6.4.1"
}
},
"react-transition-group": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz",
"integrity": "sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg==",
"requires": {
"@babel/runtime": "^7.5.5",
"dom-helpers": "^5.0.1",
"loose-envify": "^1.4.0",
"prop-types": "^15.6.2"
}
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
@ -26754,6 +27171,17 @@
"which-boxed-primitive": "^1.0.2"
}
},
"uncontrollable": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.2.1.tgz",
"integrity": "sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==",
"requires": {
"@babel/runtime": "^7.6.3",
"@types/react": ">=16.9.11",
"invariant": "^2.2.4",
"react-lifecycles-compat": "^3.0.4"
}
},
"unicode-canonical-property-names-ecmascript": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
@ -26896,6 +27324,14 @@
"makeerror": "1.0.12"
}
},
"warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"requires": {
"loose-envify": "^1.0.0"
}
},
"watchpack": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz",

View File

@ -6,13 +6,17 @@
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.2.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"start": "NODE_ENV=development API_HOST=http://localhost:5000 react-scripts start",
"build": "../scripts/build.py",
"test": "react-scripts test",
"eject": "react-scripts eject"

View File

@ -1,38 +0,0 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@ -1,25 +0,0 @@
import logo from "./logo.svg";
import "./App.css";
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;

41
client/src/Layout.js Normal file
View File

@ -0,0 +1,41 @@
import "./styles/Layout.css";
import "./styles/extra.css";
import React from "react";
import { NavLink, Route, Routes } from "react-router-dom";
import Welcome from "./pages/Welcome";
import Navbar from "react-bootstrap/Navbar";
import { Container, Nav, NavbarBrand } from "react-bootstrap";
import NavbarToggle from "react-bootstrap/esm/NavbarToggle";
import NavbarCollapse from "react-bootstrap/esm/NavbarCollapse";
export default class Layout extends React.Component {
render() {
return (
<div id="app">
<header>
<Navbar bg="light" expand="md">
<Container>
<NavbarBrand href="/">Sports Matcher</NavbarBrand>
<NavbarToggle aria-controls="navigation"></NavbarToggle>
<NavbarCollapse id="main-nav">
<Nav className="me-auto">
<li className="nav-item">
<NavLink className="nav-link" to="/" >Home</NavLink>
</li>
</Nav>
</NavbarCollapse>
</Container>
</Navbar>
</header>
<main>
<Routes>
<Route path="/" element={<Welcome></Welcome>}>
</Route>
</Routes>
</main>
<footer>
</footer>
</div>
);
}
}

View File

@ -0,0 +1,36 @@
import React from "react";
import { Button, Card } from "react-bootstrap";
import propTypes from "prop-types";
import { grammaticalListString } from "../utils/strings";
export default class GameInfoCard extends React.Component {
constructor(props) {
super(props);
}
getParticipants() {
let participants = [];
this.props.match.registeredUsers.array.forEach(user => {
participants.push(user.firstName);
});
return participants;
}
render() {
return (
<Card style={{ width: "20rem" }}>
<Card.Body>
<Card.Title>{this.props.match.sport}</Card.Title>
<Card.Subtitle className="mb-2 text-muted">{this.props.match.sport}</Card.Subtitle>
<Card.Text>
Join <strong>{grammaticalListString(this.getParticipants(), 4)}</strong> to play a few matches of <strong>{this.props.match.sport}</strong> at <strong>{this.props.match.location}</strong> on <strong>{this.props.match.dateTime.toLocaleDateString("en-US")}</strong>!
</Card.Text>
<Button variant="primary">Join!</Button>
</Card.Body>
</Card>
);
}
}
GameInfoCard.propTypes = {
match: propTypes.object,
};

View File

@ -0,0 +1,21 @@
import React from "react";
import propTypes from "prop-types";
import GameInfoCard from "./GameInfoCard";
export default class GameInfoCardDisplay extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="horizontal-scroller">
{this.props.recommendedMatches.map((match) => <GameInfoCard key={match.id} match={match}></GameInfoCard>)}
</div>
);
}
}
GameInfoCardDisplay.propTypes = {
recommendedMatches: propTypes.array,
};

View File

@ -1,13 +0,0 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View File

@ -1,12 +1,14 @@
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import Layout from "./Layout";
import reportWebVitals from "./reportWebVitals";
import { BrowserRouter } from "react-router-dom";
import "bootstrap/dist/css/bootstrap.min.css"; // This could be optimized by importing individual css components.
ReactDOM.render(
<React.StrictMode>
<App />
<BrowserRouter>
<Layout />
</BrowserRouter>
</React.StrictMode>,
document.getElementById("root")
);

View File

@ -0,0 +1,28 @@
import React from "react";
import { apiClient } from "../utils/httpClients";
export default class Welcome extends React.Component {
constructor(props) {
super(props);
this.recentMatchesRequest = apiClient.get("/match/recent/15");
}
render() {
return (
<div className="page-root">
<div className="jumbotron" >
<h1>Sports Matcher</h1>
<p>The best place to find a local match for a good game of your favourite sport!</p>
</div>
<div className="text-center p-3 mt-2">
<h2>Why?</h2>
<p>Because you want to play the sports you love while meeting new friends!</p>
{/* TODO: All this text should be expanded on. */}
</div>
<hr />
<div className="p-4">
<h2>Available Matches</h2>
</div>
</div>
);
}
}

View File

@ -0,0 +1,16 @@
.page-root,
main,
#app,
#root {
display: flex;
flex-direction: column;
flex-grow: 1;
}
html,
body {
min-height: 100%;
display: flex;
flex-direction: column;
flex-grow: 1;
}

View File

@ -0,0 +1,19 @@
.jumbotron {
width: 100%;
padding-left: 1.5rem;
padding-right: 1.5rem;
padding-top: 12rem;
padding-bottom: 1rem;
text-align: center;
background-size: cover;
background-color: black;
color: white;
}
.jumbotron h1 {
font-size: 1.5rem;
}
.horizontal-scroller {
overflow-x: scroll;
}

View File

@ -0,0 +1,6 @@
import axios from "axios";
export const apiClient = axios.create({
baseURL: process.env.API_HOST,
timeout: 5000,
});

View File

@ -0,0 +1,22 @@
export function grammaticalListString(items, max) {
if (!items) return null;
if (max < 1) return "";
let built = "";
let index = 0;
items.forEach(item => {
if (index > max) {
built += "and " + items.length + " more ";
return;
}
built += item;
built += ", ";
if (index == max - 1) {
built += "and ";
}
index += 1;
});
return built;
}

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "team58",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}

View File

@ -1,7 +1,7 @@
{
"env": {
"browser": true,
"es2021": true
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {

View File

@ -0,0 +1,94 @@
import express from "express";
import { authenticationGuard } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import matchModel from "../schemas/matchModel.js";
import sportModel from "../schemas/sportModel.js";
import userModel from "../schemas/userModel.js";
const MatchController = express.Router();
MatchController.get("/search/:sport", needDatabase, async (req, res) => {
try {
let sport = sportModel.findByName(req.params.sport);
let query = matchModel.find({ sport: sport._id });
query.where("when").gte(Date.now); // We don't want to return any results of matches that have already occurred.
if (req.session.userId) query.where("publicity").gte(1).where("friends").in(req.session.userId);
if (req.query.within) query.where("location").within({ center: req.query.location.split(","), radius: req.query.within });
if (req.query.minDifficulty) query.where("difficulty").gte(req.query.minDifficulty);
if (req.query.maxDifficulty) query.where("difficulty").lte(req.query.maxDifficulty);
if (req.query.beforeDate) query.where("when").lte(req.query.beforeDate);
let queryResults = await query;
res.send({ queryResults });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
let limit = req.params.limit;
if (!req.params.limit) limit = 10;
if (isNaN(limit)) {
res.status(400).send("Limit parameter not a number.");
return;
}
if (limit > 50) {
res.status(400).send("Limit greater than maximum limit of 50.");
return;
}
try {
const recent = await matchModel.find().where("publicity").gte(2).limit(limit).sort({ createDate: -1 });
res.status(200).send({ recent: recent });
} catch (err) {
console.error(err);
res.status(500).send("Internal server error.");
// TODO: Check and improve error handling.
}
});
// TODO: delete, update match.
MatchController.post("/", needDatabase, authenticationGuard, async (req, res) => {
try {
const userId = req.session.userId;
const user = await userModel.findById(userId);
const match = new matchModel({
title: req.body.title,
when: req.body.when,
public: req.body.public,
location: req.body.location,
creator: userId,
difficulty: req.body.difficulty,
sport: await sportModel.findByName(req.body.sport),
participants: [user._id]
});
await match.save();
user.createdMatches.push(match._id);
user.participatingMatches.push(match._id);
await user.save();
res.status(201).send(match);
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
// TODO: Develop the error handling.
}
});
MatchController.get("/:matchId", needDatabase, async (req, res) => {
if (!req.params.matchId) {
res.status(404).send("Id must be provided to retrieve match");
return;
}
try {
const match = await matchModel.findById(req.params.matchId);
if (match) {
res.status(200).send(match);
} else {
res.status(404).send("Could not find match with ID: " + req.params.matchId);
}
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Develop the error handling.
}
});
export default MatchController;

View File

@ -0,0 +1,48 @@
import express from "express";
import { authenticationGuard } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import sportModel from "../schemas/sportModel.js";
import userModel from "../schemas/userModel.js";
const SportController = express.Router();
SportController.post("/", needDatabase, authenticationGuard, async (req, res) => {
const user = await userModel.findById(req.session.userId);
try {
if (user.accessLevel <= 2) {
res.status(403).send("Insufficient privileges.");
return;
}
const sport = new sportModel({
name: req.body.name,
maxPlayers: req.body.maxPlayers,
minPlayers: req.body.minPlayers,
description: req.body.description
});
await sport.save();
res.status(201).send("Successfully created new sport.");
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Add proper error checking here.
}
});
SportController.get("/:sportId", needDatabase, async (req, res) => {
try {
res.status(200).send(await sportModel.findById(req.params.sportId));
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Add proper error checking here.
}
});
SportController.get("/", needDatabase, async (req, res) => {
try {
res.status(200).send(await sportModel.find());
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Add proper error checking here.
}
});
export default SportController;

View File

@ -0,0 +1,169 @@
import express from "express";
import { authenticationGuard } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import User from "../schemas/userModel.js";
const UserController = express.Router();
UserController.post("/login", needDatabase, async (req, res) => {
try {
const email = req.body.email;
const pwd = req.body.password;
const user = await User.credentialsExist(email, pwd);
if (!user) {
res.sendStatus(401);
return;
} else {
req.session.userId = user._id;
req.session.email = user.email;
res.status(200).send("Authenticated.");
}
} catch (error) {
if (error.name === "TypeError") {
res.status(400).send("Missing required user info.");
} else if (error.message === "Credentials do not exist.") {
res.status(401).send("Credentials do not exist.");
} else {
console.error(error);
if (process.env.NODE_ENV === "development") {
res.status(500).send(error.toString());
} else {
res.status(500).send("Internal server error. This issue has been noted.");
}
}
}
});
UserController.get("/logout", authenticationGuard, (req, res) => {
req.session.destroy((err) => {
if (err) {
console.error(err);
if (process.env.NODE_ENV === "development") {
res.status(500).send(err.toString());
} else {
res.status(500).send("Internal server error. This issue has been noted.");
}
res.status(500).send("");
} else {
res.sendStatus(200);
}
});
});
UserController.get("/email/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (selUser.email.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ email: selUser.email });
} else {
res.status(401).send("Could not authenticate request.");
}
});
UserController.get("/firstName/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (selUser.firstName.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ firstName: selUser.firstName });
} else {
res.status(401).send("Could not authenticate request.");
}
});
UserController.get("/lastName/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (selUser.lastName.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ email: selUser.lastName });
} else {
res.status(401).send("Could not authenticate request.");
}
});
UserController.get("/phone/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (selUser.phone.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ phone: selUser.phone });
} else {
res.status(401).send("Could not authenticate request.");
}
});
UserController.get("/participatingMatches/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (selUser.participatingMatches.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ participatingMatches: selUser.participatingMatches });
} else {
res.status(401).send("Could not authenticate request.");
}
});
UserController.get("/joinDate/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ joinDate: selUser.joinDate });
} else {
res.status(401).send("Could not authenticate request.");
}
});
UserController.get("/createdMatches/:userId?", needDatabase, authenticationGuard, async (req, res) => {
if (!req.params.userId) req.params.userId = req.session.userId;
const curUser = await User.findById(req.session.userId);
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
if (curUser._id === selUser._id || curUser.accessLevel > 2) {
res.status(200).send({ createdMatches: selUser.createdMatches });
} else {
res.status(401).send("Could not authenticate request.");
}
});
// TODO: Finish update requests using put.
UserController.post("/", needDatabase, async (req, res) => {
try {
let createdUser = new User({
email: req.body.email,
firstName: req.body.firstName,
lastName: req.body.lastName,
phone: req.body.phone,
password: req.body.password,
});
await createdUser.save();
res.sendStatus(201);
return;
} catch (err) {
if (err.name === "TypeError" || err.name === "ValidationError") {
if (process.env.NODE_ENV === "development") {
console.error(err);
res.status(400).send(err.toString());
} else {
res.status(400).send("Missing required user info.");
}
} else if (err.name === "MongoServerError" && err.message.startsWith("E11000")) {
if (process.env.NODE_ENV === "development") {
console.error(err);
res.status(409).send(err.toString());
} else {
res.status(409).send("User already exists.");
}
} else {
console.error(err);
if (process.env.NODE_ENV === "development") {
res.status(500).send(err.toString());
} else {
res.status(500).send("Internal server error. This issue has been noted.");
}
}
}
});
export default UserController;

View File

@ -0,0 +1,2 @@
export const mongooseDbName = process.env.DB_NAME || "sm_db";
export const mongoURI = process.env.MONGODB_URI || "mongodb://127.0.0.1:27017";

View File

@ -0,0 +1,30 @@
import MongoStore from "connect-mongo";
import session from "express-session";
import { mongooseDbName, mongoURI } from "../database/mongoose.js";
const sessionConf = {
secret: process.env.SESSION_SECRET || "super duper secret string.",
cookie: {
expires: process.env.SESSION_TIMEOUT || 300000,
httpOnly: true,
},
saveUninitialized: false,
resave: false,
};
if (process.env.NODE_ENV === "production") {
sessionConf.cookie.secure = true;
sessionConf.store = MongoStore.create({ mongoUrl: mongoURI, dbName: mongooseDbName });
}
export const userSession = session(sessionConf);
export function authenticationGuard(req, res, next) {
if (req.session.userId) {
next();
} else {
res.sendStatus(401);
return;
}
}
// TODO: Authentication
// TODO: Identity
// TODO: Authority

View File

@ -0,0 +1,9 @@
import mongoose from "mongoose";
export function needDatabase(res, req, next) {
if (mongoose.connection.readyState != 1) {
res.status(500).send("Internal server error: Database connection faulty.");
} else {
next();
}
}

2740
server/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,19 +2,28 @@
"name": "server",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "",
"main": "server.js",
"scripts": {
"develop": "NODE_ENV=development nodemon server.js",
"start": "NODE_ENV=production node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^8.12.0"
"eslint": "^8.12.0",
"nodemon": "^2.0.15"
},
"dependencies": {
"bcrypt": "^5.0.1",
"body-parser": "^1.19.2",
"connect-mongo": "^4.6.0",
"cors": "^2.8.5",
"express": "^4.17.3",
"mongoose": "^6.2.8"
"express-session": "^1.17.2",
"mongoose": "^6.2.8",
"validator": "^13.7.0"
}
}

View File

@ -1,16 +0,0 @@
{
"files": {
"main.css": "/static/css/main.073c9b0a.css",
"main.js": "/static/js/main.20b9b294.js",
"static/js/787.c4e7f8f9.chunk.js": "/static/js/787.c4e7f8f9.chunk.js",
"static/media/logo.svg": "/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg",
"index.html": "/index.html",
"main.073c9b0a.css.map": "/static/css/main.073c9b0a.css.map",
"main.20b9b294.js.map": "/static/js/main.20b9b294.js.map",
"787.c4e7f8f9.chunk.js.map": "/static/js/787.c4e7f8f9.chunk.js.map"
},
"entrypoints": [
"static/css/main.073c9b0a.css",
"static/js/main.20b9b294.js"
]
}

View File

@ -1 +0,0 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.20b9b294.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

View File

@ -1,2 +0,0 @@
body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{align-items:center;background-color:#282c34;color:#fff;display:flex;flex-direction:column;font-size:calc(10px + 2vmin);justify-content:center;min-height:100vh}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes App-logo-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}
/*# sourceMappingURL=main.073c9b0a.css.map*/

View File

@ -1 +0,0 @@
{"version":3,"file":"static/css/main.073c9b0a.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF,CCZA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,mDAA4C,CAA5C,2CACF,CACF,CAEA,YAKE,kBAAmB,CAJnB,wBAAyB,CAOzB,UAAY,CALZ,YAAa,CACb,qBAAsB,CAGtB,4BAA6B,CAD7B,sBAAuB,CAJvB,gBAOF,CAEA,UACE,aACF,CAEA,iCACE,GACE,8BAAuB,CAAvB,sBACF,CACA,GACE,+BAAyB,CAAzB,uBACF,CACF,CAPA,yBACE,GACE,8BAAuB,CAAvB,sBACF,CACA,GACE,+BAAyB,CAAzB,uBACF,CACF","sources":["index.css","App.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n",".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"],"names":[],"sourceRoot":""}

View File

@ -1,2 +0,0 @@
"use strict";(self.webpackChunkclient=self.webpackChunkclient||[]).push([[787],{787:function(e,t,n){n.r(t),n.d(t,{getCLS:function(){return y},getFCP:function(){return g},getFID:function(){return C},getLCP:function(){return P},getTTFB:function(){return D}});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},d=c("first-input",p);n=m(e,v,t),d&&f((function(){d.takeRecords().map(p),d.disconnect()}),!0),d&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=p,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
//# sourceMappingURL=787.c4e7f8f9.chunk.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,41 +0,0 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/** @license React v0.20.2
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,27 @@
import mongoose from "mongoose";
import ModelNameRegister from "./modelNameRegister.js";
const Types = mongoose.Schema.Types; // Some types require defining from this object.
const matchSchema = new mongoose.Schema({
title: { type: String, required: true, trim: true },
when: { type: Date, required: true },
publicity: { type: Number, required: true, default: 2 },
location: {
type: [Number],
required: true,
validate: {
validator: function (v) {
return v.length === 2;
},
message: "Invalid coordinate format (array not length of 2)."
}
},
creator: { type: Types.ObjectId, ref: ModelNameRegister.User },
participants: { type: [{ type: Types.ObjectId, ref: ModelNameRegister.User }], required: true, default: [] },
difficulty: { type: Number, required: true },
sport: { type: Types.ObjectId, ref: ModelNameRegister.Sport },
createDate: { type: Date, required: true, default: Date.now }
});
export default mongoose.model(ModelNameRegister.Match, matchSchema);

View File

@ -0,0 +1,5 @@
export default {
Match: "match",
User: "user",
Sport: "sport"
};

View File

@ -0,0 +1,19 @@
import mongoose from "mongoose";
import ModelNameRegister from "./modelNameRegister.js";
const sportSchema = new mongoose.Schema({
name: { type: String, required: true, unique: true, trim: true },
minPlayers: { type: Number, required: true, default: 1 },
description: { type: String, required: true, trim: true }
});
sportSchema.pre("save", function (next) {
this.name = this.name.toLowerCase();
next();
});
sportSchema.statics.findByName = function (name) {
return this.findOne({ name: name.trim().toLowerCase() });
};
export default mongoose.model(ModelNameRegister.Sport, sportSchema);

View File

@ -0,0 +1,68 @@
import mongoose from "mongoose";
import validator from "validator";
import bcrypt from "bcrypt";
import modelNameRegister from "./modelNameRegister.js";
const Types = mongoose.Schema.Types;
const userSchema = new mongoose.Schema({
email: {
type: String,
required: true,
minlength: 1,
trim: true,
unique: true,
validate: {
validator: validator.isEmail,
message: "String not email.",
}
},
firstName: { type: String, required: true, trim: true },
lastName: { type: String, required: true, trim: true },
joinDate: { type: Date, default: Date.now, required: true },
phone: { type: Number, required: false, min: 0 },
password: {
type: String,
required: true,
minlength: 8
// TODO: Custom validator for password requirements?
},
createdMatches: { type: [{ type: Types.ObjectId, ref: modelNameRegister.Match }], required: true, default: [] },
participatingMatches: { type: [{ type: Types.ObjectId, ref: modelNameRegister.Match }], required: true, default: [] },
emailPublicity: { type: Number, required: true, default: 0 },
bioPublicity: { type: Boolean, required: true, default: false },
phonePublicity: { type: Boolean, required: true, default: false },
participatingMatchesPublicity: { type: Boolean, required: true, default: false },
friends: { type: Types.ObjectId, ref: modelNameRegister.User },
accessLevel: { type: Number, required: true, default: 0 },
});
userSchema.statics.credentialsExist = async function (email, password) {
let userModel = this;
let user = await userModel.findOne({ email: email });
if (!user) {
return Promise.reject(new Error("Credentials do not exist."));
}
if (await bcrypt.compare(password, user.password)) {
return user;
}
};
userSchema.pre("save", function (next) {
let user = this;
if (user.isModified("password")) { // Only perform hashing if the password has changed.
bcrypt.genSalt(10, (err, salt) => {
bcrypt.hash(user.password, salt, (err, hash) => {
if (err) {
throw err; // Probably not, but I'm gonna leave this here for now.
}
user.password = hash;
next();
});
});
} else {
next();
}
});
export default mongoose.model(modelNameRegister.User, userSchema);

View File

@ -1,5 +1,47 @@
import express from "express";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import UserController from "./controllers/userController.js";
import MatchController from "./controllers/matchController.js";
import SportController from "./controllers/sportController.js";
import { userSession } from "./middleware/authority.js";
import { mongooseDbName, mongoURI } from "./database/mongoose.js";
import cors from "cors";
const server = express();
const port = process.env.PORT || 5000;
server.use(express.static("public")); // For all client files.
server.use(express.static("public")); // For all client files.
// Connection documentation: https://mongoosejs.com/docs/connections.html
try {
mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
dbName: mongooseDbName,
});
} catch (error) {
console.error(error);
}
if (process.env.NODE_ENV === "development") {
mongoose.set("bufferCommands", false); // We want to know if there are connection issues immediately for development. Disables globally.
server.use(cors());
}
// Docs: https://www.npmjs.com/package/body-parser
server.use(bodyParser.json());
server.use(bodyParser.urlencoded({ extended: true }));
server.use(userSession);
server.use("/user", UserController);
server.use("/match", MatchController);
server.use("/sport", SportController);
server.listen(port, () => {
console.log(`Server listening on port ${port}.`);
});

350
sports-matcher/.gitignore vendored Normal file
View File

@ -0,0 +1,350 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,node,python,react
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,node,python,react
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Node Patch ###
# Serverless Webpack directories
.webpack/
# Optional stylelint cache
# SvelteKit build / generate output
.svelte-kit
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### react ###
.DS_*
**/*.backup.*
**/*.back.*
node_modules
*.sublime*
psd
thumb
sketch
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# Support for Project snippet scope
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,node,python,react
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
server/mongo-data/**

3
sports-matcher/README.md Normal file
View File

@ -0,0 +1,3 @@
# Sports Matcher
A CSC309 Project.

View File

@ -0,0 +1,41 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"warn",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-unused-vars": "warn"
}
}

23
sports-matcher/client/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@ -0,0 +1,70 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

28053
sports-matcher/client/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.2.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"validator": "^13.7.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "NODE_ENV='development' REACT_APP_API_HOST='http://localhost:5000' react-scripts start",
"build": "../scripts/build.py",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint": "^8.12.0",
"eslint-plugin-react": "^7.29.4"
}
}

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 KiB

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -0,0 +1,86 @@
import "./styles/Layout.css";
import "./styles/extra.css";
import { useState } from "react";
import { NavLink, Route, Routes, useNavigate } from "react-router-dom";
import Welcome from "./pages/Welcome";
import Navbar from "react-bootstrap/Navbar";
import { Container, Nav, NavbarBrand } from "react-bootstrap";
import NavbarToggle from "react-bootstrap/esm/NavbarToggle";
import NavbarCollapse from "react-bootstrap/esm/NavbarCollapse";
import Dashboard from "./pages/Dashboard";
import Logout from "./pages/Logout";
import Rentals from "./pages/Rentals";
import Admin from "./pages/Administration";
import Login from "./pages/Login";
import Context from "./globals.js";
import Signup from "./pages/Signup";
export default function layout() {
const [globals, setGlobals] = useState({
user: null,
update: (updates, onUpdate) => setGlobals((state) => { return { ...state, ...updates }; }, onUpdate),
navigate: useNavigate()
});
let identityDisplay = (
<Nav>
<li className="nav-item">
<NavLink className="nav-link" to="/login" >Login</NavLink>
</li>
<li className="nav-item">
<NavLink className="nav-link" to="/signup" >Sign up!</NavLink>
</li>
</Nav>
);
if (globals.user) {
identityDisplay = (
<Nav>
<li className="nav-item">
<NavLink className="nav-link" to="/" >Hi, {globals.user.firstName}</NavLink>
</li>
<li className="nav-item">
<NavLink className="nav-link" to="/logout" >Logout</NavLink>
</li>
</Nav>
);
}
return (
<div id="app">
<Context.Provider value={globals}>
<header>
<Navbar bg="light" expand="md">
<Container>
<NavbarBrand href="/">Sports Matcher</NavbarBrand>
<NavbarToggle aria-controls="navigation"></NavbarToggle>
<NavbarCollapse id="main-nav">
<Nav className="me-auto">
<li className="nav-item">
<NavLink className="nav-link" to="/" >Home</NavLink>
</li>
</Nav>
{identityDisplay}
</NavbarCollapse>
</Container>
</Navbar>
</header>
<main>
<Routes>
<Route path="/" element={<Welcome />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="/logout" element={<Logout />} />
<Route path="/admin" element={<Admin />} />
<Route path="/rentals" element={<Rentals />} />
</Routes>
</main>
<footer>
</footer>
</Context.Provider>
</div>
);
}

View File

@ -0,0 +1,44 @@
import React from "react";
import globals from "../globals";
import { apiClient } from "../utils/httpClients";
import propTypes from "prop-types";
export default class AuthenticationGuard extends React.Component {
constructor(props) {
super(props);
}
static contextType = globals;
async componentDidMount() {
let userDataResponse = await apiClient.get("/user");
if (userDataResponse.status === 200) {
this.context.update({ user: userDataResponse.data });
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
this.context.navigate("/", { replace: true });
}
} else if (userDataResponse.status == 401) {
this.context.navigate("/signup", { replace: true });
this.context.update({ user: null });
}
}
componentDidUpdate() {
}
render() {
if (this.context.user) {
return this.props.children;
} else {
return null;
}
}
}
AuthenticationGuard.defaultProps = {
accessLevel: 0
};
AuthenticationGuard.propTypes = {
accessLevel: propTypes.number,
children: propTypes.any
};

View File

@ -0,0 +1,53 @@
import React from "react";
import { Carousel } from "react-bootstrap";
export default class HomeCarousel extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Carousel className="jumbotron" variant="light">
<Carousel.Item>
<img
className="d-block w-100"
src='/images/carousel/volleyball_normalized.jpg'
alt="Connect Slide"
/>
<Carousel.Caption>
<div className="captionStyle">
<h1>Connect</h1>
<h2>Connect with other athletes in your area!</h2>
</div>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
className="d-block w-100"
src='/images/carousel/schedule_normalized.jpg'
alt="Schedule Slide"
/>
<Carousel.Caption>
<div className="captionStyle">
<h1>Schedule</h1>
<h2>Schedule sport meets with other athletes!</h2>
</div>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img
src='/images/carousel/rentals_normalized.jpg'
alt="Rent Slide"
className="d-block w-100"
/>
<Carousel.Caption>
<div className="captionStyle">
<h1>Rent</h1>
<h2>Rent sports equipment from other athletes!</h2>
</div>
</Carousel.Caption>
</Carousel.Item>
</Carousel>
);
}
}

View File

@ -0,0 +1,36 @@
import React from "react";
import { Button, Card } from "react-bootstrap";
import propTypes from "prop-types";
import { grammaticalListString } from "../utils/strings";
export default class MatchInfoCard extends React.Component {
constructor(props) {
super(props);
}
getParticipants() {
let participants = [];
this.props.match.participants.forEach(user => {
participants.push(user.firstName);
});
return participants;
}
render() {
return (
<Card style={{ width: "20rem" }}>
<Card.Body>
<Card.Title>{this.props.match.sport.name}</Card.Title>
<Card.Subtitle className="mb-2 text-muted">{this.props.match.title}</Card.Subtitle>
<Card.Text>
Join <strong>{grammaticalListString(this.getParticipants(), 4)}</strong> to play a few matches of <strong>{this.props.match.sport.name}</strong> at <strong>{this.props.match.location.toString()}</strong> on <strong>{new Date(this.props.match.when).toLocaleDateString("en-US")}</strong>!
</Card.Text>
<Button variant="primary">Join!</Button>
</Card.Body>
</Card>
);
}
}
MatchInfoCard.propTypes = {
match: propTypes.object,
};

View File

@ -0,0 +1,24 @@
import React from "react";
import propTypes from "prop-types";
import MatchInfoCard from "./MatchInfoCard";
import "../styles/MatchInfoCardDisplay.css";
export default class MatchInfoCardDisplay extends React.Component {
constructor(props) {
super(props);
}
render() {
let matches = null;
if (this.props.recommendedmatches.length > 0) {
matches = this.props.recommendedmatches.map((match) => <MatchInfoCard key={match._id} match={match}></MatchInfoCard>);
}
return (
<div className="horizontal-scroller">
{matches}
</div>
);
}
}
MatchInfoCardDisplay.propTypes = {
recommendedmatches: propTypes.array,
};

View File

@ -0,0 +1,31 @@
import React from "react";
import { Card } from "react-bootstrap";
//import { Button, Card } from "react-bootstrap";
import propTypes from "prop-types";
//import { grammaticalListString } from "../utils/strings";
export default class MatchInfoCard extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
// <Card style={{ width: "20rem" }}>
<Card>
<Card.Body>
<Card.Title>{this.props.rental.title}</Card.Title>
<Card.Text className="mb-2 text-muted">Rate: {this.props.rental.rate}</Card.Text>
<Card.Text>Date Created: {this.props.rental.createDate}</Card.Text>
<Card.Text>Owner: {this.props.rental.creator}</Card.Text>
<Card.Text>Contact: {this.props.rental.contact}</Card.Text>
<Card.Text>Description: {this.props.rental.description}</Card.Text>
</Card.Body>
</Card>
);
}
}
MatchInfoCard.propTypes = {
rental: propTypes.object,
};

View File

@ -0,0 +1,26 @@
import React from "react";
import { Card } from "react-bootstrap";
import propTypes from "prop-types";
export default class SportInfoCard extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<Card style={{ width: "20rem" }}>
<Card.Body>
<Card.Title>{this.props.sport.name}</Card.Title>
<Card.Subtitle className="mb-2 text-muted">Requires a minimum of {this.props.sport.minPlayers.toString()} players.</Card.Subtitle>
<Card.Text>
{this.props.sport.description}
</Card.Text>
</Card.Body>
</Card>
);
}
}
SportInfoCard.propTypes = {
sport: propTypes.object,
};

View File

@ -0,0 +1,24 @@
import React from "react";
import propTypes from "prop-types";
import SportInfoCard from "./SportInfoCard";
import "../styles/MatchInfoCardDisplay.css";
export default class SportInfoCardDisplay extends React.Component {
constructor(props) {
super(props);
}
render() {
let sports = null;
if (this.props.recommendedsports.length > 0) {
sports = this.props.recommendedsports.map((sport) => <SportInfoCard key={sport._id} sport={sport}></SportInfoCard>);
}
return (
<div className="horizontal-scroller">
{sports}
</div>
);
}
}
SportInfoCardDisplay.propTypes = {
recommendedsports: propTypes.array,
};

View File

@ -0,0 +1,7 @@
import React from "react";
export default React.createContext({
user: null,
update: () => { },
navigate: () => { }
});

View File

@ -0,0 +1,22 @@
import React from "react";
import ReactDOM from "react-dom";
import Layout from "./Layout";
import reportWebVitals from "./reportWebVitals";
import { BrowserRouter } from "react-router-dom";
import "bootstrap/dist/css/bootstrap.min.css"; // This could be optimized by importing individual css components.
console.log(process.env);
ReactDOM.render(
<React.StrictMode>
<BrowserRouter>
<Layout />
</BrowserRouter>
</React.StrictMode>,
document.getElementById("root")
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,251 @@
import React from "react";
import { Button, ButtonGroup, Spinner, Table } from "react-bootstrap";
import "../styles/Admin.css";
import globals from "../globals";
import AuthenticationGuard from "../components/AuthenticationGuard";
import { apiClient } from "../utils/httpClients";
export default class Admin extends React.Component {
constructor(props) {
super(props);
// Use null to indicate not loaded
// Use empty array to indicate no items for that state.
this.state = {
users: null,
suspendedUsers: null,
matches: null,
user: null,
currentTab: "matches",
};
}
static contextType = globals;
async componentDidMount() {
await this.loadActiveUsers();
await this.loadSuspendedUsers();
await this.loadMatches();
}
async loadActiveUsers() {
let response = await apiClient.get("/user/all/active");
if (response.status === 200) {
this.setState({ users: response.data.active });
}
}
async loadSuspendedUsers() {
let response = await apiClient.get("/user/all/suspended");
if (response.status === 200) {
this.setState({ suspendedUsers: response.data.suspended });
} else {
console.error(response.status);
}
}
async loadMatches() {
let response = await apiClient.get("/match/all");
if (response.status === 200) {
this.setState({ matches: response.data.all });
}
}
DeleteButton() {
return <Button onClick={() => {
alert("User deleted.");
}} variant="outline-secondary">Delete</Button>;
}
PardonButton() {
return <Button onClick={() => {
alert("User pardoned.");
}} variant="outline-secondary">Pardon</Button>;
}
EditButton() {
return <Button onClick={() => {
alert("clicked");
}} variant="outline-secondary">Edit</Button>;
}
userTableHead() {
return (
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th></th>
<th></th>
</tr>
</thead>
);
}
matchTableHead() {
return (
<thead>
<tr>
<th>ID</th>
<th>Sport</th>
<th>Date</th>
<th>Location</th>
<th></th>
<th></th>
</tr>
</thead>
);
}
userTableData() {
if (!this.state.users) {
return (
<tr>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
</tr>
);
}
return this.state.users.map((user) => {
const { _id, firstName, lastName, email, phone } = user;
return (
<tr key={_id}>
<td>{_id}</td>
<td>{firstName}</td>
<td>{lastName}</td>
<td>{email}</td>
<td>{phone}</td>
<td>{this.DeleteButton()}</td>
<td>{this.EditButton()}</td>
</tr>
);
});
}
susUserTableData() {
if (!this.state.suspendedUsers) {
return (
<tr>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
</tr>
);
}
return this.state.suspendedUsers.map((user) => {
const { _id, firstName, lastName, email, phone } = user;
return (
<tr key={_id}>
<td>{_id}</td>
<td>{firstName}</td>
<td>{lastName}</td>
<td>{email}</td>
<td>{phone}</td>
<td>{this.DeleteButton()}</td>
<td>{this.EditButton()}</td>
<td>{this.PardonButton()}</td>
</tr>
);
});
}
matchTableData() {
if (!this.state.matches) {
return (
<tr>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
<td><Spinner animation="grow" /></td>
</tr>
);
}
return this.state.matches.map((match) => {
const { _id, sport, when, location } = match;
const sportName = sport.name;
return (
<tr key={_id}>
<td>{_id}</td>
<td>{sportName}</td>
<td>{when}</td>
<td>{location}</td>
<td>{this.DeleteButton()}</td>
<td>{this.EditButton()}</td>
</tr>
);
});
}
renderTableHead() {
if (this.state.currentTab === "matches") {
return this.matchTableHead();
} else if (this.state.currentTab === "users") {
return this.userTableHead();
} else {
return this.userTableHead();
}
}
renderTableData() {
if (this.state.currentTab === "matches") {
return this.matchTableData();
} else if (this.state.currentTab === "users") {
return this.userTableData();
} else {
return this.susUserTableData();
}
}
render() {
return (
<div className="page-root">
<AuthenticationGuard accessLevel={3}>
<React.Fragment>
<div className='center'>
<h1 id='title'>Administration</h1>
<ButtonGroup aria-label="Pages">
<Button onClick={() => {
this.setState({ currentTab: "matches" });
}} variant="outline-secondary" active={this.state.currentTab === "matches"}>Matches</Button>
<Button onClick={() => {
this.setState({ currentTab: "users" });
}} variant="outline-secondary" active={this.state.currentTab === "users"}>Users</Button>
<Button onClick={() => {
this.setState({ currentTab: "suspended" });
}} variant="outline-secondary" active={this.state.currentTab === "suspended"}>Suspended Users</Button>
</ButtonGroup>
</div>
<Table striped bordered hover>
{this.renderTableHead()}
<tbody>
{this.renderTableData()}
{/* {this.matchUserTableData()} */}
</tbody>
</Table>
</React.Fragment>
</AuthenticationGuard >
</div>
);
}
}

View File

@ -0,0 +1,71 @@
import React from "react";
import { Button, InputGroup, FormControl } from "react-bootstrap";
import "../styles/Dashboard.css";
import { apiClient } from "../utils/httpClients.js";
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
import SportInfoCardDisplay from "../components/SportInfoCardDisplay";
import AuthenticationGuard from "../components/AuthenticationGuard";
import globals from "../globals";
export default class Dashboard extends React.Component {
constructor(props) {
super(props);
this.state = {
displayedMatches: [],
displayedSports: [],
displayedEquipment: [],
user: null
};
}
static contextType = globals;
async componentDidMount() {
this.setState({ user: this.context.user });
await this.latestMatches();
await this.availableSports();
}
async latestMatches() {
let recentMatchesRes = await apiClient.get("/match/recent/user/15");
if (recentMatchesRes.status === 200) {
this.setState({ displayedMatches: recentMatchesRes.data.recent });
}
}
async availableSports() {
let availableSportsRes = await apiClient.get("/sport");
if (availableSportsRes.status === 200) {
this.setState({ displayedSports: availableSportsRes.data });
}
}
render() {
return (
<AuthenticationGuard>
<div className="page-root">
<React.Fragment>
<h1></h1>
<InputGroup className="w-50">
<FormControl
placeholder="Search for Matches"
aria-label="Search Bar"
aria-describedby="basic-addon2"
/>
<Button variant="outline-secondary" id="button-addon2">
Search
</Button>
</InputGroup>
<div className="p-4">
<h2>Available Matches</h2>
<MatchInfoCardDisplay recommendedmatches={this.state.displayedMatches} />
</div>
<div className="p-4">
<h2>Available Sports</h2>
<SportInfoCardDisplay recommendedsports={this.state.displayedSports} />
</div>
</React.Fragment>
</div>
</AuthenticationGuard>
);
}
}

View File

@ -0,0 +1,87 @@
import React from "react";
import { Alert, Button, Card, Container, Form } from "react-bootstrap";
import globals from "../globals";
import { apiClient } from "../utils/httpClients";
export default class Login extends React.Component {
constructor(props) {
super(props);
this.state = {
email: "",
password: "",
errorDisplayed: false,
};
this.attemptLogin = this.attemptLogin.bind(this);
}
static contextType = globals;
async componentDidMount() {
}
componentDidUpdate() {
if (this.context.user) {
this.context.navigate("/dashboard");
}
}
async attemptLogin(e) {
e.preventDefault();
const loginResponse = await apiClient.post("/user/login", {
email: this.state.email,
password: this.state.password,
});
if (loginResponse.status === 200) {
this.context.update({ user: loginResponse.data });
} else if (loginResponse.status === 401) {
this.setState({ errorDisplayed: true });
}
}
render() {
let errorMsg = (
<div></div>
);
if (this.state.errorDisplayed) {
errorMsg = (
< Alert variant="danger" onClose={() => this.setState({ errorDisplayed: false })} dismissible >
<Alert.Heading>Incorrect credentials</Alert.Heading>
<p>Double check your provided e-mail and password!</p>
</Alert >
);
}
return (
<div className="d-flex justify-content-center align-items-center
page-root">
{errorMsg}
<Container style={{ maxWidth: "35rem" }}>
<Card>
<Card.Body>
<Card.Title>Login</Card.Title>
<Card.Subtitle>Welcome back!</Card.Subtitle>
<Form onSubmit={this.attemptLogin}>
<Form.Group className="mb-3" controlId="loginEmail">
<Form.Label>E-mail</Form.Label>
<Form.Control type="email" placeholder="Ex. youremail@mail.com" onChange={(e) => {
this.setState({ email: e.target.value });
}} />
</Form.Group>
<Form.Group className="mb-3" controlId="loginPassword">
<Form.Label>Password</Form.Label>
<Form.Control type="password" placeholder="Enter password" onChange={(e) => {
this.setState({ password: e.target.value });
}} />
</Form.Group>
<Button variant="primary" type="submit">
Submit
</Button>
</Form>
</Card.Body>
</Card>
</Container>
</div>
);
}
}

View File

@ -0,0 +1,39 @@
import React from "react";
import globals from "../globals";
import { apiClient } from "../utils/httpClients";
export default class Logout extends React.Component {
constructor(props) {
super(props);
}
static contextType = globals;
async componentDidMount() {
const logoutResponse = await apiClient.get("/user/logout");
if (logoutResponse.status === 200) {
this.redirectTimer = setTimeout(() => {
this.context.navigate("/", { replace: true });
}, 2000);
} else if (logoutResponse.status == 401) {
this.context.navigate("/", { replace: true });
}
this.context.update({ user: null });
}
componentWillUnmount() {
clearTimeout(this.redirectTimer);
}
render() {
return (
<div className="page-root">
<div>
<h1>You are now logged out. See you later!</h1>
<p className="text-muted">We will redirect you shortly...</p>
</div>
</div>
);
}
}

View File

@ -0,0 +1,14 @@
import React from "react";
import { Container } from "react-bootstrap";
export default class Profile extends React.Component {
render() {
return (
<div className="page-root">
<Container>
</Container>
</div>
);
}
}

View File

@ -0,0 +1,89 @@
import React from "react";
import { Button, InputGroup, FormControl } from "react-bootstrap";
import "../styles/Dashboard.css";
// import { apiClient } from "../utils/httpClients.js";
// import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
// import SportInfoCardDisplay from "../components/SportInfoCardDisplay";
import RentalInfoCard from "../components/RentalInfoCard";
// import AuthenticationGuard from "../components/AuthenticationGuard";
// import globals from "../globals";
export default class Rentals extends React.Component {
constructor(props) {
super(props);
this.state = {
rentals: [
{ id: 9, creator: "Person5", createDate: "05/21/2022", title: "Horse", rate: "$1000/day", description: "This is an amazing horse, has won many races", contact: "647 765 1234" },
{ id: 7, creator: "Person1", createDate: "05/05/2022", title: "Tennis Racquet", rate: "$300/day", description: "This is an amazing tennis racquet, used by Roger Federer to win Wimbledon in 2003", contact: "123 456 7890" },
{ id: 3, creator: "Person2", createDate: "05/11/2022", title: "Soccer Ball", rate: "$70/day", description: "This is an amazing soccer ball, signed by Messi", contact: "647 822 4321" },
{ id: 2, creator: "Person3", createDate: "05/13/2022", title: "Basket Ball", rate: "$7/day", description: "This is an amazing basketball, same model as the ones used in the NBA", contact: "467 279 4321" },
{ id: 1, creator: "Person4", createDate: "05/18/2022", title: "Table Tennis Racquet", rate: "$7/day", description: "This is an amazing table tennis racquet, it's very good", contact: "326 111 4321" },
]
};
}
// static contextType = globals;
// async componentDidMount() {
// this.setState({ user: this.context.user });
// await this.latestMatches();
// await this.availableSports();
// }
// async latestMatches() {
// let recentMatchesRes = await apiClient.get("/match/recent/user/15");
// if (recentMatchesRes.status === 200) {
// this.setState({ displayedMatches: recentMatchesRes.data.recent });
// }
// }
// async availableSports() {
// let availableSportsRes = await apiClient.get("/sport");
// if (availableSportsRes.status === 200) {
// this.setState({ displayedSports: availableSportsRes.data });
// }
// }
// renderRentals() {
// let matches = null;
// if (this.props.recommendedmatches.length > 0) {
// matches = this.props.recommendedmatches.map((match) => <MatchInfoCard key={match._id} match={match}></MatchInfoCard>);
// }
// return (
// <div className="horizontal-scroller">
// {matches}
// </div>
// );
// }
rentalsCards() {
return this.state.rentals.map((rental) => {
return (<RentalInfoCard key={rental.id} rental={rental}></RentalInfoCard>);
});
}
render() {
return (
<div className="page-root">
<React.Fragment>
<h1></h1>
<InputGroup className="w-50">
<FormControl
placeholder="Search for Rentals"
aria-label="Search Bar"
aria-describedby="basic-addon2"
/>
<Button variant="outline-secondary" id="button-addon2">
Search
</Button>
</InputGroup>
<div className="p-4">
<h2>Available Rentals</h2>
{this.rentalsCards()}
</div>
</React.Fragment>
</div>
);
}
}

View File

@ -0,0 +1,147 @@
import React from "react";
import { Alert, Button, Card, Container, Form } from "react-bootstrap";
import { Link } from "react-router-dom";
import validator from "validator";
import globals from "../globals";
import { apiClient } from "../utils/httpClients";
export default class Signup extends React.Component {
constructor(props) {
super(props);
this.state = {
user: {
email: null,
firstName: null,
lastName: null,
phone: null,
password: null
},
alert: {
show: false,
variant: null,
headerMsg: null,
content: null
}
};
this.registerUser = this.registerUser.bind(this);
this.setUserState = this.setUserState.bind(this);
}
static contextType = globals;
async registerUser(event) {
event.preventDefault();
let formIssues = this.validateCurrentForm();
if (formIssues.length > 0) {
this.notifyUser("Oops there were issue(s)", (
<ul>
{formIssues.map((issue) => {
return (
<li key={issue}>{issue}</li>
);
})}
</ul>
), "danger");
return;
}
const res = await apiClient.post("/user", this.state.user);
if (res.status === 201) {
this.notifyUser("Success!", <div>You are successfully signed up! You wil be directed to <Link to="/login">login</Link> now.</div>, "success");
this.redirectTimer = setTimeout(() => {
this.context.navigate("/signin", { replace: true });
}, 1000);
} else if (res.status === 409) {
this.notifyUser("User exists!", <div>This user already exists. Try <Link to="/login">logging in</Link> instead.</div>, "danger");
} else if (res.status === 400) {
this.notifyUser("There were errors in the submitted info.", <div>Double check to see if everything is inputted is valid.</div>, "danger");
} else {
this.notifyUser("Error", <div>Internal server error. Please try again later.</div>, "danger");
}
}
componentWillUnmount() {
clearTimeout(this.redirectTimer);
}
validateCurrentForm() {
let formIssues = [];
if (!validator.isEmail(this.state.user.email)) {
formIssues.push("The email submitted is invalid.");
}
if (this.state.user.password.length < 8) {
formIssues.push("The password submitted must have a minimum length of 8 characters.");
}
return formIssues;
}
setUserState(event) {
this.setState((state) => {
state.user[event.target.id] = event.target.value;
return state;
});
}
notifyUser(headerMsg, content, key) {
this.setState((state) => {
state.alert.show = true;
state.alert.headerMsg = headerMsg;
state.alert.content = content;
state.alert.key = key;
return state;
});
}
componentDidMount() {
if (this.context.user) {
this.context.navigate("/dashboard");
}
}
render() {
return (
<div className="page-root pt-3">
<Container>
<Alert show={this.state.alert.show} variant="warning" onClose={() => this.setState((state) => { state.alert.show = false; return state; })} dismissible>
<Alert.Heading>{this.state.alert.headerMsg}</Alert.Heading>
{this.state.alert.content}
</Alert>
<Card style={{ width: "35rem" }}>
<Card.Body>
<Card.Title>Sign up!</Card.Title>
<Card.Subtitle>Welcome to Sports Matcher! Already <Link to="/login">have an account</Link>?</Card.Subtitle>
<Form onSubmit={this.registerUser}>
<Form.Group className="mb-3" controlId="firstName">
<Form.Label>First name</Form.Label>
<Form.Control type="text" placeholder="Ex. John" onChange={this.setUserState} required />
</Form.Group>
<Form.Group className="mb-3" controlId="lastName">
<Form.Label>Last name</Form.Label>
<Form.Control type="text" placeholder="Ex. Smith" onChange={this.setUserState} required />
</Form.Group>
<Form.Group className="mb-3" controlId="email">
<Form.Label>E-mail</Form.Label>
<Form.Control type="email" placeholder="Ex. youremail@mail.com" onChange={this.setUserState} required />
</Form.Group>
<Form.Group className="mb-3" controlId="phone">
<Form.Label>Phone number</Form.Label>
<Form.Control type="text" placeholder="Ex. (123) 456-7890" onChange={this.setUserState} />
</Form.Group>
<Form.Group className="mb-3" controlId="password">
<Form.Label>Password</Form.Label>
<Form.Control type="password" placeholder="Enter password" onChange={this.setUserState} required />
</Form.Group>
<Button variant="primary" type="submit">
Register!
</Button>
</Form>
</Card.Body>
</Card>
</Container>
</div >
);
}
}

View File

@ -0,0 +1,42 @@
import React from "react";
import { apiClient } from "../utils/httpClients";
import HomeCarousel from "../components/HomeCarousel";
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
export default class Welcome extends React.Component {
constructor(props) {
super(props);
this.state = {
displayedMatches: [],
};
}
async componentDidMount() {
await this.latestMatches();
}
async latestMatches() {
let recentMatchesRes = await apiClient.get("/match/recent/15");
if (recentMatchesRes.status === 200) {
this.setState({ displayedMatches: recentMatchesRes.data.recent });
}
}
render() {
return (
<div className="page-root">
<HomeCarousel />
<div className="text-center p-3 mt-2">
<h2>Why?</h2>
<p>Because you want to play the sports you love while meeting new friends!</p>
{/* TODO: All this text should be expanded on. */}
</div>
<hr />
<div className="p-4">
<h2>Available Matches</h2>
<MatchInfoCardDisplay recommendedmatches={this.state.displayedMatches} />
</div>
</div>
);
}
}

View File

@ -0,0 +1,13 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom";

View File

@ -0,0 +1,15 @@
.MainTable {
padding : 20px;
}
.center {
text-align: center;
padding: 21px;
}
.somespace {
padding: 17px;
}

View File

@ -0,0 +1,5 @@
.w-50{
margin-top: 5%;
margin-left: 25%;
margin-right: 25%;
}

View File

@ -0,0 +1,16 @@
.page-root,
main,
#app,
#root {
display: flex;
flex-direction: column;
flex-grow: 1;
}
html,
body {
min-height: 100%;
display: flex;
flex-direction: column;
flex-grow: 1;
}

View File

@ -0,0 +1,4 @@
.horizontal-scroller{
display: flex;
overflow-x: auto;
}

View File

@ -0,0 +1,5 @@
.horizontal-scroller {
overflow-x: scroll;
padding-top: 1rem;
padding-bottom: 1rem;
}

View File

@ -0,0 +1,10 @@
import axios from "axios";
export const apiClient = axios.create({
baseURL: (process.env.REACT_APP_API_HOST || "") + "/api/",
timeout: 5000,
withCredentials: process.env.NODE_ENV === "development",
validateStatus: function (status) {
return status === 401 || status === 200 || status === 400 || status === 201;
}
});

View File

@ -0,0 +1,24 @@
export function grammaticalListString(items, max) {
if (!items) return null;
if (max < 1) return "";
let built = "";
let index = 0;
items.forEach(item => {
if (index > max) {
built += "and " + items.length + " more ";
return;
}
built += item;
if (index < items.length - 1) {
built += ", ";
}
if (index == max - 1) {
built += "and ";
}
index += 1;
});
return built;
}

View File

@ -0,0 +1,17 @@
#!/usr/bin/python
import os
import shutil
DEST_DIR = os.path.abspath("../server/public/")
BUILD_CMD = "react-scripts build"
os.chdir(os.path.abspath(os.path.join(__file__, "../../client")))
errorcode = os.system(BUILD_CMD)
if (errorcode):
print("There was an issue building the client via {}. See above log (exited with error code {}).".format(
BUILD_CMD, errorcode))
else:
print("Received error code of 0. Proceeding with copying files to the public server directory.")
shutil.copytree("./build/", "../server/public/.", dirs_exist_ok=True)
print("Completed copying built files to the public server directory \"{0}\".".format(
DEST_DIR))

View File

@ -0,0 +1 @@
mongod --dbpath ./server/mongo-data

View File

@ -0,0 +1,3 @@
#!/bin/bash
mongod --dbpath ../server/mongo-data

View File

@ -0,0 +1,30 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"warn",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-unused-vars": "warn"
}
}

View File

@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}

View File

@ -0,0 +1,231 @@
import express from "express";
import { requireAdmin, requireAuthenticated } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import matchModel from "../schemas/matchModel.js";
import sportModel from "../schemas/sportModel.js";
import userModel from "../schemas/userModel.js";
const MatchController = express.Router();
MatchController.get("/search/:sport", needDatabase, async (req, res) => {
try {
let sport = sportModel.findByName(req.params.sport);
let query = matchModel.find({ sport: sport._id });
query.where("when").gte(Date.now); // We don't want to return any results of matches that have already occurred.
if (req.session.userId) query.where("publicity").gte(1).where("friends").in(req.session.userId);
if (req.query.within) query.where("location").within({ center: req.query.location.split(","), radius: req.query.within });
if (req.query.minDifficulty) query.where("difficulty").gte(req.query.minDifficulty);
if (req.query.maxDifficulty) query.where("difficulty").lte(req.query.maxDifficulty);
if (req.query.beforeDate) query.where("when").lte(req.query.beforeDate);
let queryResults = await query;
res.send({ results: queryResults });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
try {
let limit = parseInt(req.params.limit);
if (!req.params.limit) limit = 10;
if (isNaN(limit)) {
res.status(400).send("Limit parameter not a number.");
return;
}
if (limit > 50) {
res.status(400).send("Limit greater than maximum limit of 50.");
return;
}
let recent = matchModel.find().where("publicity").gte(2);
recent = await recent.sort({ createDate: -1 }).limit(limit).populate(["sport", "participants"]);
res.status(200).send({ recent: recent });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
MatchController.get("/all", requireAdmin, async (req, res) => {
try {
const allmatches = await matchModel.find().populate("sport");
res.status(200).send({ all: allmatches });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
MatchController.get("/recent/user/:limit", needDatabase, requireAuthenticated, async (req, res) => {
try {
let user = req.user;
let limit = parseInt(req.params.limit);
if (!req.params.limit) limit = 10;
if (isNaN(limit)) {
res.status(400).send("Limit parameter not a number.");
return;
}
let recent = await matchModel.find({ creator: user._id }).sort({ createDate: -1 }).limit(limit).populate(["sport", "participants"]);
res.status(200).send({ recent: recent });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
MatchController.post("/", needDatabase, requireAuthenticated, async (req, res) => {
try {
const userId = req.session.userId;
const user = await userModel.findById(userId);
const match = new matchModel({
title: req.body.title,
when: req.body.when,
public: req.body.public,
location: req.body.location,
creator: userId,
difficulty: req.body.difficulty,
sport: await sportModel.findByName(req.body.sport),
participants: [user._id]
});
if (!match.sport) {
res.status(400).send("Invalid sport name provided.");
return;
}
await match.save();
user.createdMatches.push(match._id);
user.participatingMatches.push(match._id);
await user.save();
res.status(201).send({ createdMatch: match });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
// TODO: Develop the error handling.
}
});
MatchController.patch("/:id", needDatabase, requireAuthenticated, async (req, res) => {
try {
const match = await matchModel.findById(req.params.id);
if (!match) {
res.status(400).send("Invalid match ID provided.");
return;
}
if (req.user._id !== match.creator && req.user.accessLevel < 3) {
res.status(401).send("Not authorized.");
return;
}
if (req.body._id) {
res.status(400).send("Cannot change ID of match.");
return;
}
if (req.body.creator) {
res.status(400).send("Cannot change creator of match.");
return;
}
await match.updateOne(req.body);
res.status(200).send({ updatedMatch: match });
} catch (error) {
res.status(200).send("Internal server error.");
}
});
MatchController.delete("/:id", needDatabase, requireAuthenticated, async (req, res) => {
try {
const match = await matchModel.findById(req.params.id);
if (!match) {
res.status(400).send("Invalid match ID provided.");
return;
}
if (req.user._id !== match.creator && req.user.accessLevel < 3) {
res.status(401).send("Not authorized.");
return;
}
await match.deleteOne();
res.status(200).send("Deleted.");
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
MatchController.get("/:id", needDatabase, async (req, res) => {
try {
if (!req.params.id) {
res.status(404).send("Id must be provided to retrieve match");
return;
}
const match = await matchModel.findById(req.params.id).populate("sport");
if (match) {
res.status(200).send({ match: match });
} else {
res.status(404).send("Could not find match with ID: " + req.params.id);
}
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
// TODO: Improve the error handling.
}
});
MatchController.get("/join/:id", needDatabase, requireAuthenticated, async (req, res) => {
try {
const match = await matchModel.findById(req.params.id);
const user = req.user;
if (!match) {
res.status(400).send("Invalid match ID provided.");
return;
}
if (user.participatingMatches.includes(match._id)) {
res.status(400).send("Already participating in match.");
return;
}
match.participants.push(user._id);
user.participatingMatches.push(match._id);
await match.save();
await user.save();
res.status(200).send("Joined.");
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
MatchController.get("/leave/:id", needDatabase, requireAuthenticated, async (req, res) => {
try {
const match = await matchModel.findById(req.params.id);
const user = req.user;
if (!match) {
res.status(400).send("Invalid match ID provided.");
return;
}
if (!user.participatingMatches.includes(match._id)) {
res.status(400).send("Not part of match.");
return;
}
const userIndex = match.participants.indexOf(user._id);
match.participants.splice(userIndex, 1);
await match.save();
const matchIndex = user.participatingMatches.indexOf(match._id);
user.participatingMatches.splice(matchIndex, 1);
await user.save();
res.status(200).send("Left match.");
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
export default MatchController;

View File

@ -0,0 +1,115 @@
import express from "express";
import { requireAuthenticated } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import rentalModel from "../schemas/rentalModel.js";
import userModel from "../schemas/userModel.js";
const rentalController = express.Router();
rentalController.post("/", needDatabase, requireAuthenticated, async (req, res) => {
try {
const user = req.user;
req.body.createDate = undefined;
req.body.creator = user._id;
const rental = new rentalModel(req.body);
await rental.save();
res.status(201).send({ createdRental: rental });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
rentalController.get("/:id", needDatabase, async (req, res) => {
try {
const rental = await rentalModel.findById(req.params.id).populate("creator");
res.status(200).send({ rental: rental });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
rentalController.get("/recent/:limit?", needDatabase, async (req, res) => {
try {
let user = null;
if (req.session.userId) {
user = await userModel.findById(req.session.userId);
}
let limit = parseInt(req.params.limit);
if (!req.params.limit) limit = 10;
if (isNaN(limit)) {
res.status(400).send("Limit parameter is not a number.");
return;
}
if (isNaN(limit)) {
res.status(400).send("Limit parameter not a number.");
return;
}
if (limit > 50) {
res.status(400).send("Limit greater than maximum limit of 50.");
return;
}
let recent = null;
if (user) {
await user.populate("createdRentals");
recent = user.createdRentals.slice(-limit);
} else {
recent = await rentalModel.find().limit(limit).sort({ createDate: -1 });
}
await recent.populate("members.$");
res.status(200).send({ recent: recent });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
rentalController.patch("/:id", needDatabase, requireAuthenticated, async (req, res) => {
try {
const rental = await rentalModel.findById(req.params.id);
if (!rental) {
res.status(400).send("Invalid rental ID provided.");
return;
}
if (req.body._id) {
res.status(400).send("Cannot change ID of rental.");
return;
}
if (req.body.creator) {
res.status(400).send("Cannot change creator of rental.");
return;
}
if (req.user._id !== rental.creator && req.user.accessLevel < 3) {
res.status(401).send("Not authorized.");
return;
}
await rental.updateOne(req.body);
res.status(200).send({ updated: rental });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error.");
}
});
rentalController.delete("/:id", needDatabase, requireAuthenticated, async (req, res) => {
try {
const rental = await rentalModel.findById(req.params.id);
if (!rental) {
res.status(400).send("Invalid match ID provided.");
return;
}
if (req.user._id !== rental.creator && req.user.accessLevel < 3) {
res.status(401).send("Not authorized.");
return;
}
await rental.deleteOne();
res.status(200).send("Deleted.");
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
export default rentalController;

View File

@ -0,0 +1,48 @@
import express from "express";
import { requireAuthenticated } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import sportModel from "../schemas/sportModel.js";
import userModel from "../schemas/userModel.js";
const SportController = express.Router();
SportController.post("/", needDatabase, requireAuthenticated, async (req, res) => {
const user = await userModel.findById(req.session.userId);
try {
if (user.accessLevel <= 2) {
res.status(403).send("Insufficient privileges.");
return;
}
const sport = new sportModel({
name: req.body.name,
maxPlayers: req.body.maxPlayers,
minPlayers: req.body.minPlayers,
description: req.body.description
});
await sport.save();
res.status(201).send("Successfully created new sport.");
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Add proper error checking here.
}
});
SportController.get("/:sportId", needDatabase, async (req, res) => {
try {
res.status(200).send(await sportModel.findById(req.params.sportId));
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Add proper error checking here.
}
});
SportController.get("/", needDatabase, async (req, res) => {
try {
res.status(200).send(await sportModel.find());
} catch (error) {
res.status(500).send("Internal server error.");
// TODO: Add proper error checking here.
}
});
export default SportController;

View File

@ -0,0 +1,218 @@
import express from "express";
import { requireAdmin, requireAuthenticated } from "../middleware/authority.js";
import { needDatabase } from "../middleware/database.js";
import userModel from "../schemas/userModel.js";
import User from "../schemas/userModel.js";
const UserController = express.Router();
UserController.post("/login", needDatabase, async (req, res) => {
try {
const email = req.body.email;
const pwd = req.body.password;
const user = await User.credentialsExist(email, pwd);
if (!user) {
res.sendStatus(401);
return;
} else {
req.session.userId = user._id;
req.session.email = user.email;
user.password = undefined;
res.status(200).send(user);
}
} catch (error) {
if (error.name === "TypeError") {
res.status(400).send("Missing required user info.");
} else if (error.message === "Credentials do not exist.") {
res.status(401).send("Credentials do not exist.");
} else {
console.error(error);
if (process.env.NODE_ENV === "development") {
res.status(500).send(error.toString());
} else {
res.status(500).send("Internal server error. This issue has been noted.");
}
}
}
});
UserController.get("/logout", requireAuthenticated, (req, res) => {
req.session.destroy((err) => {
if (err) {
console.error(err);
if (process.env.NODE_ENV === "development") {
res.status(500).send(err.toString());
} else {
res.status(500).send("Internal server error. This issue has been noted.");
}
res.status(500).send("");
} else {
res.sendStatus(200);
}
});
});
UserController.get("/:id?", needDatabase, requireAuthenticated, async (req, res) => {
let user = null;
if (req.params.id) {
if (req.user.accessLevel > 2) {
user = await userModel.findById(req.params.id);
} else {
res.status(401).send("Unauthorized.");
return;
}
} else {
user = req.user;
}
user.password = undefined;
res.status(200).send(user);
});
UserController.patch("/:id?", needDatabase, requireAuthenticated, async (req, res) => {
try {
let user = null;
if (req.params.id) {
if (req.user.accessLevel > 2) {
user = await userModel.findById(req.params.id);
} else {
res.status(401).send("Unauthorized.");
return;
}
} else {
user = req.user;
}
if (req.body._id) {
res.status(400).send("Cannot change user ID.");
return;
}
if (req.body.createdMatches) {
res.status(400).send("Cannot directly change the list of created matches.");
return;
}
if (req.body.password) {
res.status(400).send("Cannot directly change user password.");
return;
}
if (req.body.participatingMatches) {
res.status(400).send("Cannot directly change the list of participating matches.");
return;
}
if (req.body.joinDate) {
res.status(400).send("Cannot change the join date.");
return;
}
if (req.body.accessLevel && req.user.accessLevel < 3) {
res.status(401).send("Unauthorized to change the access level of this user.");
return;
}
if (req.body.suspend && req.user.accessLevel < 3) {
res.status(401).send("Unauthorized to change the accounts disabled date. ");
return;
}
await user.updateOne(req.body);
res.status(200).send("Updated.");
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
UserController.get("/all", requireAdmin, async (req, res) => {
try {
let all = await userModel.find();
res.status(200).send({ all: all });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
UserController.get("/all/active", requireAdmin, async (req, res) => {
try {
let active = await userModel.find().where("suspend").lt(Date.now());
res.status(200).send({ active: active });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
UserController.get("/all/suspended", requireAuthenticated, async (req, res) => {
try {
let suspended = await userModel.find().where("suspend").gte(Date.now());
res.status(200).send({ suspended: suspended });
} catch (error) {
console.error(error);
res.status(500).send("Internal server error");
}
});
/* TODO: Implement middleware for removing users.
UserController.delete("/:id?", needDatabase, requireAuthenticated, async (req, res) => {
let user = null;
if (req.params.id) {
if (req.user.accessLevel > 2) {
user = await userModel.findById(req.params.id);
} else {
res.status(401).send("Unauthorized.");
return;
}
} else {
user = req.user;
}
await user.deleteOne();
res.status(200).send("Deleted user.");
});
*/
UserController.post("/", needDatabase, async (req, res) => {
try {
const data = {
email: req.body.email,
firstName: req.body.firstName,
lastName: req.body.lastName,
phone: req.body.phone,
password: req.body.password,
};
let createdUser = new User(data);
await createdUser.save();
res.sendStatus(201);
return;
} catch (err) {
if (err.name === "TypeError" || err.name === "ValidationError") {
if (process.env.NODE_ENV === "development") {
console.error(err);
res.status(400).send(err.toString());
} else {
res.status(400).send("Missing required user info.");
}
} else if (err.name === "MongoServerError" && err.message.startsWith("E11000")) {
if (process.env.NODE_ENV === "development") {
console.error(err);
res.status(409).send(err.toString());
} else {
res.status(409).send("User already exists.");
}
} else {
console.error(err);
if (process.env.NODE_ENV === "development") {
res.status(500).send(err.toString());
} else {
res.status(500).send("Internal server error. This issue has been noted.");
}
}
}
});
export default UserController;

View File

@ -0,0 +1,2 @@
export const mongooseDbName = process.env.DB_NAME || "sm_db";
export const mongoURI = process.env.MONGODB_URI || "mongodb://127.0.0.1:27017";

View File

@ -0,0 +1,52 @@
import MongoStore from "connect-mongo";
import session from "express-session";
import { mongooseDbName, mongoURI } from "../database/mongoose.js";
import userModel from "../schemas/userModel.js";
import { checkDatabaseConnection } from "./database.js";
const sessionConf = {
secret: process.env.SESSION_SECRET || "super duper secret string.",
cookie: {
expires: process.env.SESSION_TIMEOUT || 300000,
httpOnly: true,
},
saveUninitialized: false,
resave: false,
};
if (process.env.NODE_ENV === "production") {
sessionConf.cookie.secure = true;
sessionConf.store = MongoStore.create({ mongoUrl: mongoURI, dbName: mongooseDbName });
}
export const userSession = session(sessionConf);
export async function requireAuthenticated(req, res, next) {
if (!checkDatabaseConnection()) {
req.status(500).send("Internal server error.");
return;
}
if (req.session.userId) {
req.user = await userModel.findById(req.session.userId);
next();
} else {
res.status(401).send("Not authorized.");
return;
}
}
export async function requireAdmin(req, res, next) {
if (!checkDatabaseConnection()) {
req.status(500).send("Internal server error.");
return;
}
if (req.session.userId) {
req.user = await userModel.findById(req.session.userId);
if (req.user.accessLevel < 3) {
res.status(401).send("Not authorized");
return;
}
next();
} else {
res.status(401).send("Not authorized.");
return;
}
}

View File

@ -0,0 +1,13 @@
import mongoose from "mongoose";
export function needDatabase(req, res, next) {
if (!checkDatabaseConnection()) {
res.status(500).send("Internal server error: Database connection faulty.");
} else {
next();
}
}
export function checkDatabaseConnection() {
return mongoose.connection.readyState == 1;
}

Some files were not shown because too many files have changed in this diff Show More