Skip to content

Commit

Permalink
feat: Username of reviews clickable and redirect to userProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmansilla committed Dec 14, 2023
1 parent cc60669 commit 3185e5f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/Reviews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React, { useState, useEffect } from "react";
import { Container, Row, Col, Button, Image } from "react-bootstrap";
import PostReview from "./PostReview";
import { StarFill, PatchCheck, PencilSquare, Trash } from 'react-bootstrap-icons';
import { useNavigate } from "react-router-dom";
import LikesReview from "./LikesReview";
import ImageModal from "./ImageModal";
import ModifyReview from "./ModifyReview";


function Reviews(props) {
const { id, reloadReviews, owner } = props;
const [reviews, setReviews] = useState(null);
Expand All @@ -18,6 +18,7 @@ function Reviews(props) {
const [selectedFunct, setSelectedFunct] = useState(null);
const isLogged = window.localStorage.getItem("logged");
const currentUser = localStorage.getItem('currentUser');
const navigate = useNavigate();


useEffect(() => {
Expand Down Expand Up @@ -60,6 +61,10 @@ function Reviews(props) {
setSelectedFunct(null);
};

const handleNavigate = (userId) => {
navigate(`/UserProfile/${userId}`);
};

return (
<Container className="flex-column justify-content-between align-items-center">
{isLogged === 'true' ?
Expand All @@ -85,8 +90,10 @@ function Reviews(props) {
<li key={index} className="mb-3 p-2 fs-6 bg-light box-shadow">
{review.image ?
<Row>
<Col sm={12} className="fw-bold">
{review.username}:{" "}
<Col sm={12}>
<div className="fw-bold" style={{ cursor: 'pointer' }} onClick={() => handleNavigate(review.username)}>
{review.username}:{" "}
</div>
</Col>
<Col sm={12}>{review.comment}</Col>
<Col sm={5} className="mt-2">
Expand Down Expand Up @@ -156,8 +163,10 @@ function Reviews(props) {
</Row>
:
<Row>
<Col sm={12} className="fw-bold">
{review.username}:{" "}
<Col sm={12}>
<div className="fw-bold" style={{ cursor: 'pointer' }} onClick={() => handleNavigate(review.username)}>
{review.username}:{" "}
</div>
</Col>
<Col sm={5} className="mt-1" style={{ wordWrap: "break-word" }}>{review.comment}</Col>
<Col sm={7}>
Expand Down

0 comments on commit 3185e5f

Please sign in to comment.