-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0885709
commit c7c41bb
Showing
10 changed files
with
155 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.link{ | ||
text-decoration: none; | ||
color: aliceblue; | ||
} | ||
.link:hover{ | ||
color: aliceblue; | ||
|
||
} | ||
.table{ | ||
margin-left: auto; | ||
margin-right: auto; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,81 @@ | ||
import React,{useEffect} from "react"; | ||
import React, { useContext, useEffect, useState } from "react"; | ||
import Header from "./Header"; | ||
import { Button, Col, Table } from "react-bootstrap"; | ||
import { useHistory } from "react-router-dom"; | ||
import { Link, useHistory } from "react-router-dom"; | ||
import axios from "axios"; | ||
import UserContext from "../context/userContext"; | ||
import "./Favourite.css"; | ||
|
||
export default function Favourite() { | ||
// const history = useHistory(); | ||
// const callHomePage = async () => { | ||
|
||
// try { | ||
// const res = await axios.get("/favourite"); | ||
// console.log(res) | ||
// const data = await res.json(); | ||
// console.log(data); | ||
// } catch (e) { | ||
// history.push("/login"); | ||
// console.log(e) | ||
// } | ||
// }; | ||
// useEffect(() => { | ||
// callHomePage(); | ||
const currentUser = useContext(UserContext); | ||
const { favourite } = currentUser; | ||
const [cart, setCart] = useState([]); | ||
const [movie, setMovie] = useState(""); | ||
const history = useHistory(); | ||
const callHomePage = async () => { | ||
// try { | ||
const res = await axios.get("/favourite"); | ||
setCart(res.data); | ||
console.log(res); | ||
// const data = await res.json(); | ||
console.log(res.data); | ||
// } | ||
// catch (e) { | ||
// history.push("/login"); | ||
// console.log(e); | ||
// } | ||
}; | ||
|
||
async function removeFav(id) { | ||
await axios.post("/favourite/remove", id); | ||
await axios.get("/favourite"); | ||
// res.send() | ||
} | ||
useEffect(() => { | ||
callHomePage(); | ||
}, []); | ||
|
||
// // axios.post('/favourite') | ||
// }, []); | ||
return ( | ||
<div> | ||
<Header /> | ||
<Header favouriteLen={favourite.length} /> | ||
<h1>Favoourite Page</h1> | ||
<Table striped bordered hover variant="dark" responsive> | ||
<div className="table"> | ||
<Table striped bordered hover variant="dark" responsive> | ||
<thead> | ||
<tr> | ||
<th>S.No</th> | ||
<th>Movie Name</th> | ||
<th>Last Name</th> | ||
<th>Username</th> | ||
<th>Movie </th> | ||
<th>Title</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>1</td> | ||
<td>Mark</td> | ||
<td>Otto</td> | ||
<td> | ||
<Button>Remove</Button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
{cart.map((item, index) => { | ||
return ( | ||
<tbody> | ||
<tr> | ||
<td>{index + 1}</td> | ||
|
||
<td style={{ width: "5%" }}> | ||
<Link to={`/movie/${item.imdbID}`} className="link"> | ||
<img width="100px" src={item.Poster} alt={item.Title} /> | ||
</Link> | ||
</td> | ||
|
||
<td> | ||
<Link to={`/movie/${item.imdbID}`} className="link"> | ||
<h6>{item.Title}</h6> | ||
</Link> | ||
</td> | ||
|
||
<td> | ||
<Button onClick={() => removeFav(item._id)}>Remove</Button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
); | ||
})} | ||
</Table> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters