From 2d4a29093705f1fcee825718f6950881d5cfeae5 Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Sun, 31 Mar 2024 21:20:27 +0530
Subject: [PATCH 1/7] initial commit
---
package-lock.json | 63 ++++++++++++++++++++++++++++++++++++-
package.json | 3 +-
src/App.jsx | 79 ++++++++++++++++++++++++++++++++++-------------
3 files changed, 122 insertions(+), 23 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index cd606935..ba6ce06b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,8 @@
"version": "0.0.0",
"dependencies": {
"react": "^18.2.0",
- "react-dom": "^18.2.0"
+ "react-dom": "^18.2.0",
+ "react-router-dom": "^6.22.3"
},
"devDependencies": {
"@types/react": "^18.0.28",
@@ -766,6 +767,14 @@
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
"dev": true
},
+ "node_modules/@remix-run/router": {
+ "version": "1.15.3",
+ "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.15.3.tgz",
+ "integrity": "sha512-Oy8rmScVrVxWZVOpEF57ovlnhpZ8CCPlnIIumVcV9nFdiSIrus99+Lw78ekXyGvVDlIsFJbSfmSovJUhCWYV3w==",
+ "engines": {
+ "node": ">=14.0.0"
+ }
+ },
"node_modules/@types/prop-types": {
"version": "15.7.5",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
@@ -1226,6 +1235,36 @@
"node": ">=0.10.0"
}
},
+ "node_modules/react-router": {
+ "version": "6.22.3",
+ "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.22.3.tgz",
+ "integrity": "sha512-dr2eb3Mj5zK2YISHK++foM9w4eBnO23eKnZEDs7c880P6oKbrjz/Svg9+nxqtHQK+oMW4OtjZca0RqPglXxguQ==",
+ "dependencies": {
+ "@remix-run/router": "1.15.3"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8"
+ }
+ },
+ "node_modules/react-router-dom": {
+ "version": "6.22.3",
+ "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.22.3.tgz",
+ "integrity": "sha512-7ZILI7HjcE+p31oQvwbokjk6OA/bnFxrhJ19n82Ex9Ph8fNAq+Hm/7KchpMGlTgWhUxRHMMCut+vEtNpWpowKw==",
+ "dependencies": {
+ "@remix-run/router": "1.15.3",
+ "react-router": "6.22.3"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8",
+ "react-dom": ">=16.8"
+ }
+ },
"node_modules/resolve": {
"version": "1.22.2",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz",
@@ -1853,6 +1892,11 @@
}
}
},
+ "@remix-run/router": {
+ "version": "1.15.3",
+ "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.15.3.tgz",
+ "integrity": "sha512-Oy8rmScVrVxWZVOpEF57ovlnhpZ8CCPlnIIumVcV9nFdiSIrus99+Lw78ekXyGvVDlIsFJbSfmSovJUhCWYV3w=="
+ },
"@types/prop-types": {
"version": "15.7.5",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
@@ -2176,6 +2220,23 @@
"integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==",
"dev": true
},
+ "react-router": {
+ "version": "6.22.3",
+ "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.22.3.tgz",
+ "integrity": "sha512-dr2eb3Mj5zK2YISHK++foM9w4eBnO23eKnZEDs7c880P6oKbrjz/Svg9+nxqtHQK+oMW4OtjZca0RqPglXxguQ==",
+ "requires": {
+ "@remix-run/router": "1.15.3"
+ }
+ },
+ "react-router-dom": {
+ "version": "6.22.3",
+ "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.22.3.tgz",
+ "integrity": "sha512-7ZILI7HjcE+p31oQvwbokjk6OA/bnFxrhJ19n82Ex9Ph8fNAq+Hm/7KchpMGlTgWhUxRHMMCut+vEtNpWpowKw==",
+ "requires": {
+ "@remix-run/router": "1.15.3",
+ "react-router": "6.22.3"
+ }
+ },
"resolve": {
"version": "1.22.2",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz",
diff --git a/package.json b/package.json
index 154dd4dd..97373c41 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,8 @@
},
"dependencies": {
"react": "^18.2.0",
- "react-dom": "^18.2.0"
+ "react-dom": "^18.2.0",
+ "react-router-dom": "^6.22.3"
},
"devDependencies": {
"@types/react": "^18.0.28",
diff --git a/src/App.jsx b/src/App.jsx
index 7743965b..519f8298 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,3 +1,5 @@
+import { BrowserRouter, Routes, Route } from "react-router-dom";
+
/*
* Temporary problems array schema
*/
@@ -5,39 +7,74 @@ const problems = [{
title: "201. Bitwise AND of Numbers Range",
difficulty: "Medium",
acceptance: "42%"
-},{
+}, {
title: "201. Bitwise AND of Numbers Range",
difficulty: "Medium",
acceptance: "412%"
},
- {
- title: "202. Happy Number",
- difficulty: "Easy",
- acceptance: "54.9%"
- },
- {
- title: "203. Remove Linked List Elements",
- difficulty: "Hard",
- acceptance: "42%"
- }];
+{
+ title: "202. Happy Number",
+ difficulty: "Easy",
+ acceptance: "54.9%"
+},
+{
+ title: "203. Remove Linked List Elements",
+ difficulty: "Hard",
+ acceptance: "42%"
+}];
function App() {
+ return (
+
+ /* Add routing here, routes look like -
+ /login - Login page
+ /signup - Signup page
+ /problemset/all/ - All problems (see problems array above)
+ /problems/:problem_slug - A single problem page
+ */
+
+ // return (
+ //
+ // Finish the assignment! Look at the comments in App.jsx as a starting point
+ //
+ // )
+
+
+
+
+
+
+
+ )
+}
+
+//home component
+function Home() {
+ return (
+ <>
+ Home
+
+
+ >
+ );
+};
- /* Add routing here, routes look like -
- /login - Login page
- /signup - Signup page
- /problemset/all/ - All problems (see problems array above)
- /problems/:problem_slug - A single problem page
- */
+//login component
+function Login() {
+ return (
+ Login
+ )
+}
+//signup component
+function Signup() {
return (
-
- Finish the assignment! Look at the comments in App.jsx as a starting point
-
- )
+ Signup
+ )
}
+
// A demo component
function ProblemStatement(props) {
const title = props.title;
From f38cacf3e4d948dcbcf5988c903b778f40e3d1a9 Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Mon, 1 Apr 2024 21:53:30 +0530
Subject: [PATCH 2/7] updated added all routes
---
src/App.jsx | 79 +++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 68 insertions(+), 11 deletions(-)
diff --git a/src/App.jsx b/src/App.jsx
index 519f8298..9d33a082 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,24 +1,28 @@
-import { BrowserRouter, Routes, Route } from "react-router-dom";
+import { BrowserRouter, Routes, Route, useParams } from "react-router-dom";
/*
* Temporary problems array schema
*/
const problems = [{
- title: "201. Bitwise AND of Numbers Range",
+ index: "201",
+ title: "Bitwise AND of Numbers Range",
difficulty: "Medium",
acceptance: "42%"
}, {
- title: "201. Bitwise AND of Numbers Range",
+ index: "202",
+ title: "Palindrome",
difficulty: "Medium",
- acceptance: "412%"
+ acceptance: "41%"
},
{
- title: "202. Happy Number",
+ index: "203",
+ title: "Happy Number",
difficulty: "Easy",
acceptance: "54.9%"
},
{
- title: "203. Remove Linked List Elements",
+ index: "204",
+ title: "Remove Linked List Elements",
difficulty: "Hard",
acceptance: "42%"
}];
@@ -44,6 +48,8 @@ function App() {
+
+
)
@@ -55,25 +61,76 @@ function Home() {
<>
Home
-
+
>
- );
-};
+ )
+}
//login component
function Login() {
return (
- Login
+ <>
+ Login
+
+ >
)
}
//signup component
function Signup() {
return (
- Signup
+ <>
+ Signup
+
+ >
)
}
+//all problem set
+function AllProblem() {
+ return (
+
+ {problems.map(problem => (
+
+ ))}
+
+ )
+}
+
+//slug component
+function SingleProblem() {
+ let { index } = useParams();
+ let problem_statement = problems.find(problem => (problem.index == index));
+ if (problem_statement) {
+ return (
+
+ )
+ }
+ else {
+ return (
+ NOT VALID INDEX
+ )
+ }
+}
// A demo component
function ProblemStatement(props) {
From 5b65c3e1bf36becdeab31ece87bda616e8988b5a Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Mon, 1 Apr 2024 22:13:58 +0530
Subject: [PATCH 3/7] modified components to have diff views for diff pages
---
src/App.jsx | 56 +++++++++++++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/src/App.jsx b/src/App.jsx
index 9d33a082..7a524620 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -49,7 +49,7 @@ function App() {
-
+
)
@@ -103,7 +103,7 @@ function AllProblem() {
return (
{problems.map(problem => (
-
))}
@@ -112,17 +112,15 @@ function AllProblem() {
}
//slug component
-function SingleProblem() {
+function ProblemPage() {
let { index } = useParams();
let problem_statement = problems.find(problem => (problem.index == index));
if (problem_statement) {
return (
-
+
)
}
else {
@@ -134,20 +132,36 @@ function SingleProblem() {
// A demo component
function ProblemStatement(props) {
+ const page = props.page;
+ const index = props.index;
const title = props.title;
const acceptance = props.acceptance;
const difficulty = props.difficulty;
-
- return
-
- {title}
- |
-
- {acceptance}
- |
-
- {difficulty}
- |
-
+ if (page == "all") {
+ return
+
+ {index}
+ |
+
+ {title}
+ |
+
+ {acceptance}
+ |
+
+ {difficulty}
+ |
+
+ } else {
+ return (
+
+
{index} : {title}
+
+ - Acceptance : {acceptance}
+ - Difficulty : {difficulty}
+
+
+ )
+ }
}
export default App
From 1ff052a0c0ec0487a61550f683ce49a3a418f76d Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Tue, 2 Apr 2024 13:00:52 +0530
Subject: [PATCH 4/7] added Hooks
---
src/App.jsx | 57 +++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 13 deletions(-)
diff --git a/src/App.jsx b/src/App.jsx
index 7a524620..71a2763d 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,9 +1,10 @@
+import { useEffect, useState } from "react";
import { BrowserRouter, Routes, Route, useParams } from "react-router-dom";
/*
* Temporary problems array schema
*/
-const problems = [{
+const problems1 = [{
index: "201",
title: "Bitwise AND of Numbers Range",
difficulty: "Medium",
@@ -26,7 +27,29 @@ const problems = [{
difficulty: "Hard",
acceptance: "42%"
}];
-
+const problems2 = [{
+ index: "205",
+ title: "Numbers Range",
+ difficulty: "Medium",
+ acceptance: "42%"
+}, {
+ index: "206",
+ title: "Reverse Array",
+ difficulty: "Easy",
+ acceptance: "41%"
+},
+{
+ index: "207",
+ title: "Sad Number",
+ difficulty: "Easy",
+ acceptance: "54.9%"
+},
+{
+ index: "208",
+ title: "Remove Duplicate Elements",
+ difficulty: "Easy",
+ acceptance: "42%"
+}];
function App() {
return (
@@ -48,7 +71,7 @@ function App() {
-
+
@@ -99,22 +122,30 @@ function Signup() {
}
//all problem set
-function AllProblem() {
+function AllProblems() {
+ const [page, setPage] = useState([])
+
return (
-
- {problems.map(problem => (
-
- ))}
-
+ <>
+
+ {page.map(problem => (
+
+ ))}
+
+
+
+ >
)
}
//slug component
function ProblemPage() {
+ const [problemSlug, setProblemSlug] = useState("")
let { index } = useParams();
- let problem_statement = problems.find(problem => (problem.index == index));
+ useEffect(() => setProblemSlug(problemSlug => index), [])
+ let problem_statement = problems1.find(problem => (problem.index == problemSlug));
if (problem_statement) {
return (
} else {
return (
-
+
{index} : {title}
- Acceptance : {acceptance}
From cd06239e8a6f3f397c8851e289e8b49a18a4cbfd Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Tue, 2 Apr 2024 21:21:49 +0530
Subject: [PATCH 5/7] updated code editor
---
src/App.jsx | 157 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 118 insertions(+), 39 deletions(-)
diff --git a/src/App.jsx b/src/App.jsx
index 71a2763d..98331474 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -6,7 +6,7 @@ import { BrowserRouter, Routes, Route, useParams } from "react-router-dom";
*/
const problems1 = [{
index: "201",
- title: "Bitwise AND of Numbers Range",
+ title: "Bitwise And of Numbers Range",
difficulty: "Medium",
acceptance: "42%"
}, {
@@ -51,6 +51,37 @@ const problems2 = [{
acceptance: "42%"
}];
+const problemDetail = [
+ {
+ index: "201",
+ title: "Bitwise AND of Numbers Range",
+ description: "asdhfsdfjksdhfjshdf",
+ input: "5,2,3",
+ output: "5,2,2"
+ }, {
+ index: "202",
+ title: "Palindrome",
+ description: "check if the given string is palindrome",
+ input: "ababa",
+ output: "True"
+ }
+]
+
+const defaultCode = {
+ "java": `class Solution {
+ public int[] twoSum(int[] nums, int target) {
+
+ }
+ }`,
+ "python": `class Solution(object):
+ def twoSum(self, nums, target):
+ """
+ :type nums: List[int]
+ :type target: int
+ :rtype: List[int]
+ """
+ `
+}
function App() {
return (
@@ -72,7 +103,7 @@ function App() {
-
+
)
@@ -123,16 +154,26 @@ function Signup() {
//all problem set
function AllProblems() {
- const [page, setPage] = useState([])
+ const [page, setPage] = useState(problems1)
return (
<>
- {page.map(problem => (
-
- ))}
+
+
+ Index |
+ Title |
+ Acceptance |
+ Difficulty |
+
+
+
+ {page.map(problem => (
+
+ ))}
+
@@ -141,17 +182,19 @@ function AllProblems() {
}
//slug component
-function ProblemPage() {
+function SingleProblem() {
const [problemSlug, setProblemSlug] = useState("")
let { index } = useParams();
useEffect(() => setProblemSlug(problemSlug => index), [])
- let problem_statement = problems1.find(problem => (problem.index == problemSlug));
- if (problem_statement) {
+ let problem_details = problemDetail.find(problem => (problem.index == problemSlug));
+ if (problem_details) {
return (
-
+
)
}
else {
@@ -161,38 +204,74 @@ function ProblemPage() {
}
}
-// A demo component
+//seperate page for a problem
+function ProblemPage(props) {
+ const index = props.index;
+ const title = props.title;
+ const description = props.description;
+ const input = props.input;
+ const output = props.output;
+
+ const [language, setLanguage] = useState("");
+ console.log("curr-val", language);
+ const handleChange = (e) => {
+ console.log("selected-value", e.target.value);
+ setLanguage(e.target.value);
+ console.log("changed-val", language);
+ }
+
+ // const onCodeTyping = e => {
+ // console.log(e.target.value);
+ // defaultCode[language] = e.target.value;
+ // }
+
+
+
+ return (
+
+
{index} : {title}
+
{description}
+
{input}
+ {/* {console.log("outside testing: ", "hii")} */}
+
{output}
+
+
+
+
+ )
+}
+
+
+// A demo component(summary component)
function ProblemStatement(props) {
const page = props.page;
const index = props.index;
const title = props.title;
const acceptance = props.acceptance;
const difficulty = props.difficulty;
- if (page == "all") {
- return
-
- {index}
- |
-
- {title}
- |
-
- {acceptance}
- |
+ console.log(index)
+
+ return (
+
+ {index} |
- {difficulty}
+
+ {title}
+
|
+ {acceptance} |
+ {difficulty} |
- } else {
- return (
-
-
{index} : {title}
-
- - Acceptance : {acceptance}
- - Difficulty : {difficulty}
-
-
- )
- }
+ );
}
export default App
From 2f3c56e57e60f9034a6ecee46a960512dc7a23dd Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Tue, 2 Apr 2024 22:38:32 +0530
Subject: [PATCH 6/7] updated event handlers
---
src/App.jsx | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/App.jsx b/src/App.jsx
index 98331474..96438b06 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -206,44 +206,47 @@ function SingleProblem() {
//seperate page for a problem
function ProblemPage(props) {
+
const index = props.index;
const title = props.title;
const description = props.description;
const input = props.input;
const output = props.output;
- const [language, setLanguage] = useState("");
- console.log("curr-val", language);
- const handleChange = (e) => {
+ // const [language, setLanguage] = useState("java");
+ // console.log("curr-val", language);
+
+ const handleLanguageChange = (e) => {
console.log("selected-value", e.target.value);
- setLanguage(e.target.value);
- console.log("changed-val", language);
+ setCodeChange(defaultCode[e.target.value]);
}
- // const onCodeTyping = e => {
- // console.log(e.target.value);
- // defaultCode[language] = e.target.value;
- // }
-
+ const [code, setCodeChange] = useState(defaultCode["java"]);
+ const handleCodeChange = e => {
+ // console.log(e.target.value);
+ setCodeChange(e.target.value);
+ }
+ const handleSubmit = (e) => {
+ e.preventDefault();
+ console.log("submmited code", e.target.elements.code.value);
+ }
return (
{index} : {title}
{description}
{input}
- {/* {console.log("outside testing: ", "hii")} */}
{output}
-
From 0b079233f84c198ac7f65ed6e82e95a3e588a93f Mon Sep 17 00:00:00 2001
From: ramprasanth0 <88130479+ramprasanth0@users.noreply.github.com>
Date: Wed, 3 Apr 2024 13:58:08 +0530
Subject: [PATCH 7/7] added custom css to all pages
---
README.md | 5 --
index.html | 25 ++++----
src/App.css | 42 -------------
src/App.jsx | 134 ++++++++++++++++++++++++++----------------
src/assets/custom.css | 127 +++++++++++++++++++++++++++++++++++++++
5 files changed, 223 insertions(+), 110 deletions(-)
create mode 100644 src/assets/custom.css
diff --git a/README.md b/README.md
index 83f3a207..ca60280a 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,3 @@
## Full stack assignment
-### Video
-Link to video - https://www.youtube.com/watch?v=569YZm0X5-0
-
-### Where to start?
-Look at App.jsx inside the src/ folder
diff --git a/index.html b/index.html
index 79c47019..163197ca 100644
--- a/index.html
+++ b/index.html
@@ -1,13 +1,16 @@
-
-
-
-
-
Vite + React
-
-
-
-
-
-
+
+
+
+
+
+
Vite + React
+
+
+
+
+
+
+
+