index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import List from '@mui/material/List';
  2. import { makeStyles } from '@material-ui/core'
  3. import AlertInfo from '../../../../../../reusableComponents/AlertInfo'
  4. import ForwardItem from './ForwardItem'
  5. import { TChats } from '../../../../../../../typescript/redux/chats/types';
  6. const useStyles = makeStyles({
  7. list: {
  8. width: '100%',
  9. maxHeight: '63vh',
  10. overflowY: 'scroll',
  11. '&::-webkit-scrollbar': {
  12. width: '0.4em'
  13. },
  14. '&::-webkit-scrollbar-track': {
  15. boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  16. webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  17. backgroundColor: '#eceeec',
  18. },
  19. '&::-webkit-scrollbar-thumb': {
  20. backgroundColor: '#ccc8c8',
  21. },
  22. "&::-webkit-scrollbar-thumb:focus": {
  23. backgroundColor: "#959595",
  24. },
  25. "&::-webkit-scrollbar-thumb:active": {
  26. backgroundColor: "#959595",
  27. },
  28. },
  29. })
  30. interface IForwardList {
  31. value: string,
  32. date:string,
  33. filteredAndSorted:TChats,
  34. handleForwardTo: (companionId: string) => void,
  35. }
  36. const ForwardList = ({ value,date,filteredAndSorted,handleForwardTo }: IForwardList) => {
  37. const classes = useStyles()
  38. return <>
  39. <List className={classes.list} component="nav"
  40. aria-label="main mailbox folders">
  41. {filteredAndSorted.map(({ name, lastName, avatarUrl, color, online, companionId, number }) =>
  42. <ForwardItem key={number} name={name} lastName={lastName}
  43. avatarUrl={avatarUrl} color={color} online={online}
  44. companionId={companionId} handleForwardTo={handleForwardTo} />)}
  45. {(value || date) && filteredAndSorted.length === 0 && <AlertInfo name={`Can not find Chat by request: ${value}`} />}
  46. {!value && !date && filteredAndSorted.length === 0 &&<AlertInfo name='You do not have any Chats yet!'/>}
  47. </List>
  48. </>
  49. }
  50. export default ForwardList