'use client';
import Image from 'next/image';
import placeholder from '@/public/person placeholder.svg';
interface IProps {
number: number;
name: string | null;
photo: string | null;
votes: number;
progress: number;
voteCode: string;
smsNumber: string;
isFirst: boolean;
voteStatus: string;
winner: boolean;
}
const ParticipantCard = ({
number,
name,
photo,
votes,
progress,
voteCode,
isFirst,
voteStatus,
winner,
}: IProps) => {
const substractedProgress = progress > 99 ? progress - 2 : progress;
return winner && votes !== 0 ? (
////////////////////////////////////////////// Winner card
{number}
{photo && name ? (
// If there an image, show image
) : (
// If there is no image, show placeholder
)}
{name ? (
{name}
) : 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
{/* Progress bar */}
{/*
*/}
{/* 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 ? (
{name}
) : 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;