-
-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
london-10-shadi-fakhri-full-stack-project #375
Changes from 19 commits
8d1b941
cca8a08
bc7504e
6507e92
3cd878e
ece4b32
4a7747c
7cd143a
6ad81bf
99cadd1
38d9074
c6885a2
020b78a
a06dfa5
9276c41
1f2ee20
278cf42
15a019a
e2f89a7
81cd4c6
f832b4e
96cd636
541a8ab
828d24e
b1fc225
f591e33
eb7d1d5
fd9057b
6e1a73b
8f2d6e1
2ccc8e1
4cb01cf
464c5d1
cc478c4
6fce3a3
5626978
23081c9
003b2e0
5cae357
ce620e7
15ee3a8
0e68f45
659af4a
0090b3e
8d4f192
9807a58
4503776
113d492
cc922f3
dab25af
320fbbf
29aa960
394af84
61d674c
68823dd
3d9076d
668f76b
22436ab
173cad3
5cc14c2
f79c327
c9a411c
a575aa1
0094db8
c66197a
031210e
9da4a65
cd7ef29
4978c46
7b6a5d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"git.ignoreLimitWarning": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,132 @@ | ||
.App { | ||
text-align: center; | ||
width: 100%; | ||
height: 100vh; | ||
background-color: #55BCC9; | ||
} | ||
|
||
.nav{ | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
background-color: #97CAEF; | ||
height: 40px; | ||
margin-top: 10px; | ||
} | ||
.orderBtn{ | ||
display: flex; | ||
background-color: transparent; | ||
margin: 5px; | ||
font-weight: bold; | ||
|
||
} | ||
.orderBtn p{ | ||
background-color: transparent; | ||
color: #FC4445; | ||
} | ||
.orderBtn button{ | ||
background-color: transparent; | ||
border-radius: 5px; | ||
border-style: none; | ||
color:black; | ||
height: 20px; | ||
text-align: center; | ||
font-weight: bold; | ||
} | ||
.orderBtn button:active { | ||
color: aliceblue; | ||
} | ||
.main{ | ||
width: 800px; | ||
} | ||
div{ | ||
background-color: #55BCC9; | ||
} | ||
p{ | ||
background-color: #55BCC9; | ||
color: black; | ||
} | ||
button{ | ||
background-color: #FC4445; | ||
border-radius: 5px; | ||
border-style: none; | ||
color:aliceblue ; | ||
} | ||
iframe{ | ||
border-radius: 5px; | ||
height: 100%; | ||
} | ||
|
||
.formDiv { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100vh; | ||
height: 30vh; | ||
} | ||
|
||
|
||
.input-group { | ||
display: flex; | ||
justify-content: center; | ||
margin: 10px; | ||
background-color: #3FEEE6; | ||
} | ||
|
||
#url.lineInput{ | ||
margin-left: 10px; | ||
background-color:#3FEEE6; | ||
border: none; | ||
border-bottom: 1px solid #FC4445; | ||
outline: none; | ||
padding: 5px; | ||
} | ||
#title.lineInput{ | ||
margin-left: 10px; | ||
background-color:#3FEEE6 ; | ||
border: none; | ||
border-bottom: 1px solid #FC4445; | ||
outline: none; | ||
padding: 5px; | ||
|
||
} | ||
|
||
.input-group label { | ||
margin-bottom: 5px; | ||
color: #FC4445; | ||
font-weight: bold ; | ||
|
||
} | ||
.addCancelBtn{ | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
.addCancelBtn button{ | ||
margin: 20px; | ||
} | ||
.showVideo{ | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-left: 10px; | ||
margin-right: 10px; | ||
} | ||
.btnShowVideo{ | ||
margin: 10px; | ||
border-radius: 5px; | ||
} | ||
.mainShowVideos{ | ||
display: grid; | ||
width: 100 vh; | ||
grid-template-columns: repeat(3,1fr); | ||
grid-template-rows: auto; | ||
gap: 20px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.thumbBtn{ | ||
background-color: transparent; | ||
border: none; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,92 @@ | ||
import React, {useState } from "react"; | ||
import { BrowserRouter as Router, Route, Routes, Link } from "react-router-dom"; | ||
|
||
import "./App.css"; | ||
import Videos from "./Videos.js"; | ||
|
||
function App() { | ||
|
||
const [showVideos, setShowVideos] = useState(false); | ||
const [loadData, setLoadData] = useState([]); | ||
|
||
async function aseClickHandler(e) { | ||
e.preventDefault(); | ||
try { | ||
const response = await fetch( | ||
"https://web-server-5nme.onrender.com/videos" | ||
); | ||
if (!response.ok) { | ||
throw new Error("something went wrong"); | ||
} | ||
const data = await response.json(); | ||
//asending acording to the rating | ||
data.sort((a, b) => a.rating - b.rating); | ||
return setLoadData(data); | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
} | ||
} | ||
|
||
async function descClickHandler(e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code looks a lot like the code in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right I fixed it. |
||
e.preventDefault(); | ||
try { | ||
const response = await fetch("https://web-server-5nme.onrender.com/videos"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once you've loaded the data once, you probably don't actually need to load it again just to change the sort order - can you make this re-sort without fetching again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I deleted fetch from the function. |
||
if (!response.ok) { | ||
throw new Error("something went wrong"); | ||
} | ||
const data = await response.json(); | ||
//asending acording to the rating | ||
data.sort((a, b) => b.rating - a.rating); | ||
return setLoadData(data); | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
} | ||
} | ||
|
||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<h1>Video Recommendation</h1> | ||
</header> | ||
</div> | ||
<Router> | ||
<div className="App"> | ||
<header className="appHeader"> | ||
<h1 style={{ background: "#97CAEF", color: "black" }}> | ||
Video Recommendation | ||
</h1> | ||
</header> | ||
<nav className="nav"> | ||
<div className="orderBtn"> | ||
<p>order by rate : </p> | ||
<button onClick={aseClickHandler}>ase</button> | ||
<button onClick={descClickHandler}>desc</button> | ||
</div> | ||
<div style={{ backgroundColor: "#55BCC9" }}></div> | ||
<Link | ||
to="/videos" | ||
style={{ | ||
color: "#FC4445", | ||
marginLeft: 20, | ||
textDecoration: "none", | ||
fontWeight: "bold", | ||
}} | ||
onClick={() => setShowVideos(true)} | ||
> | ||
Videos | ||
</Link> | ||
</nav> | ||
<Routes> | ||
{" "} | ||
<Route | ||
path="/videos" | ||
element={ | ||
<Videos | ||
show={showVideos} | ||
setShow={setShowVideos} | ||
loadData={loadData} | ||
setLoadData={setLoadData} | ||
/> | ||
} | ||
/> | ||
</Routes> | ||
</div> | ||
</Router> | ||
); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more clear name than
loadData
you can think of for this state that describes what data is stored in this array?Generally all apps deal with "data", so being specific can make things a lot more clear :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Daniel
thanks for your pieces of advice. I will try to do all of them.
here i changed loadData to loadVideo.