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
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/peetcode.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/src/Components/AllProblems/AllProblems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AllProblemsPage = () => {
</tr>

{problems.map((prob,index) => (
<tr>
<tr key={prob.problemId}>
<Link to={`/problems/:${prob.problemId}`}>
<td>{prob.title}</td>
</Link>
Expand Down
3 changes: 3 additions & 0 deletions client/src/Components/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const Login = () => {
<button type="submit" id="test" onClick={async (e) => {
const response = await fetch(`${backendUrl}/login`, {
method: "POST",
headers:{
"Content-Type":"application/json"
},
body: JSON.stringify({
email: email,
password: password
Expand Down
20 changes: 20 additions & 0 deletions client/src/Components/ProblemsPage/ProblemsPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,24 @@ button {
}
#submit {
background-color: rgb(68, 207, 68);
}

#sub-content{
padding: 1vh;
border : 1px solid black;
border-radius: 0.3vw;
height: 39vh;
width: 100%;
overflow-y: scroll;
}
#internal{
margin : 1%;
}
.AC {
color: green;
font-weight: 900;
}
.WA {
color: red;
font-weight: 900;
}
41 changes: 37 additions & 4 deletions client/src/Components/ProblemsPage/ProblemsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,35 @@ const ProblemsPage = () => {
const cleanId = pid.substring(1) ;
const [problem, setProblem] = useState(null);
const [submission, setSubmission] = useState("");
const [submissions,setSubmissions]= useState([]);

const handlesubmissions = async ()=>{
const response = await fetch(`${backendUrl}/submissions/`+cleanId,{
method:"GET",
headers: {
"authorization": localStorage.getItem("token"),
},
})
const json = await response.json();
// let ans = [];
const ans = json.submissions.filter((x)=> {
console.log(x.status)
})
setSubmissions(json.submissions);
}
const init = async () => {
const response = await fetch(`${backendUrl}/problem/` + cleanId, {
method: "GET",
});

const json = await response.json();
setProblem(json.problem);

}

useEffect(() => {
init();
handlesubmissions();
}, [])
// console.log(cleanId) ;

Expand All @@ -39,8 +56,8 @@ const ProblemsPage = () => {
}

return (
<>
<div>

{
problem? (
<div id="problempage" className='flex-row'>
Expand All @@ -50,6 +67,21 @@ const ProblemsPage = () => {
<p>{problem.description}</p>
<code>Input : {problem.exampleIn}</code>
<code>Output : {problem.exampleOut}</code>
<div id="submissions">
<h3>Submissions</h3>
<div id="sub-content">
{
submissions.map((x,index)=>{
return(
<div id="internal" key ={index} >
<div >Submission: {index}</div>

<div className={x.status} >Status: {x.status}</div></div>
)
})
}
</div>
</div>
</div>
<div className="code">
<h1>Code Here</h1>
Expand All @@ -59,7 +91,8 @@ const ProblemsPage = () => {
const response = await fetch(`${backendUrl}/submission`, {
method: "POST",
headers: {
"authorization": localStorage.getItem("token")
"authorization": localStorage.getItem("token"),
"Content-Type":"application/json"
},
body: JSON.stringify({
problemId: cleanId,
Expand All @@ -69,7 +102,7 @@ const ProblemsPage = () => {

const json = await response.json();
console.log(json);

handlesubmissions();
}}>SubmitCode</button>
</div>
</div>
Expand All @@ -79,7 +112,7 @@ const ProblemsPage = () => {
}

</div>

</>
)
}

Expand Down
3 changes: 3 additions & 0 deletions client/src/Components/Signup/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const Signup = () => {
onClick={async (e) => {
const response = await fetch(`${backendUrl}/signup`, {
method: "POST",
headers:{
'Content-Type':'application/json'
},
body: JSON.stringify({
email: email,
password: password,
Expand Down
4 changes: 3 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const bodyParser = require("body-parser");
var jsonParser = bodyParser.json();
var urlencodedParser = bodyParser.urlencoded({ extended: false });
const cors = require("cors");
app.use(cors());
app.use(cors(
{origin: "*"}
));
app.use(jsonParser);

const PROBLEMS = [
Expand Down