2026-03-19 18:22:18 -03:00
|
|
|
function ChannelBadge({ channel }) {
|
|
|
|
|
const colors = {
|
|
|
|
|
WhatsApp: '#2bb741',
|
|
|
|
|
Email: '#e5a22a',
|
|
|
|
|
SMS: '#00a4b7',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
display: 'inline-flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
borderRadius: 999,
|
|
|
|
|
padding: '0.22rem 0.6rem',
|
|
|
|
|
background: `${colors[channel] || '#003150'}16`,
|
|
|
|
|
color: colors[channel] || '#003150',
|
|
|
|
|
fontSize: '0.8rem',
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{channel}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 11:37:29 -03:00
|
|
|
function LastMessageDot({ fromMe }) {
|
|
|
|
|
const color = fromMe ? '#e5a22a' : '#00a4b7';
|
|
|
|
|
const label = fromMe ? 'Última mensagem enviada pelo atendimento' : 'Última mensagem enviada pelo cliente';
|
2026-05-19 09:45:00 -03:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span
|
2026-05-20 11:37:29 -03:00
|
|
|
title={label}
|
|
|
|
|
aria-label={label}
|
2026-05-19 09:45:00 -03:00
|
|
|
style={{
|
|
|
|
|
width: 10,
|
|
|
|
|
height: 10,
|
|
|
|
|
borderRadius: 999,
|
|
|
|
|
background: color,
|
|
|
|
|
boxShadow: `0 0 0 3px ${color}22`,
|
|
|
|
|
flex: '0 0 auto',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 15:29:43 -03:00
|
|
|
function UnreadBadge({ count }) {
|
|
|
|
|
if (!count) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
width: 26,
|
|
|
|
|
height: 26,
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
background: 'var(--color-secondary)',
|
|
|
|
|
color: '#fff',
|
|
|
|
|
fontSize: '0.78rem',
|
|
|
|
|
fontWeight: 800,
|
|
|
|
|
display: 'inline-grid',
|
|
|
|
|
placeItems: 'center',
|
|
|
|
|
lineHeight: 1,
|
|
|
|
|
flex: '0 0 auto',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{count > 99 ? '99+' : count}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 11:37:29 -03:00
|
|
|
function SavedContactLabel({ contact }) {
|
|
|
|
|
const profile = contact.contactProfile;
|
|
|
|
|
const hasSavedContact = Boolean(profile?.created_at || profile?.name || profile?.company || profile?.note);
|
|
|
|
|
if (!hasSavedContact) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span
|
|
|
|
|
title="Contato salvo na agenda"
|
|
|
|
|
style={{
|
|
|
|
|
color: '#b7791f',
|
|
|
|
|
flex: '0 0 auto',
|
|
|
|
|
fontSize: '0.72rem',
|
|
|
|
|
fontWeight: 800,
|
|
|
|
|
lineHeight: 1,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
•Salvo•
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-05-19 15:29:43 -03:00
|
|
|
|
2026-05-20 13:56:04 -03:00
|
|
|
const CHAT_LIST_HEIGHT = 'min(760px, calc(100vh - 160px))';
|
|
|
|
|
|
2026-03-19 18:22:18 -03:00
|
|
|
export function ChatConversationList({
|
|
|
|
|
contacts,
|
|
|
|
|
activeContactId,
|
|
|
|
|
onSelectContact,
|
2026-05-20 11:37:29 -03:00
|
|
|
onOpenContact,
|
2026-03-19 18:22:18 -03:00
|
|
|
isMobile = false,
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<aside
|
|
|
|
|
style={{
|
|
|
|
|
background: '#fff',
|
|
|
|
|
border: '1px solid var(--color-border)',
|
|
|
|
|
borderRadius: '28px',
|
|
|
|
|
padding: '1rem',
|
|
|
|
|
display: 'grid',
|
2026-05-19 09:45:00 -03:00
|
|
|
gridTemplateRows: 'auto minmax(0, 1fr)',
|
2026-03-19 18:22:18 -03:00
|
|
|
gap: '0.85rem',
|
2026-05-20 13:56:04 -03:00
|
|
|
height: isMobile ? 'auto' : CHAT_LIST_HEIGHT,
|
|
|
|
|
maxHeight: isMobile ? 'none' : CHAT_LIST_HEIGHT,
|
|
|
|
|
alignSelf: 'start',
|
2026-05-19 09:45:00 -03:00
|
|
|
minHeight: 0,
|
2026-03-19 18:22:18 -03:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<strong style={{ display: 'block', fontSize: '1.08rem' }}>Conversas ativas</strong>
|
|
|
|
|
<span style={{ color: 'var(--color-text-soft)' }}>
|
2026-05-20 11:37:29 -03:00
|
|
|
WhatsApp, SMS e e-mail em uma fila visual.
|
2026-03-19 18:22:18 -03:00
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: 'grid',
|
|
|
|
|
gap: '0.75rem',
|
|
|
|
|
gridTemplateColumns: isMobile ? '1fr' : '1fr',
|
2026-05-19 15:29:43 -03:00
|
|
|
gridAutoRows: 'max-content',
|
|
|
|
|
alignContent: 'start',
|
2026-05-19 09:45:00 -03:00
|
|
|
overflowY: 'auto',
|
|
|
|
|
minHeight: 0,
|
|
|
|
|
paddingRight: '0.15rem',
|
2026-03-19 18:22:18 -03:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{contacts.map((contact) => {
|
|
|
|
|
const isActive = contact.id === activeContactId;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={contact.id}
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => onSelectContact(contact.id)}
|
2026-05-20 11:37:29 -03:00
|
|
|
onContextMenu={(event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
onSelectContact(contact.id);
|
|
|
|
|
onOpenContact?.(contact);
|
|
|
|
|
}}
|
2026-03-19 18:22:18 -03:00
|
|
|
style={{
|
|
|
|
|
border: '1px solid',
|
|
|
|
|
borderColor: isActive ? 'rgba(0, 164, 183, 0.26)' : 'var(--color-border)',
|
|
|
|
|
background: isActive ? 'rgba(0, 164, 183, 0.08)' : '#fff',
|
|
|
|
|
borderRadius: '20px',
|
|
|
|
|
padding: '1rem',
|
|
|
|
|
textAlign: 'left',
|
|
|
|
|
display: 'grid',
|
|
|
|
|
gap: '0.6rem',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', gap: '1rem' }}>
|
2026-05-19 09:45:00 -03:00
|
|
|
<span style={{ display: 'inline-flex', alignItems: 'center', gap: '0.5rem', minWidth: 0 }}>
|
2026-05-20 11:37:29 -03:00
|
|
|
<LastMessageDot fromMe={contact.lastMessageFromMe} />
|
2026-05-19 09:45:00 -03:00
|
|
|
<strong style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
|
|
|
|
{contact.name}
|
|
|
|
|
</strong>
|
|
|
|
|
</span>
|
2026-03-19 18:22:18 -03:00
|
|
|
<span style={{ fontSize: '0.82rem', color: 'var(--color-text-soft)' }}>
|
|
|
|
|
{contact.time}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', gap: '0.75rem' }}>
|
2026-05-20 11:37:29 -03:00
|
|
|
<span style={{ display: 'inline-flex', alignItems: 'center', gap: '0.45rem', minWidth: 0 }}>
|
|
|
|
|
<ChannelBadge channel={contact.channel} />
|
|
|
|
|
<SavedContactLabel contact={contact} />
|
|
|
|
|
</span>
|
2026-05-19 15:29:43 -03:00
|
|
|
<UnreadBadge count={contact.unread} />
|
2026-03-19 18:22:18 -03:00
|
|
|
</div>
|
|
|
|
|
<span style={{ color: 'var(--color-text-soft)' }}>{contact.preview}</span>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2026-05-19 15:29:43 -03:00
|
|
|
|
|
|
|
|
{contacts.length === 0 ? (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
border: '1px solid var(--color-border)',
|
|
|
|
|
borderRadius: '18px',
|
|
|
|
|
padding: '1rem',
|
|
|
|
|
background: 'rgba(0, 49, 80, 0.04)',
|
|
|
|
|
color: 'var(--color-text-soft)',
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
lineHeight: 1.45,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Nenhuma conversa ativa na sua fila. Conversas em triagem do Omnino aparecem aqui depois de classificadas.
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
2026-03-19 18:22:18 -03:00
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
);
|
|
|
|
|
}
|