1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import List from '@mui/material/List';
- import ListItem from '@mui/material/ListItem';
- import ListItemText from '@mui/material/ListItemText';
- import ListItemAvatar from '@mui/material/ListItemAvatar';
- import Avatar from '@mui/material/Avatar';
- import Divider from '@mui/material/Divider';
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
- import { makeStyles } from '@material-ui/core'
- import AlertInfo from '../../../../reusableComponents/AlertInfo';
- import { timeStampEU,firstLetter,prodAwsS3 } from '../../../../../helpers'
- import { TAllMessages } from '../../../../../typescript/redux/allMessages/types'
- const useStyles = makeStyles({
- container: {
- width: '100%',
- maxHeight: '88vh',
- overflowY: 'scroll',
- position: 'absolute',
- animationDuration: '0.2s',
- animationDirection: 'normal',
- animation: `$moveElement`,
- '&::-webkit-scrollbar': {
- width: '0.4em'
- },
- '&::-webkit-scrollbar-track': {
- boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
- webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
- backgroundColor: '#eceeec',
- },
- '&::-webkit-scrollbar-thumb': {
- backgroundColor: '#ccc8c8',
- },
- "&::-webkit-scrollbar-thumb:focus": {
- backgroundColor: "#959595",
- },
- "&::-webkit-scrollbar-thumb:active": {
- backgroundColor: "#959595",
- },
- },
- listItem: {
- cursor:'pointer',
- '&:hover': {
- backgroundColor: '#f0f0f0',
- }
- },
- folderIcon: {
- margin: 'auto 0px',
- color: 'rgba(0, 0, 0, 0.5)',
- },
- '@keyframes moveElement': {
- '0%': { left: '-100%'},
- '100%': { left: '0%'},
- },
- })
- interface ITextList {
- filteredAndSortedMessages: TAllMessages,
- value: string,
- date: any,
- handleScrollToTheMessage:(_id:string,companionId:string) => void
- }
- const TextList = ({ filteredAndSortedMessages,value,date,handleScrollToTheMessage }: ITextList) => {
- const classes = useStyles()
-
- return (
- <>
- {filteredAndSortedMessages.length > 0 &&
- <List className={classes.container}>
- {filteredAndSortedMessages.map(({ message, createdAt, lastName, name, color, avatarUrl,_id,companionId }) =>
- <div key={createdAt}>
- <ListItem onClick={() => handleScrollToTheMessage(_id,companionId)}
- alignItems="flex-start" className={classes.listItem}>
- <ListItemAvatar>
- <Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
- sx={{ background: color, width: 40, height: 40}}>
- {`${firstLetter(name)}${firstLetter(lastName)}`}
- </Avatar>
- </ListItemAvatar>
- <ListItemText style={{ wordBreak: 'break-word',marginRight:2 }} primary={message}
- secondary={timeStampEU(createdAt)} secondaryTypographyProps={{color: '#020202',paddingTop:0.5}}
- />
- <ContentCopyIcon className={classes.folderIcon} fontSize='large' />
- </ListItem>
- <Divider variant="inset" />
- </div>)}
- </List>}
- {(value || date) && filteredAndSortedMessages.length === 0 && <AlertInfo name={`Can not find Text by request: ${value}`} />}
- {!value && !date && filteredAndSortedMessages.length === 0 && <AlertInfo name='You do not have Text yet!'/>}
- </>
- )
- }
- export default TextList
|