This repository was archived by the owner on Feb 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProjectEvaluationList.tsx
100 lines (96 loc) · 2.79 KB
/
ProjectEvaluationList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { DefaultLogo } from "@/assets";
import { IconLabel } from "@/components/IconLabel";
import { CircleStat } from "@/primitives/Indicators";
import { ListGrid, ListGridColumn } from "@/primitives/ListGrid";
import { EvaluationAction, ProjectReview, ProjectStatus } from "~checker/types";
import { getReviewsCount } from "~checker/utils/getReviewsCount";
import { ProjectEvaluationAction } from "../ProjectEvaluationAction";
import { ReviewsCounterLabel } from "../ReviewsCounterLabel";
export interface ProjectEvaluationListProps {
evaluationStatus?: ProjectStatus;
projects: ProjectReview[];
action: (projectId: string, action: EvaluationAction) => void;
}
export const ProjectEvaluationList = ({
evaluationStatus = "pending",
projects,
action,
}: ProjectEvaluationListProps) => {
const columns: ListGridColumn<ProjectReview>[] = [
{
header: "Project",
key: "project",
width: "2fr",
render: (item) => (
<div className="flex items-center gap-4">
<img
src={item.avatarUrl}
alt={item.name}
className="aspect-square size-12 rounded-sm"
onError={(event: React.SyntheticEvent<HTMLImageElement, Event>) => {
event.currentTarget.src = DefaultLogo;
}}
/>
<span>{item.name}</span>
</div>
),
},
{
header: "Date Submitted",
key: "date",
width: "1fr",
render: (item) => <IconLabel type="date" date={item.date} />,
},
{
header: "Reviews",
key: "reviews",
width: "1fr",
render: (item) => {
const { nApproved, nRejected } = getReviewsCount(item.reviews);
return <ReviewsCounterLabel positiveReviews={nApproved} negativeReviews={nRejected} />;
},
},
{
header: "AI Suggestion",
key: "aiSuggestion",
width: "1fr",
render: (item) => <IconLabel type="ai-evaluation" percent={item.aiSuggestion} />,
},
{
header: "Score Average",
key: "scoreAverage",
width: "1fr",
position: "center",
render: (item) => (
<div className="flex items-center justify-center">
<CircleStat value={item.scoreAverage.toFixed(0)} />
</div>
),
},
{
header: "Action",
key: "action",
width: "2fr",
position: "center",
render: (item) => {
return (
<div className="flex items-center justify-center">
<ProjectEvaluationAction
onEvaluate={action}
projectId={item.id}
status={evaluationStatus}
/>
</div>
);
},
},
];
return (
<ListGrid
data={projects}
columns={columns}
rowClassName="h-[72px]"
getRowKey={(item: ProjectReview) => item.id.toString()}
/>
);
};