'use client'; import { type ServiceFieldsFragment } from '@repo/graphql/types'; import { Badge } from '@repo/ui/components/ui/badge'; import { Button } from '@repo/ui/components/ui/button'; import { cn } from '@repo/ui/lib/utils'; import { getMinutes } from '@repo/utils/datetime-format'; import { formatMoney } from '@repo/utils/money'; import { useState } from 'react'; type ServiceCardProps = ServiceFieldsFragment; export function ServiceCard({ active, description, duration, name, price, }: Readonly) { const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false); const shouldShowExpandButton = description && (description.length > 120 || description.split('\n').length > 2 || (description.length > 80 && description.includes('\n'))); return (
{name} {active ? ( {getMinutes(duration) + ' мин'} ) : ( Закрыта )}
{(description || typeof price === 'number') && (
{description && (
{description}
{shouldShowExpandButton && (
{ event.preventDefault(); event.stopPropagation(); }} onMouseDown={(event) => { event.preventDefault(); event.stopPropagation(); }} >
)}
)} {typeof price === 'number' && (
{formatMoney(price)}
)}
)}
); }