diff --git a/package.json b/package.json index 94be3f3..56546c9 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@prisma/client": "^5.11.0", + "@radix-ui/react-avatar": "^1.1.1", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-menubar": "^1.0.4", "@radix-ui/react-slot": "^1.0.2", diff --git a/src/app/elections/[electionId]/results/page.tsx b/src/app/elections/[electionId]/results/page.tsx index 223254d..ea2c883 100644 --- a/src/app/elections/[electionId]/results/page.tsx +++ b/src/app/elections/[electionId]/results/page.tsx @@ -1,8 +1,26 @@ +import { getCandidates } from "@packages/DAO/candidates.dao"; +import ResultCard from "@packages/components/ResultCard"; const Home = () => { return ( -
-
-

Resultados da Eleição

+
+
+
+

Resultado da Eleição

+ {getCandidates().map( + ({ image, candidate, vice, party, percentage, votes }) => ( +
+ +
+ ), + )} +
); diff --git a/src/packages/DAO/candidates.dao.ts b/src/packages/DAO/candidates.dao.ts new file mode 100644 index 0000000..537da2e --- /dev/null +++ b/src/packages/DAO/candidates.dao.ts @@ -0,0 +1,55 @@ +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 function getCandidates() { + return candidates; +} diff --git a/src/packages/components/ResultCard.tsx b/src/packages/components/ResultCard.tsx new file mode 100644 index 0000000..5bdf9ba --- /dev/null +++ b/src/packages/components/ResultCard.tsx @@ -0,0 +1,45 @@ +import { Avatar, AvatarImage } from "@packages/shadcn-ui/ui/avatar"; +import { Card } from "@packages/shadcn-ui/ui/card"; + +interface ElectionResult { + image: string; + candidate: string; + vice: string; + party: string; + percentagem: string; + votos: string; +} +function ResultCard({ + candidate, + vice, + party, + percentagem, + votos, + image, +}: ElectionResult) { + return ( + +
+ + + +
+

Presidente: {candidate}

+

Vice: {vice}

+

{party}

+
+
+
+

+ Percentagem dos votos:{" "} + {percentagem} +

+

+ Total de votos: {votos} +

+
+
+ ); +} + +export default ResultCard; diff --git a/src/packages/shadcn-ui/ui/avatar.tsx b/src/packages/shadcn-ui/ui/avatar.tsx new file mode 100644 index 0000000..3ab8f19 --- /dev/null +++ b/src/packages/shadcn-ui/ui/avatar.tsx @@ -0,0 +1,50 @@ +"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, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +Avatar.displayName = AvatarPrimitive.Root.displayName; + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AvatarImage.displayName = AvatarPrimitive.Image.displayName; + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; + +export { Avatar, AvatarImage, AvatarFallback }; diff --git a/src/packages/shadcn-ui/ui/card.tsx b/src/packages/shadcn-ui/ui/card.tsx new file mode 100644 index 0000000..02908d8 --- /dev/null +++ b/src/packages/shadcn-ui/ui/card.tsx @@ -0,0 +1,86 @@ +import * as React from "react"; + +import { cn } from "@packages/utils/shadcn-utils"; + +const Card = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +Card.displayName = "Card"; + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +CardHeader.displayName = "CardHeader"; + +const CardTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)); +CardTitle.displayName = "CardTitle"; + +const CardDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)); +CardDescription.displayName = "CardDescription"; + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)); +CardContent.displayName = "CardContent"; + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +CardFooter.displayName = "CardFooter"; + +export { + Card, + CardHeader, + CardFooter, + CardTitle, + CardDescription, + CardContent, +}; diff --git a/yarn.lock b/yarn.lock index 8fdbacb..62ae6bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -276,6 +276,16 @@ "@babel/runtime" "^7.13.10" "@radix-ui/react-primitive" "1.0.3" +"@radix-ui/react-avatar@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@radix-ui/react-avatar/-/react-avatar-1.1.1.tgz#5848d2ed5f34d18b36fc7e2d227c41fca8600ea1" + integrity sha512-eoOtThOmxeoizxpX6RiEsQZ2wj5r4+zoeqAwO0cBaFQGjJwIH3dIX0OCxNrCyrrdxG+vBweMETh3VziQG7c1kw== + dependencies: + "@radix-ui/react-context" "1.1.1" + "@radix-ui/react-primitive" "2.0.0" + "@radix-ui/react-use-callback-ref" "1.1.0" + "@radix-ui/react-use-layout-effect" "1.1.0" + "@radix-ui/react-collection@1.0.3": version "1.0.3" resolved "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz" @@ -311,6 +321,11 @@ resolved "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.1.0.tgz" integrity sha512-OKrckBy+sMEgYM/sMmqmErVn0kZqrHPJze+Ql3DzYsDDp0hl0L62nx/2122/Bvps1qz645jlcu2tD9lrRSdf8A== +"@radix-ui/react-context@1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@radix-ui/react-context/-/react-context-1.1.1.tgz#82074aa83a472353bb22e86f11bcbd1c61c4c71a" + integrity sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q== + "@radix-ui/react-dialog@^1.1.1": version "1.1.1" resolved "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.1.tgz"