Skip to content

Commit

Permalink
feat: icon indicating you authored review (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
timobraz authored Feb 2, 2024
1 parent a337e23 commit e0f9318
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion site/src/component/Review/Review.scss
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@
.add-report-button:hover {
background-color: lightgray;
}

.gapped {
display: flex;
align-items: center;
gap: 0.25rem;
}
@media only screen and (max-width: 600px) {
.subreview-content {
flex-direction: column;
Expand Down
15 changes: 12 additions & 3 deletions site/src/component/Review/SubReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Tooltip from 'react-bootstrap/Tooltip';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import { useCookies } from 'react-cookie';
import { Link } from 'react-router-dom';

import { PersonFill } from 'react-bootstrap-icons';
import { ReviewData, VoteRequest, CourseGQLData, ProfessorGQLData, VoteColor } from '../../types/types';
import ReportForm from '../ReportForm/ReportForm';

Expand Down Expand Up @@ -41,6 +41,7 @@ const SubReview: FC<SubReviewProps> = ({ review, course, professor, colors, colo
alert('You must be logged in to vote.');
return;
}

const votes = {
id: ((e.target as HTMLElement).parentNode! as Element).getAttribute('id')!,
upvote: true,
Expand Down Expand Up @@ -74,13 +75,20 @@ const SubReview: FC<SubReviewProps> = ({ review, course, professor, colors, colo
};

const badgeOverlay = <Tooltip id="verified-tooltip">This review was verified by an administrator.</Tooltip>;
const authorOverlay = <Tooltip id="authored-tooltip">You are the author of this review.</Tooltip>;

const verifiedBadge = (
<OverlayTrigger overlay={badgeOverlay}>
<Badge variant="primary">Verified</Badge>
</OverlayTrigger>
);

const authorBadge = (
<OverlayTrigger overlay={authorOverlay}>
<PersonFill size={25} fill="green"></PersonFill>
</OverlayTrigger>
);

return (
<div className="subreview">
<div>
Expand Down Expand Up @@ -137,9 +145,10 @@ const SubReview: FC<SubReviewProps> = ({ review, course, professor, colors, colo
</div>
<div>
<div className="subreview-author">
<p>
<span className="mr-1">Posted by {review.userDisplay}</span>
<p className=" gapped">
<span className=" mr-1">Posted by {review.userDisplay}</span>
{review.verified && verifiedBadge}
{cookies.user?.id === review.userID && authorBadge}
</p>
<p>
{new Date(review.timestamp).toLocaleString('default', {
Expand Down

0 comments on commit e0f9318

Please sign in to comment.