-
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.
add feat review and update feat gitcard
- Loading branch information
1 parent
99df15b
commit b7d0153
Showing
18 changed files
with
583 additions
and
409 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import React from "react"; | ||
import newRequest from "../../utils/newRequest"; | ||
import "./Review.scss"; | ||
const Review = ({ review }) => { | ||
const { isLoading, error, data } = useQuery( | ||
{ | ||
queryKey: [review.userId], | ||
queryFn: () => | ||
newRequest.get(`/users/${review.userId}`).then((res) => { | ||
return res.data; | ||
}), | ||
}, | ||
); | ||
|
||
|
||
return ( | ||
<div className="review"> | ||
{isLoading ? ( | ||
"loading" | ||
) : error ? ( | ||
"error" | ||
) : ( | ||
<div className="user"> | ||
<img className="pp" src={data.img || "/img/noavatar.jpg"} alt="" /> | ||
<div className="info"> | ||
<span>{data.username}</span> | ||
<div className="country"> | ||
<span>{data.country}</span> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
<div className="stars"> | ||
{Array(review.star) | ||
.fill() | ||
.map((item, i) => ( | ||
<img src="/img/star.png" alt="" key={i} /> | ||
))} | ||
<span>{review.star}</span> | ||
</div> | ||
<p>{review.desc}</p> | ||
<div className="helpful"> | ||
<span>Helpful?</span> | ||
<img src="/img/like.png" alt="" /> | ||
<span>Yes</span> | ||
<img src="/img/dislike.png" alt="" /> | ||
<span>No</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Review; |
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,52 @@ | ||
.review { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
margin: 20px 0px; | ||
.user { | ||
display: flex; | ||
align-items: center; | ||
.pp { | ||
height: 50px; | ||
width: 50px; | ||
border-radius: 50%; | ||
} | ||
|
||
.country { | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
color: gray; | ||
|
||
img { | ||
width: 20px; | ||
} | ||
} | ||
} | ||
|
||
.stars { | ||
display: flex; | ||
gap: 5px; | ||
|
||
img { | ||
height: 14px; | ||
width: 14px; | ||
} | ||
|
||
span { | ||
font-size: 14px; | ||
font-weight: bold; | ||
color: #ffc108; | ||
} | ||
} | ||
|
||
.helpful { | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
|
||
img { | ||
width: 14px; | ||
} | ||
} | ||
} |
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,58 @@ | ||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; | ||
import React from "react"; | ||
import newRequest from "../../utils/newRequest"; | ||
import Review from "../review/Review"; | ||
import "./Reviews.scss"; | ||
const Reviews = ({ gigId }) => { | ||
const queryClient = useQueryClient(); | ||
const { isLoading, error, data } = useQuery({ | ||
queryKey: ["reviews"], | ||
queryFn: () => | ||
newRequest.get(`/reviews/${gigId}`).then((res) => { | ||
return res.data; | ||
}), | ||
}); | ||
|
||
const mutation = useMutation({ | ||
mutationFn: (review) => { | ||
return newRequest.post("/reviews", review); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries(["reviews"]); | ||
}, | ||
}); | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
const desc = e.target[0].value; | ||
const star = e.target[1].value; | ||
mutation.mutate({ gigId, desc, star }); | ||
}; | ||
|
||
return ( | ||
<div className="reviews"> | ||
<h2>Đánh Giá</h2> | ||
{isLoading | ||
? "loading" | ||
: error | ||
? "Something went wrong!" | ||
: data.map((review) => <Review key={review._id} review={review} />)} | ||
<div className="add"> | ||
<h3>Thêm đánh giá về người này</h3> | ||
<form action="" className="addForm" onSubmit={handleSubmit}> | ||
<input type="text" placeholder="write your opinion" /> | ||
<select name="" id=""> | ||
<option value={1}>1</option> | ||
<option value={2}>2</option> | ||
<option value={3}>3</option> | ||
<option value={4}>4</option> | ||
<option value={5}>5</option> | ||
</select> | ||
<button>Gửi</button> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Reviews; |
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,41 @@ | ||
.reviews { | ||
margin-top: 50px; | ||
|
||
.add { | ||
margin-top: 20px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
|
||
.addForm { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
|
||
input { | ||
padding: 20px; | ||
} | ||
|
||
select { | ||
width: 200px; | ||
padding: 20px; | ||
align-self: flex-end; | ||
} | ||
button { | ||
align-self: flex-end; | ||
width: 100px; | ||
border: none; | ||
padding: 10px; | ||
color: white; | ||
background-color: #1dbf73; | ||
cursor: pointer; | ||
} | ||
} | ||
} | ||
|
||
hr { | ||
height: 0; | ||
border: 0.5px solid lightgray; | ||
margin: 50px 0px; | ||
} | ||
} |
Oops, something went wrong.