|
@@ -12,8 +12,10 @@ import ListItemText from '@mui/material/ListItemText';
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
import Badge from '@mui/material/Badge';
|
|
import Badge from '@mui/material/Badge';
|
|
import DoneAllIcon from '@mui/icons-material/DoneAll';
|
|
import DoneAllIcon from '@mui/icons-material/DoneAll';
|
|
|
|
+import PushPinIcon from '@mui/icons-material/PushPin';
|
|
|
|
+import CloseIcon from '@mui/icons-material/Close';
|
|
|
|
|
|
-import { muteChat } from '../../../../../api-data';
|
|
|
|
|
|
+import { muteChat,pinChat } from '../../../../../api-data';
|
|
import { TChat } from '../../../../../typescript/redux/chats/types';
|
|
import { TChat } from '../../../../../typescript/redux/chats/types';
|
|
import { firstLetter, slicedWord, timeStampEU,prodAwsS3 } from '../../../../../helpers';
|
|
import { firstLetter, slicedWord, timeStampEU,prodAwsS3 } from '../../../../../helpers';
|
|
import DeleteModal from './DeleteModal';
|
|
import DeleteModal from './DeleteModal';
|
|
@@ -126,7 +128,7 @@ const useStyles = makeStyles({
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
alignContent: 'center',
|
|
alignContent: 'center',
|
|
fontSize: 12,
|
|
fontSize: 12,
|
|
- marginLeft: 'auto',
|
|
|
|
|
|
+ marginLeft: 10,
|
|
'&:hover': {
|
|
'&:hover': {
|
|
outline: 'solid 3px #3ee415',
|
|
outline: 'solid 3px #3ee415',
|
|
}
|
|
}
|
|
@@ -144,24 +146,21 @@ const useStyles = makeStyles({
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
alignContent: 'center',
|
|
alignContent: 'center',
|
|
fontSize: 12,
|
|
fontSize: 12,
|
|
- marginLeft: 'auto',
|
|
|
|
|
|
+ marginLeft: 10,
|
|
'&:hover': {
|
|
'&:hover': {
|
|
outline: 'solid 3px #cccbcb',
|
|
outline: 'solid 3px #cccbcb',
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- listItem_iconRightBtnHidden: {
|
|
|
|
- background: 'inherit',
|
|
|
|
- borderRadius: '50%',
|
|
|
|
- border: 'none',
|
|
|
|
- height: 24,
|
|
|
|
- width: 24,
|
|
|
|
- textAlign: 'center',
|
|
|
|
|
|
+ pinnedIcon: {
|
|
|
|
+ transform: 'rotate(45deg)',
|
|
|
|
+ color: '#a7aaa7',
|
|
|
|
+ },
|
|
|
|
+ listIconsRightContainer: {
|
|
|
|
+ marginLeft: 'auto',
|
|
display: 'flex',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
alignContent: 'center',
|
|
alignContent: 'center',
|
|
- fontSize: 12,
|
|
|
|
- marginLeft: 'auto',
|
|
|
|
},
|
|
},
|
|
listItem_icon_time: {
|
|
listItem_icon_time: {
|
|
fontSize: 12,
|
|
fontSize: 12,
|
|
@@ -185,14 +184,22 @@ const useStyles = makeStyles({
|
|
clipPath: 'inset(0 -1ch 0 0)'
|
|
clipPath: 'inset(0 -1ch 0 0)'
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ iconClose: {
|
|
|
|
+ '&:hover': {
|
|
|
|
+ transform: 'rotate(180deg)',
|
|
|
|
+ transition: 'all 250ms ease-out ',
|
|
|
|
+ }
|
|
|
|
+ },
|
|
})
|
|
})
|
|
|
|
|
|
interface IChatItem {
|
|
interface IChatItem {
|
|
chat: TChat,
|
|
chat: TChat,
|
|
handleListItemClick: (companionId: string) => void,
|
|
handleListItemClick: (companionId: string) => void,
|
|
- handleNewMsgs: (e: any,companionId: string) => void,
|
|
|
|
|
|
+ handleNewMsgs: (e: any, companionId: string) => void,
|
|
|
|
+ id: string,
|
|
|
|
+ pinned:boolean,
|
|
}
|
|
}
|
|
-const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
|
|
|
|
+const ChatItem = ({chat,handleListItemClick,handleNewMsgs,id,pinned}:IChatItem) => {
|
|
const classes = useStyles()
|
|
const classes = useStyles()
|
|
const [anchorEl, setAnchorEl] = useState<any>(null);
|
|
const [anchorEl, setAnchorEl] = useState<any>(null);
|
|
const [selected, setSelected] = useState<boolean>(false);
|
|
const [selected, setSelected] = useState<boolean>(false);
|
|
@@ -201,6 +208,10 @@ const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
const { name, lastName, avatarUrl, color, companionId, mute, seen, total, watched,
|
|
const { name, lastName, avatarUrl, color, companionId, mute, seen, total, watched,
|
|
typing, online, lastMessage, lastMessageCreatedAt, createdAt } = chat
|
|
typing, online, lastMessage, lastMessageCreatedAt, createdAt } = chat
|
|
|
|
|
|
|
|
+ const handlePin = (id: string, pinned:boolean) => {
|
|
|
|
+ pinChat(id,!pinned)
|
|
|
|
+ handleClose(undefined)
|
|
|
|
+ }
|
|
const handleClose = (type: string | undefined): void => {
|
|
const handleClose = (type: string | undefined): void => {
|
|
if (type === 'mute') muteChat(companionId)
|
|
if (type === 'mute') muteChat(companionId)
|
|
if (type === 'delete') setModal(true)
|
|
if (type === 'delete') setModal(true)
|
|
@@ -244,10 +255,15 @@ const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
<Typography className={classes.listItem_icon_time} variant="h6" color="initial">
|
|
<Typography className={classes.listItem_icon_time} variant="h6" color="initial">
|
|
{timeStampEU(lastMessageCreatedAt?lastMessageCreatedAt:createdAt)}
|
|
{timeStampEU(lastMessageCreatedAt?lastMessageCreatedAt:createdAt)}
|
|
</Typography>
|
|
</Typography>
|
|
- </div>
|
|
|
|
- {lastMessage && total > seen ? <button onClick={(e) => handleNewMsgs(e,companionId)}
|
|
|
|
- className={mute?classes.listItem_iconRightBtnMute:classes.listItem_iconRightBtn}>{total-seen}</button> :
|
|
|
|
- <button className={classes.listItem_iconRightBtnHidden}/>}
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div className={classes.listIconsRightContainer}>
|
|
|
|
+ {pinned && <PushPinIcon className={classes.pinnedIcon} fontSize='small' />}
|
|
|
|
+ {lastMessage && total > seen &&
|
|
|
|
+ <button onClick={(e) => handleNewMsgs(e, companionId)}
|
|
|
|
+ className={mute ? classes.listItem_iconRightBtnMute : classes.listItem_iconRightBtn}>
|
|
|
|
+ {total - seen}
|
|
|
|
+ </button>}
|
|
|
|
+ </div>
|
|
</ListItemIcon>
|
|
</ListItemIcon>
|
|
</ListItemButton>
|
|
</ListItemButton>
|
|
<StyledMenu
|
|
<StyledMenu
|
|
@@ -261,6 +277,12 @@ const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
{mute ? <NotificationsNoneIcon /> : <VolumeOffIcon />}
|
|
{mute ? <NotificationsNoneIcon /> : <VolumeOffIcon />}
|
|
{mute ? 'Unmute chat':'Mute chat'}
|
|
{mute ? 'Unmute chat':'Mute chat'}
|
|
</MenuItem>
|
|
</MenuItem>
|
|
|
|
+ <MenuItem onClick={() => handlePin(id,pinned)}>
|
|
|
|
+ {pinned ?
|
|
|
|
+ <CloseIcon className={classes.iconClose} /> :
|
|
|
|
+ <PushPinIcon />}
|
|
|
|
+ {pinned?'Unpin chat':'Pin chat'}
|
|
|
|
+ </MenuItem>
|
|
<MenuItem style={{color:'#f02a2a'}} onClick={() => handleClose('delete')}>
|
|
<MenuItem style={{color:'#f02a2a'}} onClick={() => handleClose('delete')}>
|
|
<DeleteOutlineIcon style={{color:'#f02a2a'}}/>
|
|
<DeleteOutlineIcon style={{color:'#f02a2a'}}/>
|
|
Delete chat
|
|
Delete chat
|