diff --git a/.gitignore b/.gitignore index c66ba3a..532eddc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,25 @@ -.env -.venv \ No newline at end of file +# 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* + +.env \ No newline at end of file diff --git a/README.md b/README.md index 4caab5e..58beeac 100644 --- a/README.md +++ b/README.md @@ -1 +1,70 @@ -# communityLeaderboard \ No newline at end of file +# 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) diff --git a/client/.gitignore b/client/.gitignore deleted file mode 100644 index 532eddc..0000000 --- a/client/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# 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* - -.env \ No newline at end of file diff --git a/client/README.md b/client/README.md deleted file mode 100644 index 58beeac..0000000 --- a/client/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# 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) diff --git a/client/public/manifest.json b/client/public/manifest.json deleted file mode 100644 index 080d6c7..0000000 --- a/client/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/client/src/App.css b/client/src/App.css deleted file mode 100644 index 8e80933..0000000 --- a/client/src/App.css +++ /dev/null @@ -1,408 +0,0 @@ -:root { - --NAV-COLOR: rgb(212, 212, 212); - --NAV-BORDER-COLOR: #525151; - --NAV-BGCOLOR: rgb(51, 55, 62); - --NAV-BORDER: 2px solid var(--NAV-BORDER-COLOR); - --CONTENT-H2-COLOR: rgb(212, 212, 212); - --CONTENT-COLOR: rgb(188, 197, 206); - --LINK-COLOR: white; - --LINK-HOVER-BGCOLOR: rgba(62, 216, 219, 0.866); - --LINK-FOCUS-BGCOLOR: rgb(57, 185, 188); - --LINK-ACTIVE-COLOR: rgb(82, 81, 81); -} -*{ - margin:0; - padding: 0; -} -body { - background-color: rgba(228, 251, 251, 0.866); -} - -/* NAVBAR *************************************************************************************** */ -.NavBar { - border-right: var(--NAV-BORDER); - padding: 1rem; - background-color: var(--NAV-BGCOLOR); - width: 18rem; - min-width: 14rem; - box-sizing: border-box; - overflow-y: auto; - position: fixed; - top: 0; - bottom: 0; - transition: width 0.3s ease, height 0.3s ease; -} - -.NavBar > h2 { - font-weight: 500; - color: var(--NAV-COLOR); -} - -.NavBar ul { - list-style-type: none; - padding: 0; - margin-top: 1rem; -} - -.NavBar li { - padding-bottom: 0.3rem; - margin-bottom: 1rem; - display: flex; - align-items: center; -} - -.NavBar li a, -.NavBar li span { - text-decoration: none; - color: var(--NAV-COLOR); - padding: 0.8rem; - border-bottom: 2px solid transparent; - flex-grow: 1; -} - -.NavBar li a:hover, -.NavBar li span:hover { - background-color: var(--LINK-HOVER-BGCOLOR); - color: rgb(253, 254, 254); - cursor: pointer; - border-radius: 7px; -} - -.NavBar li:active, -.NavBar li a:active, -.NavBar li span:active { - color: var(--LINK-ACTIVE-COLOR); -} - -.NavBar li:focus, -.NavBar li a:focus, -.NavBar li span:focus { - background-color: var(--LINK-FOCUS-BGCOLOR); - color: rgb(253, 254, 254); - outline-offset: 4px; - border-radius: 7px; -} - -.nav-icon { - margin-left: 0.5rem; - margin-right: 1rem; - font-size: 1.2rem; -} - -.ccsLogo { - height: 7.5rem; - margin-bottom: 2rem; - display: block; - margin-left: auto; /* Center horizontally */ - margin-right: auto; /* Center horizontally */ -} - -/* Scrollbar styles */ -.NavBar::-webkit-scrollbar, -body::-webkit-scrollbar { - width: 8px; -} - -.NavBar::-webkit-scrollbar-track, -body::-webkit-scrollbar-track { - background: rgba(255, 255, 255, 0.1); -} - -.NavBar::-webkit-scrollbar-thumb, -body::-webkit-scrollbar-thumb { - background-color: rgb(82, 81, 81); - border-radius: 10px; -} - -.NavBar::-webkit-scrollbar-thumb:hover, -body::-webkit-scrollbar-thumb:hover { - cursor: pointer; -} - -.divider { - font-weight: 600; - pointer-events: none; - color: var(--CONTENT-H2-COLOR); -} - -/* APP-CONTAINER ********************************************************************************/ -.app-container { - display: flex; - flex-grow: 1; - max-width: 160rem; -} - -.content { - flex-grow: 1; - text-align: left; - padding: 2rem 12rem; - margin-top: 2rem; - margin-left: 13rem; - margin-right: 0; - color: var(--CONTENT-COLOR); - overflow-y: auto; -} - -.content h2 { - color: rgb(33, 35, 42); - font-weight: 700; - font-family: 'Roboto', sans-serif; -} - -.content p { - font-family: 'Open Sans', sans-serif; - line-height: 1.8; - margin-bottom: 1rem; -} - -/* Profile ************************************************/ -.profile-container { - display: flex; - justify-content: space-between; /* Space between containers */ - background-color: #282c34; - color: var(--CONTENT-COLOR); - padding: 2rem; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - /* Adjusted width to fit both containers */ - margin: 0 auto; - margin-top: 50px; /* Add margin-top for centering */ - position: relative; /* Ensure it's centered vertically */ -} - -.detail-container { - flex: 1; /* Flex to adjust with the container */ - text-align: center; - padding-right: 1rem; /* Padding to add space between containers */ -} - -.detail-container img { - border-radius: 50%; - width: 150px; - height: 150px; - object-fit: cover; - margin-bottom: 20px; - border: 3px solid var(--CONTENT-H2-COLOR); /* Add border */ - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Add shadow */ -} - -.detail-container h1 { - font-size: 2.5em; /* Increase font size */ - color: white; /* Change name color to white */ - margin-bottom: 10px; -} - -.detail-container p { - font-size: 1.2em; - color: var(--CONTENT-COLOR); - margin: 5px 0; -} - -.detail-container p span { - font-weight: bold; - color: white; /* Ensure high contrast */ -} - -/* Loading and Error Styles */ -.loading, -.error { - display: flex; - justify-content: center; - align-items: center; - height: 100vh; - font-size: 1.5em; - color: rgb(33, 35, 42); -} - -/* Adding responsive design */ -@media (max-width: 768px) { - .profile-container { - padding: 1rem; - } - - .profile-container h1 { - font-size: 1.5em; - } - - .profile-container p { - font-size: 1em; - } -} - -.question-container { - flex: 2; /* Flex to adjust with the container */ -} - -.question-container h2 { - color: white; /* Change heading color to white */ - text-align: center; -} - -.questions-table { - width: 100%; - margin-top: 20px; - border-collapse: collapse; - background-color: var(--NAV-BGCOLOR); /* Add background color for contrast */ -} - -.questions-table th, -.questions-table td { - padding: 12px; - text-align: left; - border-bottom: 1px solid #ddd; -} - -.questions-table th { - background-color: var(--NAV-BGCOLOR); - color: white; -} - -.questions-table tr:hover { - background-color: var(--NAV-COLOR); - color: black; -} - -.questions-table a { - color: rgba(62, 216, 219, 0.866); - text-decoration: none; -} - -.questions-table a:hover { - text-decoration: underline; - color: rgb(57, 185, 255); -} - -/* LEADERBOARD ********************************************/ -.leaderboard-container { - background-color: var(--NAV-BGCOLOR); - border-radius: 0.9375rem; /* 15px in rem */ - padding: 1.25rem; /* 20px in rem */ - margin: 1.25rem; /* 20px in rem */ -} - -.leaderboard-title { - color: var(--CONTENT-H2-COLOR); - text-align: center; -} - -.leaderboard-table { - width: 100%; - border-collapse: collapse; - background-color: var(--NAV-BGCOLOR); - color: var(--CONTENT-COLOR); -} - -.leaderboard-table th, -.leaderboard-table td { - padding: 0.9375rem; /* 15px in rem */ - text-align: left; - border-bottom: 0.0625rem solid #ddd; /* 1px in rem */ -} - -.leaderboard-table th { - background-color: var(--NAV-BGCOLOR); - color: white; -} - -.leaderboard-row { - margin: 0.3125rem; /* 5px in rem */ -} - -.leaderboard-row td { - margin: 0.125rem; /* 2px in rem */ - background-color: var(--NAV-BGCOLOR); -} - -.leaderboard-row img { - border-radius: 50%; - width: 3.125rem; /* 50px in rem */ - height: 3.125rem; /* 50px in rem */ - object-fit: cover; -} - -.leaderboard-row td:last-child { - text-align: right; -} - -/* Responsive Navbar for Smaller Screens */ -@media (max-width: 1024px) { - .NavBar { - width: 100%; - height: 7rem; - position: fixed; - top: 0; - left: 0; - background-color: var(--NAV-BGCOLOR); - padding: 0.5rem; - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-around; - z-index: 1000; /* Ensure it is above other content */ - border-right: none; /* Remove right border */ - border-bottom: var(--NAV-BORDER); /* Add bottom border */ - } - - .NavBar ul { - display: flex; - flex-direction: row; - align-items: right; - width: 70%; - justify-content: space-around; - } - - .NavBar li { - margin: 0; - padding: 0; - } - - .NavBar li a, - .NavBar li span { - padding: 0.5rem; - } - - .nav-icon { - font-size: 1.5rem; /* Increase icon size */ - margin: 0; - } - .ccsLogo{ - margin-top: 2rem; - height: 5rem; - margin-left: 0.5rem; - } - .NavBar > h2, - .NavBar li a span, - .NavBar li span span { - display: none; /* Hide text */ - } - .NavBar .divider{ - display: none; - } - .app-container { - margin-top: 3rem; /* Add top margin to avoid overlap with the navbar */ - margin-left: 0; /* Reset left margin */ - } - - .content { - margin-top: 1rem; - margin-left: 1rem; - margin-right: 1rem; - padding: 1rem; - } -} - -@media (max-width: 768px) { - .profile-container { - flex-direction: column; - align-items: center; - } - - .detail-container { - padding-right: 0; - margin-bottom: 1rem; /* Add space between the containers */ - } - - .question-container { - width: 100%; /* Ensure the question container takes full width */ - } -} diff --git a/client/src/Components/AuthVerify.js b/client/src/Components/AuthVerify.js deleted file mode 100644 index 203b2e5..0000000 --- a/client/src/Components/AuthVerify.js +++ /dev/null @@ -1,68 +0,0 @@ -import React, { useEffect } from 'react'; -import { useNavigate, useLocation } from 'react-router-dom'; - -const AuthVerify = ({ onVerify, setIsNewUser }) => { - const navigate = useNavigate(); - const location = useLocation(); - - useEffect(() => { - const query = new URLSearchParams(location.search); - const jwtToken = query.get('token'); - - if (jwtToken) { - console.log('JWT Token:', jwtToken); - - const requestBody = { - token: jwtToken, - }; - - console.log('Request Body:', requestBody); - - fetch('http://localhost:8000/api/auth/login/', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(requestBody), - }) - .then(response => { - console.log('Response Status:', response.status); - return response.json().then(data => ({ status: response.status, data })); - }) - .then(({ status, data }) => { - console.log('Response Data:', data); - - if (status === 400) { - if (data.leetcode === false) { - setIsNewUser(true); - navigate('/username', { state: { jwtToken } }); // Pass the JWT token as state - } else { - throw new Error('Unexpected error format'); - } - } else if (status === 200) { - if (data && data.token) { - localStorage.setItem('token', data.token); // Save token locally - console.log('Token stored in localStorage:', localStorage.getItem('token')); // Log the stored token - onVerify(); - navigate('/profile'); - } else { - throw new Error('Token not found in response'); - } - } else { - throw new Error(`Unexpected response status: ${status}`); - } - }) - .catch(error => { - console.error('Error checking user:', error); - // Handle error (e.g., show a notification) - navigate('/login'); // Navigate to login page on error - }); - } else { - navigate('/login'); // Navigate to login page if no token found - } - }, [navigate, location, onVerify, setIsNewUser]); - - return
Loading...
; - if (error) returnError loading data: {error.message}
; - - return ( -| Rank | -Username | -- | Questions Solved | -
|---|---|---|---|
| {index + 1} | -{item.username} | -{item.ques_solv} | -
Loading...
; - if (error) returnError loading data: {error.message}
; - - return ( -| Rank | -Username | -- | Questions Solved | -
|---|---|---|---|
| {index + 1} | -{item.username} | -{item.ques_solv} | -
Loading...
; - if (error) returnError loading data: {error.message}
; - - return ( -| Rank | -Username | -- | Questions Solved | -
|---|---|---|---|
| {index + 1} | -{item.username} | -{item.ques_solv} | -
LeetCode Rank: {response.ranking}
+Username: {username}
+| Rank | +Profile | +Username | +Questions Solved | +
|---|---|---|---|
|
+
+ {/* {index === 0 && |
+
+ {!item.photo_url ? (
+ |
+ {item.username} | +{item.ques_solv} | +
| Rank | +Profile | +Username | +Questions Solved | +
|---|---|---|---|
| + {index === 0 && 1} + {index === 1 && 2} + {index === 2 && 3} + {index >= 3 && {index + 1}} + | +
+ {!item.photo_url ? (
+ |
+ {item.username} | +{item.ques_solv} | +
LeetCode Username: {profile.username}
-LeetCode Rank: {profile.leetcode_rank}
-Today's Rank: {profile.daily_rank}
-Weekly Rank: {profile.weekly_rank}
-Monthly Rank: {profile.monthly_rank}
+Username: {profile.username}
+ + {rankPeriod === 'today' &&Today's Rank: {profile.daily_rank}
} + {rankPeriod === 'weekly' &&Weekly Rank: {profile.weekly_rank}
} + {rankPeriod === 'monthly' &&Monthly Rank: {profile.monthly_rank}
} +Please accept the OAuth policy and provide additional information.
+| Rank | +Profile | +Username | +Questions Solved | +
|---|---|---|---|
| + {index === 0 && 1} + {index === 1 && 2} + {index === 2 && 3} + {index >= 3 && {index + 1}} + | +
+ {!item.photo_url ? (
+ |
+ {item.username} | +{item.ques_solv} | +