import { JSXInternal } from "node_modules/preact/src/jsx"; import { LocationInfo } from "../../../domains"; import { cn } from "../../../utils/common"; import FallbackImage from "../../../../src/components/Img/FallbackImage"; interface ComponentProps { onCardClick: (id: number) => void, data: LocationInfo, containerClass?: string, containerStyle?: JSXInternal.CSSProperties } const LocationCard = (props: ComponentProps) => { const getScoreClasses = (score: number, count: number) => { if (count === 0) return { text: 'text-white', bg: 'bg-white' }; if (score <= 40) return { text: 'text-rating-red', bg: 'bg-rating-red' }; if (score <= 69) return { text: 'text-rating-yellow', bg: 'bg-rating-yellow' }; return { text: 'text-brand-green', bg: 'bg-brand-green' }; }; const criticClasses = getScoreClasses(props.data.critic_score, props.data.critic_count); const userClasses = getScoreClasses(props.data.user_score, props.data.user_count); return (
{props.data.name}
{props.data.regency_name}, {props.data.province_name}
{props.data.critic_count !== 0 ? props.data.critic_score : 'NR'}
Critic score ({props.data.critic_count})
{props.data.user_count !== 0 ? props.data.user_score : 'NR'}
User score ({props.data.user_count})