Skip to content

Commit

Permalink
chore: partially implemented ProjectReviewList component
Browse files Browse the repository at this point in the history
  • Loading branch information
hussedev committed Oct 29, 2024
1 parent 62b7315 commit 9441198
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Meta, StoryObj } from "@storybook/react";

import { ProjectReviewList } from "./ProjectReviewList";
import { mockProjectReviews } from "./mocks";

const meta = {
title: "Features/Checker/ProjectReviewList",
component: ProjectReviewList,
args: {
reviewer: "0x1234567890123456789012345678901234567890",
projects: mockProjectReviews,
},
} satisfies Meta;

export default meta;

type Story = StoryObj<typeof ProjectReviewList>;

export const Default: Story = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { ListGrid, ListGridColumn } from "@/primitives/ListGrid/ListGrid";

import { ProjectReview } from "./types";

export interface ProjectReviewListProps {
reviewer: `0x${string}`;
projects: ProjectReview[];
}

export const ProjectReviewList = ({ reviewer, projects }: ProjectReviewListProps) => {
const columns: ListGridColumn<ProjectReview>[] = [
{
header: "Project",
key: "project",
render: (item) => <span>{item.name}</span>, // TODO: Add project avatar
},
{
header: "Date Submitted",
key: "date",
render: (item) => <span>{item.date.toLocaleDateString()}</span>,
},
{
header: "Reviews",
key: "reviews",
render: (item) => <span>{item.reviews.length}</span>,
},
{
header: "AI Suggestion",
key: "aiSuggestion",
render: (item) => <span>{item.aiSuggestion}</span>,
},
{
header: "Score Average",
key: "scoreAverage",
render: (item) => <span>{item.scoreAverage}</span>,
},
{
header: "Action",
key: "action",
render: (item) =>
item.reviews.find((review) => review.reviewer === reviewer) ? (
<span>IsReviewed</span>
) : (
<span>Review</span>
),
},
];
return (
<ListGrid
data={projects}
columns={columns}
getRowKey={(item: ProjectReview) => item.id.toString()}
/>
);
};
31 changes: 31 additions & 0 deletions src/features/checker/components/ProjectReviewList/mocks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ProjectReview } from "./types";

export const mockProjectReviews: ProjectReview[] = [
{
id: 1,
name: "Project 1",
date: new Date(),
avatarUrl: "",
reviews: [],
aiSuggestion: 0,
scoreAverage: 0,
},
{
id: 2,
name: "Project 2",
date: new Date(),
avatarUrl: "",
reviews: [],
aiSuggestion: 0,
scoreAverage: 0,
},
{
id: 3,
name: "Project 3",
date: new Date(),
avatarUrl: "",
reviews: [],
aiSuggestion: 0,
scoreAverage: 0,
},
];
14 changes: 14 additions & 0 deletions src/features/checker/components/ProjectReviewList/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
interface Review {
reviewer: `0x${string}`;
approved: boolean;
}

export interface ProjectReview {
id: number;
name: string;
date: Date;
avatarUrl: string;
reviews: Review[];
aiSuggestion: number;
scoreAverage: number;
}

0 comments on commit 9441198

Please sign in to comment.