r.sender.discordID === UserStore.getCurrentUser().id)}
/>
)}
>
);
}
function ReviewList({ refetch, reviews, hideOwnReview }: { refetch(): void; reviews: Review[]; hideOwnReview: boolean; }) {
const myId = UserStore.getCurrentUser().id;
return (
{reviews?.map(review =>
(review.sender.discordID !== myId || !hideOwnReview) &&
)}
{reviews?.length === 0 && (
Looks like nobody reviewed this user yet. You could be the first!
)}
);
}
export function ReviewsInputComponent({ discordId, isAuthor, refetch, name }: { discordId: string, name: string; isAuthor: boolean; refetch(): void; }) {
const { token } = settings.store;
function onKeyPress({ key, target }: KeyboardEvent) {
if (key === "Enter") {
addReview({
userid: discordId,
comment: (target as HTMLInputElement).value,
star: -1
}).then(res => {
if (res?.success) {
(target as HTMLInputElement).value = ""; // clear the input
refetch();
} else if (res?.message) {
showToast(res.message);
}
});
}
}
return (