- 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.
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
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>
|
||
);
|
||
});
|