Skip to content

Commit

Permalink
fix: i suggestion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Dec 2, 2024
1 parent 0a501d4 commit 05554e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ProjectReview } from "~checker/types";
import { getReviewsCount } from "~checker/utils/getReviewsCount";

import { ReviewsCounterLabel } from "../ReviewsCounterLabel";
import { addressFrom } from "@/lib";

export interface ProjectReviewListProps {
projects: ProjectReview[];
Expand Down Expand Up @@ -65,11 +66,11 @@ export const ProjectReviewList = ({
header: "AI Suggestion",
key: "aiSuggestion",
width: "0.9fr",
render: (item) => {
return item.aiSuggestion !== 0 ? (
<IconLabel type="ai-evaluation" percent={item.aiSuggestion} />
) : (
render: (item) => { // addressFrom(1) === ai evaluator
return item.reviews.some(review => review.reviewer === addressFrom(1)) ? (
<ReviewsCounterLabel negativeReviews={0} positiveReviews={0} />
) : (
<IconLabel type="ai-evaluation" percent={item.aiSuggestion} />
);
},
},
Expand Down
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import { match, P } from "ts-pattern";


export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
Expand Down Expand Up @@ -54,3 +55,8 @@ export function capitalizeWord(word: string): string {
if (!word) return word;
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
}

export const addressFrom = (index: number): string => {
const address = index.toString(16).padStart(40, "0");
return `0x${address}`;
};

0 comments on commit 05554e0

Please sign in to comment.