Skip to content

Commit

Permalink
Applied the corrections from the review
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel-leal committed Nov 27, 2024
1 parent e1dbc58 commit fa56ccd
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 93 deletions.
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = "postgres://test:test@localhost:5432/test"
}


Expand Down
Binary file removed public/image/avatar1.png
Binary file not shown.
Binary file removed public/image/avatar2.png
Binary file not shown.
Binary file removed public/image/avatar3.png
Binary file not shown.
Binary file removed public/image/avatar4.png
Binary file not shown.
Binary file removed public/image/avatar5.png
Binary file not shown.
8 changes: 4 additions & 4 deletions src/app/elections/[electionId]/results/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import candidates from "@packages/DAO/candidates.dao";
import ResultCard from "@packages/components/ResultCard";
import candidates from "src/data/data";
const Home = () => {
return (
<div>
<div className="flex items-center justify-center h-[80vh] content-center">
<div>
<h1 className="text-center text-xl p-16">Resultado da Eleição</h1>
{candidates.map(
({ image, candidate, vice, party, percentagem, votos }) => (
({ image, candidate, vice, party, percentage, votes }) => (
<div key={candidate} className="p-4">
<ResultCard
image={image}
candidate={candidate}
vice={vice}
party={party}
percentagem={percentagem}
votos={votos}
percentagem={percentage}
votos={votes}
/>
</div>
),
Expand Down
44 changes: 0 additions & 44 deletions src/data/data.tsx

This file was deleted.

52 changes: 52 additions & 0 deletions src/packages/DAO/candidates.dao.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
type Candidate = {
image: string;
candidate: string;
vice: string;
party: string;
percentage: string;
votes: string;
};

const candidates: Candidate[] = [
{
image: "https://picsum.photos/id/237/200/300",
candidate: "Jiji Ping Png",
vice: "Xinguilingui",
party: "PCC",
percentage: "35.2%",
votes: "3,200,000",
},
{
image: "https://picsum.photos/id/444/200/300",
candidate: "Vladimir Putin",
vice: "Zelensky",
party: "ABC",
percentage: "28.1%",
votes: "2,550,000",
},
{
image: "https://picsum.photos/id/398/200/300",
candidate: "Lulão da massa",
vice: "Xuxu",
party: "DEF",
percentage: "18.4%",
votes: "1,670,000",
},
{
image: "https://picsum.photos/id/577/200/300",
candidate: "Biden",
vice: "Gagá",
party: "GHI",
percentage: "12.3%",
votes: "1,120,000",
},
{
image: "https://picsum.photos/id/610/200/300",
candidate: "Trump",
vice: "Bolsonaro",
party: "JKL",
percentage: "6.0%",
votes: "540,000",
},
];
export default candidates;
2 changes: 1 addition & 1 deletion src/packages/components/ResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function ResultCard({
image,
}: ElectionResult) {
return (
<Card className="flex flex-row w-[60vw] p-4 shadow-md shadow-gray-200 border-[rgba(0,0,0,0)]">
<Card className="flex flex-row w-[60vw] p-4 shadow-md shadow-gray-200">
<div className="flex w-[40vw] gap-4">
<Avatar className="w-16 h-16">
<AvatarImage src={image} />
Expand Down
70 changes: 27 additions & 43 deletions src/packages/shadcn-ui/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,34 @@
"use client";

import * as AvatarPrimitive from "@radix-ui/react-avatar";
import * as React from "react";

import { cn } from "@packages/utils/shadcn-utils";

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className,
)}
{...props}
/>
));
Avatar.displayName = AvatarPrimitive.Root.displayName;

const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn("aspect-square h-full w-full", className)}
{...props}
/>
));
AvatarImage.displayName = AvatarPrimitive.Image.displayName;

const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
"flex h-full w-full items-center justify-center rounded-full bg-muted",
className,
)}
{...props}
/>
));
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
const WithStyles = (ShadcnElement: React.ElementType, styles: string) => {
const CustomComponent = React.forwardRef<
React.ElementRef<typeof ShadcnElement>,
React.ComponentPropsWithoutRef<typeof ShadcnElement>
>(({ className, ...props }, ref) => (
<ShadcnElement ref={ref} className={cn(styles, className)} {...props} />
));

CustomComponent.displayName = ShadcnElement.displayName;

return CustomComponent;
};

const AvatarFallback = WithStyles(
AvatarPrimitive.Fallback,
"flex h-full w-full items-center justify-center rounded-full bg-muted",
);

const Avatar = WithStyles(
AvatarPrimitive.Root,
"flex h-full w-full items-center justify-center rounded-full bg-muted",
);

const AvatarImage = WithStyles(
AvatarPrimitive.Image,
"flex h-full w-full items-center justify-center rounded-full bg-muted",
);

export { Avatar, AvatarImage, AvatarFallback };

0 comments on commit fa56ccd

Please sign in to comment.