"use client"; import Image from "next/image"; import placeholder from "@/public/person placeholder.svg"; import clsx from "clsx"; import { motion, usePresence, Variant, Transition } from "framer-motion"; import RollingCounter from "react-slot-counter"; interface IProps { number: number; name: string | null; description: string | null; photo: string | null; votes: number; progress: number; voteCode: string; smsNumber: string; isFirst: boolean; voteStatus: string; winner: boolean; hasUrl: boolean; index: number; } const ParticipantCard = ({ number, name, description, photo, votes, progress, voteCode, index, hasUrl, isFirst, voteStatus, winner, }: IProps) => { const substractedProgress = progress > 99 ? progress - 2 : progress; const transition: Transition = { type: "spring", stiffness: 500, damping: 50, mass: 1, delay: index * 0.1, }; const [isPresent, safeToRemove] = usePresence(); const animations = { layout: true, initial: "out", style: { position: (isPresent ? "static" : "absolute") as "static" | "absolute", // Corrected cast }, animate: isPresent ? "in" : "out", variants: { in: { scaleY: 1, opacity: 1 }, out: { scaleY: 0, opacity: 0, zIndex: -1 }, tapped: { scale: 0.98, opacity: 0.5, transition: { duration: 0.1 } }, }, onAnimationComplete: () => !isPresent && safeToRemove(), transition, }; return winner && votes !== 0 ? ( ////////////////////////////////////////////// Winner card

{number}

{photo && name ? ( // If there an image, show image
{name}
) : ( // If there is no image, show placeholder
{"placeholder"}
)}
{name ? (

{name}

) : null} {description ? (

{description}

) : null} {/* If we have voteCode and voting not closed, then show badge with code. Else dont show */} {voteCode && voteStatus !== "closed" ? ( // Desktop version

Ses bermek üçin {voteCode} ugrat

) : null}

{/* {votes ? votes : 0} */}

ses

{/* If we have voteCode and voting not closed, then show badge with code. Else dont show */} {voteCode && voteStatus !== "closed" ? ( // Mobile version

Ses bermek üçin{" "} {voteCode} {" "} ugrat

) : null}
) : ( ////////////////////////////////////////////// Simple card

{number}

{photo && name ? (
{name}
) : (
{"placeholder"}
)}
{name ? (

{name}

) : null} {description ? (

{description}

) : null} {/* If we have voteCode and voting not closed, then show badge with code. Else dont show */} {voteCode && voteStatus !== "closed" ? ( // Desktop version

Ses bermek üçin {voteCode} ugrat

) : null}

{/* {votes ? votes : 0} */}

ses

{/* If we have voteCode and voting not closed, then show badge with code. Else dont show */} {voteCode && voteStatus !== "closed" ? ( // Mobile version

Ses bermek üçin{" "} {voteCode} {" "} ugrat

) : null}
); }; export default ParticipantCard;