vchikalkin 92035a4ff8 feat(contacts): add showServices prop to ContactRow for conditional rendering
- Updated ContactsList to pass showServices prop to ContactRow.
- Modified ContactRow to conditionally render services based on the showServices prop, enhancing the display of contact information.
2025-09-08 14:50:31 +03:00

46 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type * as GQL from '@repo/graphql/types';
import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/ui/avatar';
import { Badge } from '@repo/ui/components/ui/badge';
import { cn } from '@repo/ui/lib/utils';
import Link from 'next/link';
import { memo } from 'react';
type ContactRowProps = GQL.CustomerFieldsFragment & {
readonly className?: string;
readonly showServices?: boolean;
};
export const ContactRow = memo(function ({ className, showServices, ...contact }: ContactRowProps) {
return (
<Link
className="block"
href={contact.active ? `/profile/${contact.telegramId}` : ''}
key={contact.telegramId}
>
<div
className={cn(
'flex items-center justify-between',
contact.active ? 'hover:bg-accent' : 'opacity-50',
className,
)}
>
<div className={cn('flex items-center space-x-4 rounded-lg py-2 transition-colors')}>
<Avatar>
<AvatarImage alt={contact.name} src={contact.photoUrl || ''} />
<AvatarFallback>{contact.name.charAt(0)}</AvatarFallback>
</Avatar>
<div>
<p className="font-medium">{contact.name}</p>
{showServices && (
<p className="max-w-52 truncate text-xs text-muted-foreground">
{contact.services.map((service) => service?.name).join(', ')}
</p>
)}
</div>
</div>
{contact.active ? <div /> : <Badge variant="destructive">Неактивен</Badge>}
</div>
</Link>
);
});