From 47de9fab2efc4edd29aca46eca87c931607c13dc Mon Sep 17 00:00:00 2001 From: Manti <67705577+mantikafasi@users.noreply.github.com> Date: Sun, 18 Dec 2022 01:30:29 +0300 Subject: [PATCH] Make some changes to reviewdb ui and add badges to it (#245) --- .../reviewDB/components/ReviewBadge.tsx | 45 ++++++++++++ .../reviewDB/components/ReviewComponent.tsx | 21 ++++-- .../reviewDB/components/ReviewsView.tsx | 70 +++++++++---------- src/plugins/reviewDB/entities/Badge.ts | 26 +++++++ src/plugins/reviewDB/entities/Review.ts | 3 + src/webpack/common.tsx | 4 ++ 6 files changed, 126 insertions(+), 43 deletions(-) create mode 100644 src/plugins/reviewDB/components/ReviewBadge.tsx create mode 100644 src/plugins/reviewDB/entities/Badge.ts diff --git a/src/plugins/reviewDB/components/ReviewBadge.tsx b/src/plugins/reviewDB/components/ReviewBadge.tsx new file mode 100644 index 00000000..4a3c0c4c --- /dev/null +++ b/src/plugins/reviewDB/components/ReviewBadge.tsx @@ -0,0 +1,45 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { MaskedLinkStore, Tooltip } from "@webpack/common"; + +import { Badge } from "../entities/Badge"; + +export default function ReviewBadge(badge: Badge) { + return ( + + {({ onMouseEnter, onMouseLeave }) => ( + {badge.badge_description} + MaskedLinkStore.openUntrustedLink({ + href: badge.redirect_url, + }) + } + /> + )} + + ); +} diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index 8808ccd5..ddb49223 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -24,6 +24,7 @@ import { Review } from "../entities/Review"; import { deleteReview, reportReview } from "../Utils/ReviewDBAPI"; import { canDeleteReview, openUserProfileModal, showToast } from "../Utils/Utils"; import MessageButton from "./MessageButton"; +import ReviewBadge from "./ReviewBadge"; export default LazyComponent(() => { // this is terrible, blame mantika @@ -78,24 +79,32 @@ export default LazyComponent(() => { } return ( -
-
+
+ +
openModal()} > {review.username} + {review.badges.map(badge => )}

{review.comment}

diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 57f974e7..4852967a 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -54,44 +54,40 @@ export default function ReviewsView({ userId }: { userId: string; }) { return (
- <> - - User Reviews - - {reviews?.map(review => - - )} - {reviews?.length === 0 && ( - - Looks like nobody reviewed this user yet. You could be the first! - - )} -