Rev 7248 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react'import { useSelector } from 'react-redux'import styled, { css } from 'styled-components'import Avatar from '@mui/material/Avatar'import Options from '../UI/Option'import EmptySection from '../UI/EmptySection'const ContactsContainer = styled.div`background-color: var(--bg-color);border-radius: var(--border-radius);border: 1px solid var(--border-primary);display: flex;flex-direction: column;height: 100%;gap: 0.5rem;padding: 1rem 0.5rem;max-height: 80vh;flex-grow: 1;`const ContactHeader = styled.div`position: relative;h1 {font-weight: 600;font-size: 1.3rem;}`const ContactList = styled.ul`display: flex;flex-direction: column;overflow: auto;`const ContactItem = styled.div`align-items: center;display: flex;height: auto;padding: 0.5rem 1rem;gap: 0.5rem;cursor: pointer;border-radius: var(--border-radius);${(props) =>props.current &&css`background-color: #42b72a21;`}`const ContactInfo = styled.div`display: flex;flex-direction: column;span {font-size: 0.9rem;font-weight: bold;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 20ch;}`const Contacts = ({ children }) => {return <ContactsContainer>{children}</ContactsContainer>}const Header = ({ options = [], children }) => {return (<ContactHeader>{children}{!!options.length && <Options options={options} />}</ContactHeader>)}const List = ({contacts = [],onChange = () => null,currentConversation,}) => {const labels = useSelector(({ intl }) => intl.labels)return (<ContactList>{!contacts.length ? (<EmptySection message={labels.datatable_szerorecords} />) : (contacts.map((contact) => {return (<li key={contact.id || contact.uuid}><List.Item contact={contact} onClick={onChange} /></li>)}))}</ContactList>)}const Item = ({ contact, onClick, isCurrent }) => {const labels = useSelector(({ intl }) => intl.labels)return (<ContactItem onClick={() => onClick(contact)} current={isCurrent}><Avatarsrc={contact.image || '/images/users-group.png'}alt="image-image"sx={{ width: 32, height: 32 }}/><ContactInfo><span>{contact.name}</span>{contact.last_message && (<p>{`${contact.count_not_seen_messages || contact.count_unread || ''} ${labels.new_messages} |${contact.last_message}`}</p>)}</ContactInfo></ContactItem>)}List.Item = ItemContacts.List = ListContacts.Header = Headerexport default Contacts