Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Merriweather:ital@1&family=Montserrat&family=Prompt&family=Sacramento&display=swap" rel="stylesheet">
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PeetCode</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- <link href="https://fonts.googleapis.com/css2?family=Merriweather:ital@1&family=Montserrat&family=Prompt&family=Sacramento&display=swap" rel="stylesheet"> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>

</html>
4 changes: 2 additions & 2 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ font-family: 'Sacramento', cursive;
*/

h1 , h2 , h3 , h4 , h5 , h6 {
font-family: 'Montserrat', sans-serif;
font-family: 'Poppins', sans-serif;
font-weight: 900;
}
p , a {
font-family: 'Prompt', sans-serif
font-family: 'Poppins', sans-serif
}

.flex-row {
Expand Down
4 changes: 2 additions & 2 deletions client/src/Components/AllProblems/AllProblems.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ th {
text-align: start;
padding: 0.5rem 0 0.5rem 0.3rem;
color: black;
font-family: 'Merriweather', serif;
font-family: 'Poppins', serif;
}

td {
font-family: 'Merriweather', serif;
font-family: 'Poppins', serif;
padding: 1rem;
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/Components/AllProblems/AllProblems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const AllProblemsPage = () => {
}, []);

return (
<div id="allproblems">
<div id="allproblems" className='py-9 md:px-8 pl-4'>
<table>
<tbody>

Expand All @@ -32,7 +32,7 @@ const AllProblemsPage = () => {
</tr>

{problems.map((prob,index) => (
<tr>
<tr className='hover:bg-stone-100 hover:drop-shadow-md'>
<Link to={`/problems/:${prob.problemId}`}>
<td>{prob.title}</td>
</Link>
Expand Down
3 changes: 3 additions & 0 deletions client/src/Components/HomePage/HomePage.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@

.content {
margin: 5px 0;
}
#home{
padding-top: 3rem;
}
6 changes: 3 additions & 3 deletions client/src/Components/HomePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import loremContent from './LoremPosts'

const HomePage = () => {
return (
<div id="home">
<h1 className='flex-row'>Blogs</h1>
<div id="home" className='md:px-5 px-2'>
<h1 className='flex-row pb-5 text-3xl'>Blogs</h1>
{loremContent.map((content,index) => (
<div key={`blog-${index}`} className="blog-box">
<div key={`blog-${index}`} className="blog-box hover:bg-slate-100 hover:drop-shadow-md ">
<p className="date">{content.date}</p>
<h4 className='title'>{content.title}</h4>
<p className="content">{content.content}</p>
Expand Down
4 changes: 2 additions & 2 deletions client/src/Components/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const Login = () => {

return (
<div id="login" className='flex-col'>
<h1>Login</h1>
<div className='signup-form'>
<h1 className='text-3xl'>Login</h1>
<div className='signup-form mt-4'>
<div className='subform'>
<label htmlFor="email">Email: </label>
<input onChange={(e) => {
Expand Down
14 changes: 12 additions & 2 deletions client/src/Components/ProblemsPage/ProblemsPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
min-height: 91vh;
display: flex;
align-items: flex-start;
/* flex-direction: column; */
}

@media screen and (max-width: 640px) {
#problempage{
flex-direction: column;
}

}



.ques , .code {
width: 50%;
min-height: 65vh;
width: 100%;
/* min-height: 65vh; */
margin: 0;
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion client/src/Components/ProblemsPage/ProblemsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ProblemsPage = () => {
</div>
<div className="code">
<h1>Code Here</h1>
<div className='code-form'>
<div className='code-form border-2 rounded border-stone-700'>
<textarea onChange={(e) => setSubmission(e.target.value)} name="SolvedCode" onKeyDown={ (event) => handleKey(event) }></textarea>
<button type="submit" id="submit" onClick={async () => {
const response = await fetch(`${backendUrl}/submission`, {
Expand Down
4 changes: 2 additions & 2 deletions client/src/Components/Signup/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const Signup = () => {

return (
<div id='signup' className='flex-col'>
<h1>Signup</h1>
<div className='signup-form'>
<h1 className="text-3xl">Signup</h1>
<div className='signup-form mt-4'>
<div className='subform'>
<label htmlFor='email'>Email: </label>
<input
Expand Down
52 changes: 50 additions & 2 deletions client/src/Constants/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react'
import { Link } from 'react-router-dom'

import './Navbar.css'
// import './Navbar.css'

const Navbar = () => {
// old navbar
const Navbar1 = () => {
return (
<div id='navbar-main' className='flex-row'>
<Link to={'/'}>

<div className="logo-box flex-row">
<img className='logo' src="https://user-images.githubusercontent.com/63964149/152531278-5e01909d-0c2e-412a-8acc-4a06863c244d.png" alt="logo" />
<p>PeetCode</p>

</div>
</Link>
<div className="nav-options">
Expand All @@ -25,4 +28,49 @@ const Navbar = () => {
)
}


// new nav bar
const Navbar = () => {
return (

<div className="bg-neutral-700 flex md:p-4 p-3 md:text-xl text-sm
shadow-lg
text-stone-300

">

<div className="items-center w-full flex">
<Link to={'/'}>
<div className="text-white cursor-pointer md:text-3xl text-md md:pr-4
flex items-center
">
<div className="md:px-2 pr-1"><img src="https://user-images.githubusercontent.com/63964149/152531278-5e01909d-0c2e-412a-8acc-4a06863c244d.png" className="md:w-10 w-5"></img></div>
<div>
PeetCode
</div>
</div>
</Link>
<div className="md:px-4 pl-3 hover:text-white cursor-pointer h-full items-center flex" > <Link to={'/problemset/all/'} >Problems</Link></div>


</div>

<div className="items-center
hover:text-white
cursor-pointer md:px-4 px-1 flex">
<Link to={'/signup'} >Signup</Link>
</div>
<div className="items-center
hover:text-white
cursor-pointer md:px-4 px-1 flex">
<Link to={'/login'} >Login</Link>
</div>

</div>

)
}


export default Navbar

43 changes: 43 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

const express = require("express");
const app = express();
const port = 3000;
var jwt = require("jsonwebtoken");

const { auth } = require("./middleware");
let USER_ID_COUNTER = 1;
const USERS = [];
Expand Down Expand Up @@ -143,6 +145,46 @@ app.get("/submissions/:problemId", auth, (req, res) => {
});

app.post("/submission", auth, (req, res) => {

const isCorrect = Math.random() < 0.5;
const problemId = req.body.problemId;
const submission = req.body.submission;

if (isCorrect) {
SUBMISSIONS.push({
submission,
problemId,
userId: req.userId,
status: "AC"
})
return res.json({
status: "AC"
})
} else {

SUBMISSIONS.push({
submission,
problemId,
userId: req.userId,
status: "WA"
})
return res.json({
status: "WA"
})
}
})

app.post("/signup", (req, res) => {
console.log(req.body)
const email = req.body.email;
const password = req.body.password;
if (USERS.find(x => x.email === email)) {
return res.status(403).json({msg: "Email already exists"});
}

USERS.push({
email, password, id: USER_ID_COUNTER++
})
const isCorrect = Math.random() < 0.5;
const problemId = req.body.problemId;
const submission = req.body.submission;
Expand All @@ -163,6 +205,7 @@ app.post("/submission", auth, (req, res) => {
problemId,
userId: req.userId,
status: "WA",

});
return res.json({
status: "WA",
Expand Down