omnichannel-frontend/src/modules/chat/components/ChatConversationList.jsx

143 lines
4.0 KiB
React
Raw Normal View History

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>
);
}
function PresenceDot({ status }) {
const color =
status === 'online'
? '#16a34a'
: status === 'away'
? '#e5a22a'
: '#dc2626';
return (
<span
aria-hidden="true"
style={{
width: 10,
height: 10,
borderRadius: 999,
background: color,
boxShadow: `0 0 0 3px ${color}22`,
flex: '0 0 auto',
}}
/>
);
}
export function ChatConversationList({
contacts,
activeContactId,
onSelectContact,
isMobile = false,
}) {
return (
<aside
style={{
background: '#fff',
border: '1px solid var(--color-border)',
borderRadius: '28px',
padding: '1rem',
display: 'grid',
gridTemplateRows: 'auto minmax(0, 1fr)',
gap: '0.85rem',
height: isMobile ? 'auto' : 'min(760px, calc(100vh - 190px))',
minHeight: 0,
}}
>
<div>
<strong style={{ display: 'block', fontSize: '1.08rem' }}>Conversas ativas</strong>
<span style={{ color: 'var(--color-text-soft)' }}>
WhatsApp, SMS e email em uma fila visual.
</span>
</div>
<div
style={{
display: 'grid',
gap: '0.75rem',
gridTemplateColumns: isMobile ? '1fr' : '1fr',
overflowY: 'auto',
minHeight: 0,
paddingRight: '0.15rem',
}}
>
{contacts.map((contact) => {
const isActive = contact.id === activeContactId;
return (
<button
key={contact.id}
type="button"
onClick={() => onSelectContact(contact.id)}
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' }}>
<span style={{ display: 'inline-flex', alignItems: 'center', gap: '0.5rem', minWidth: 0 }}>
<PresenceDot status={contact.status} />
<strong style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{contact.name}
</strong>
</span>
<span style={{ fontSize: '0.82rem', color: 'var(--color-text-soft)' }}>
{contact.time}
</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', gap: '0.75rem' }}>
<ChannelBadge channel={contact.channel} />
{contact.unread ? (
<span
style={{
minWidth: 24,
borderRadius: 999,
padding: '0.15rem 0.45rem',
background: 'var(--color-secondary)',
color: '#fff',
fontSize: '0.78rem',
fontWeight: 700,
textAlign: 'center',
}}
>
{contact.unread}
</span>
) : null}
</div>
<span style={{ color: 'var(--color-text-soft)' }}>{contact.preview}</span>
</button>
);
})}
</div>
</aside>
);
}