index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { makeStyles } from '@material-ui/core'
  2. import List from '@mui/material/List';
  3. import Stack from '@mui/material/Stack';
  4. import { TChats } from '../../../../../typescript/redux/chats/types';
  5. import RecentItem from './RecentItem';
  6. import ChatItem from './ChatItem';
  7. import AlertInfo from '../../../../reusableComponents/AlertInfo';
  8. const useStyles = makeStyles({
  9. stack: {
  10. display: 'flex',
  11. justifyContent: 'space-around',
  12. paddingTop:20,
  13. },
  14. container: {
  15. width: '100%',
  16. maxHeight: '88vh',
  17. overflowY: 'scroll',
  18. position: 'absolute',
  19. animationDuration: '0.2s',
  20. animationDirection: 'normal',
  21. animation: `$moveElement`,
  22. '&::-webkit-scrollbar': {
  23. width: '0.4em'
  24. },
  25. '&::-webkit-scrollbar-track': {
  26. boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  27. webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
  28. backgroundColor: '#eceeec',
  29. },
  30. '&::-webkit-scrollbar-thumb': {
  31. backgroundColor: '#ccc8c8',
  32. },
  33. "&::-webkit-scrollbar-thumb:focus": {
  34. backgroundColor: "#959595",
  35. },
  36. "&::-webkit-scrollbar-thumb:active": {
  37. backgroundColor: "#959595",
  38. },
  39. },
  40. '@keyframes moveElement': {
  41. '0%': { left: '-100%'},
  42. '100%': { left: '0%'},
  43. },
  44. })
  45. interface IChatListRecent {
  46. value: string,
  47. date:any,
  48. filteredAndSortedChats: TChats,
  49. handleListItemClick: (companionId: string) => void,
  50. }
  51. const ChatListRecent = ({value,date,filteredAndSortedChats,handleListItemClick}:IChatListRecent) => {
  52. const classes = useStyles()
  53. return (
  54. <>
  55. {!value && !date && filteredAndSortedChats.length > 0 &&
  56. <Stack direction="row" className={classes.stack}>
  57. {filteredAndSortedChats.slice(0, 6).map((chat) =>
  58. <RecentItem key={chat.companionId} handleListItemClick={handleListItemClick} chat={chat} />)}
  59. </Stack>}
  60. {(value || date) && filteredAndSortedChats.length > 0 &&
  61. <List className={classes.container} component="nav" aria-label="main mailbox folders">
  62. {filteredAndSortedChats.map((chat) =>
  63. <ChatItem key={chat.companionId} handleListItemClick={handleListItemClick} chat={chat} />)}
  64. </List>}
  65. {(value || date) && filteredAndSortedChats.length === 0 && <AlertInfo name={`Can not find Chat by request: ${value}`} />}
  66. {!value && !date && filteredAndSortedChats.length === 0 &&<AlertInfo name='You do not have any Chats yet!'/>}
  67. </>)
  68. }
  69. export default ChatListRecent