Browse Source

add abilit yto change name and surename

unknown 2 years ago
parent
commit
1d641b7d4d
23 changed files with 112 additions and 92 deletions
  1. 1 1
      .eslintcache
  2. 25 3
      src/api-data/index.ts
  3. 2 2
      src/components/HomePage/LeftBar/MenuBar/index.tsx
  4. 2 2
      src/components/HomePage/LeftBar/SearchBar/index.tsx
  5. 1 1
      src/components/HomePage/LeftBar/SearchLists/index.tsx
  6. 4 7
      src/components/HomePage/LeftBar/SettingsBar/SettingsPicture/DeleteModal/index.tsx
  7. 16 15
      src/components/HomePage/LeftBar/SettingsBar/SettingsPicture/index.tsx
  8. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftAudio/index.tsx
  9. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftFile/index.tsx
  10. 4 4
      src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftImage/index.tsx
  11. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftText/index.tsx
  12. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftVideo/index.tsx
  13. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageRightAudio/index.tsx
  14. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageRightFile/index.tsx
  15. 4 4
      src/components/HomePage/RightBar/ChatBar/Messages/MessageRightImage/index.tsx
  16. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageRightText/index.tsx
  17. 3 3
      src/components/HomePage/RightBar/ChatBar/Messages/MessageRightVideo/index.tsx
  18. 24 24
      src/components/HomePage/RightBar/ChatBar/index.tsx
  19. 1 3
      src/components/HomePage/RightBar/RightListsAndBars/CredentialsList/ProfileLists/index.tsx
  20. 1 1
      src/components/HomePage/RightBar/RightListsAndBars/EditBar/index.tsx
  21. 1 1
      src/components/HomePage/RightBar/RightListsAndBars/SearchList/index.tsx
  22. 1 0
      src/typescript/redux/allMessages/types.ts
  23. 1 0
      src/typescript/redux/messages/types.ts

File diff suppressed because it is too large
+ 1 - 1
.eslintcache


+ 25 - 3
src/api-data/index.ts

@@ -81,7 +81,27 @@ const onlineUser = async <T>():Promise<T | undefined> => {
 
 const updateCredentials = async <T>(body:object):Promise<T | undefined> => {
   try {
-    const { data : {data} } = await axios.patch('/users/current', body);
+    const { data : {data} } = await axios.patch('/users/current/credentials', body);
+    return data
+  } catch (e) {
+    forbidden(e)
+    return undefined
+  }
+};
+
+const updateUser = async <T>(body:object):Promise<T | undefined> => {
+  try {
+    const { data : {data} } = await axios.patch('/users/current/update', body);
+    return data
+  } catch (e) {
+    forbidden(e)
+    return undefined
+  }
+};
+
+const removeUserAvatar = async <T>(index:number):Promise<T | undefined> => {
+  try {
+    const { data: { data } } = await axios.delete(`/users/current/${index}`);
     return data
   } catch (e) {
     forbidden(e)
@@ -129,9 +149,9 @@ const removeContact = async <T>(id:string): Promise<T | undefined> => {
   }
 };
 
-const updateContact = async <T>(id:string,_id:string,name:string,lastName:string): Promise<T | undefined> => {
+const updateContact = async <T>(id:string,_id:string,name:string,lastName:string,companionId:string): Promise<T | undefined> => {
   try {
-    const { data: { data } } = await axios.patch('/contacts', { id, _id, name, lastName });
+    const { data: { data } } = await axios.patch('/contacts', { id, _id, name, lastName,companionId });
     return data
   } catch (e) {
     forbidden(e)
@@ -318,6 +338,8 @@ export {
   logoutUser,
   onlineUser,
   updateCredentials,
+  updateUser,
+  removeUserAvatar,
   updateUserAvatar,
   currentUser,
   addContact,

+ 2 - 2
src/components/HomePage/LeftBar/MenuBar/index.tsx

@@ -13,7 +13,7 @@ import Switch from '@mui/material/Switch';
 import { makeStyles } from '@material-ui/core'
 import { useDispatch } from 'react-redux';
 import { asyncCurrentUser } from '../../../../redux/authorization/operations';
-import { updateCredentials } from '../../../../api-data';
+import { updateUser } from '../../../../api-data';
 
 const useStyles = makeStyles({
     overlay: {
@@ -59,7 +59,7 @@ const MenuBar = ({handleSelectedMenu,nightMode}:IContactsList) => {
   const classes = useStyles()
   const dispatch = useDispatch()
   const handleNightMode = () => {
-      updateCredentials({ nightMode: !nightMode })
+      updateUser({ nightMode: !nightMode })
       dispatch(asyncCurrentUser())
   }
   return (

+ 2 - 2
src/components/HomePage/LeftBar/SearchBar/index.tsx

@@ -9,7 +9,7 @@ import CalendarTodayIcon from '@mui/icons-material/CalendarToday';
 import { styled } from '@mui/material/styles';
 import { makeStyles } from '@material-ui/core'
 import { useDispatch } from 'react-redux';
-import { updateCredentials } from '../../../../api-data';
+import { updateUser } from '../../../../api-data';
 import { asyncCurrentUser } from '../../../../redux/authorization/operations';
 import StaticDatePicker from "./StaticDatePicker";
 
@@ -84,7 +84,7 @@ const SearchBar = ({ handleClick, handleFocus, handleSearch, isSearch,
   value, sort,setDate,date }: ISearchBar) => {
   const dispatch = useDispatch()
   const handleSort = () => {
-    updateCredentials({ sort: !sort })
+    updateUser({ sort: !sort })
     dispatch(asyncCurrentUser())
   }
   const handleOnOpen = () => setDate('')  

+ 1 - 1
src/components/HomePage/LeftBar/SearchLists/index.tsx

@@ -120,7 +120,7 @@ const SearchLists = ({ value,setValue,sort,date,setDate }: ISearchLists) => {
     }, [dispatch]);
   
     const filteredAndSorted = filteredChats(sortByRecent(chats,sort))
-    const allMessagesMemo = filteredMessages(handleSort('updatedAt',messagesMemo,sort))
+    const allMessagesMemo = filteredMessages(handleSort('createdAt',messagesMemo,sort))
   
     return (
     <>

+ 4 - 7
src/components/HomePage/LeftBar/SettingsBar/SettingsPicture/DeleteModal/index.tsx

@@ -1,7 +1,7 @@
 import Button from '@mui/material/Button';
 import { makeStyles } from '@material-ui/core'
 import { useDispatch } from 'react-redux';
-import { updateCredentials } from '../../../../../../api-data';
+import { removeUserAvatar } from '../../../../../../api-data';
 import { asyncCurrentUser } from '../../../../../../redux/authorization/operations';
 
 const useStyles = makeStyles({
@@ -38,19 +38,16 @@ const useStyles = makeStyles({
 
 interface IDeleteModal {
   setModal: (a: boolean) => void,
-  avatarsArr: { avatarUrl: string, updatedAt: string }[] | [],
-  index: number
+  index: number,
 }
-const DeleteModal = ({setModal,avatarsArr,index}:IDeleteModal) => {
+const DeleteModal = ({setModal,index}:IDeleteModal) => {
   const classes = useStyles()
   const dispatch = useDispatch()
   const handleDeleteModal = (e: any) => {
     const id = e.target.id
     if (id === 'overlay' || id === 'cancel') return setModal(false)
     if (id === 'delete') {
-      const toDelete = avatarsArr[index]
-      const filteredAvatars = [...avatarsArr].filter(({ avatarUrl }) => avatarUrl !== toDelete.avatarUrl)
-      updateCredentials({ avatarsArr:filteredAvatars,avatarUrl: filteredAvatars[0].avatarUrl})
+      removeUserAvatar(index)
       setModal(false)
       dispatch(asyncCurrentUser())
     }

+ 16 - 15
src/components/HomePage/LeftBar/SettingsBar/SettingsPicture/index.tsx

@@ -55,17 +55,17 @@ const useStyles = makeStyles({
     }
   },
   '@keyframes shake': {
-  '0%': { transform: 'translate(1px, 1px) rotate(0deg)'},
-  '10%': { transform: 'translate(-1px, -2px) rotate(-1deg)'},
-  '20%': { transform: 'translate(-3px, 0px) rotate(1deg)'},
-  '30%': { transform: 'translate(3px, 2px) rotate(0deg)'},
-  '40%': { transform: 'translate(1px, -1px) rotate(1deg)'},
-  '50%': { transform: 'translate(-1px, 2px) rotate(-1deg)'},
-  '60%': { transform: 'translate(-3px, 1px) rotate(0deg)'},
-  '70%': { transform: 'translate(3px, 1px) rotate(-1deg)'},
-  '80%': { transform: 'translate(-1px, -1px) rotate(1deg)'},
-  '90%': { transform: 'translate(1px, 2px) rotate(0deg)'},
-  '100%': { transform: 'translate(1px, -2px) rotate(-1deg)'},
+  '0%': { transform: 'translate(0.5px, 0.5px) rotate(0deg)'},
+  '10%': { transform: 'translate(-0.5px, -1px) rotate(-1deg)'},
+  '20%': { transform: 'translate(-1.5px, 0px) rotate(1deg)'},
+  '30%': { transform: 'translate(1.5px, 1px) rotate(0deg)'},
+  '40%': { transform: 'translate(0.5px, -0.5px) rotate(1deg)'},
+  '50%': { transform: 'translate(-0.5px, 1px) rotate(-1deg)'},
+  '60%': { transform: 'translate(-1.5px, 0.5px) rotate(0deg)'},
+  '70%': { transform: 'translate(1.5px, 0.5px) rotate(-1deg)'},
+  '80%': { transform: 'translate(-0.5px, -0.5px) rotate(1deg)'},
+  '90%': { transform: 'translate(0.5px, 1px) rotate(0deg)'},
+  '100%': { transform: 'translate(0.5px, -1px) rotate(-1deg)'},
 }  
 })
 
@@ -77,10 +77,10 @@ const SettingsPicture = () => {
   const handleClick = (): void => setModal(true)
   return (
     <div className={classes.container}>
-      {modal&&<DeleteModal setModal={setModal} avatarsArr={avatarsArr} index={index} />}
+      {modal&&<DeleteModal setModal={setModal} index={index}/>}
       <Carousel onChange={(i)=> setIndex(i)}>
         {avatarsArr.map(({ avatarUrl, updatedAt }) =>
-          <div>
+          <div key={avatarUrl}>
             <img alt='pic' src={`http://localhost:3000/${avatarUrl}`}/>
             <p className="legend">{timeStampEU(updatedAt)}</p>         
           </div>)}
@@ -88,13 +88,14 @@ const SettingsPicture = () => {
       <span className={classes.nameTile}>{`${firstLetter(name)}${slicedWord(name, 15, 1)}
         ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}</span>
       <span className={classes.timeTile}>{online === 'true' ? 'online' : `last seen ${timeStampEU(online)}`}</span>
-      <div className={classes.iconDeleteWrapper}>
+      {avatarsArr.length > 1 &&
+       <div className={classes.iconDeleteWrapper}>
         <Avatar className={classes.iconDelete} onClick={handleClick}
           sx={{width: 36, height: 36, backgroundColor: 'rgb(0,0,0)',
           color: '#ffffff', opacity: 0.5,cursor:'pointer'}}>
           <DeleteOutlineIcon fontSize='medium'/>  
         </Avatar>     
-      </div>
+      </div>}
     </div>
   )
 }

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftAudio/index.tsx

@@ -172,12 +172,12 @@ const useStyles = makeStyles({
 
 interface IMessageLeftAudio {
   url:string,
-  updatedAt: string,
+  createdAt: string,
   fullType: string,
   _id:string
 }
 
-const MessageLeftAudio = ({ url,updatedAt,fullType,_id }:IMessageLeftAudio) => {
+const MessageLeftAudio = ({ url,createdAt,fullType,_id }:IMessageLeftAudio) => {
   const classes = useStyles();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [selected, setSelected] = useState<boolean>(false);
@@ -217,7 +217,7 @@ const MessageLeftAudio = ({ url,updatedAt,fullType,_id }:IMessageLeftAudio) => {
         <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload}  >
             <FileDownloadIcon fontSize='medium'/>
         </IconButton>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftFile/index.tsx

@@ -189,12 +189,12 @@ const useStyles = makeStyles({
 
 interface IMessageLeftFile {
   url:string,
-  updatedAt: string,
+  createdAt: string,
   type: string,
   _id:string
 }
 
-const MessageLeftFile = ({ url,updatedAt,type,_id }:IMessageLeftFile) => {
+const MessageLeftFile = ({ url,createdAt,type,_id }:IMessageLeftFile) => {
   const classes = useStyles();
   const [read, setRead] = useState<boolean>(false)
   const [anchorEl, setAnchorEl] = useState<any>(null);
@@ -243,7 +243,7 @@ const MessageLeftFile = ({ url,updatedAt,type,_id }:IMessageLeftFile) => {
              <FileDownloadIcon fontSize='medium'/>
            </IconButton>
         </a>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 4 - 4
src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftImage/index.tsx

@@ -194,7 +194,7 @@ const useStyles = makeStyles({
 
 interface IMessagesLeftImage {
   url:string,
-  updatedAt:string,
+  createdAt:string,
   color: string,
   message: string,
   messages: any,
@@ -202,7 +202,7 @@ interface IMessagesLeftImage {
   _id:string
 }
 
-const MessagesLeftImage = ({url,updatedAt,color,message,messages,fullType,_id}:IMessagesLeftImage) => {
+const MessagesLeftImage = ({url,createdAt,color,message,messages,fullType,_id}:IMessagesLeftImage) => {
   const classes = useStyles();
   const [watch, setWatch] = useState<boolean>(false)
   const [anchorEl, setAnchorEl] = useState<any>(null);
@@ -245,7 +245,7 @@ const MessagesLeftImage = ({url,updatedAt,color,message,messages,fullType,_id}:I
           return acc
         },[]).map((el:any) => <div>
               <img alt='pic' src={`http://localhost:3000/${el.message}`}/>
-                <p className="legend">{timeStampFilter(el.updatedAt)}</p>
+                <p className="legend">{timeStampFilter(el.createdAt)}</p>
             </div>)}
        </Carousel>
     </div> :
@@ -258,7 +258,7 @@ const MessagesLeftImage = ({url,updatedAt,color,message,messages,fullType,_id}:I
         <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload}  >
             <FileDownloadIcon fontSize='medium'/>
         </IconButton>       
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftText/index.tsx

@@ -167,11 +167,11 @@ interface IMessageLeftText {
   message:string,
   name:string,
   lastName:string,
-  updatedAt: string,
+  createdAt: string,
   _id:string
 }
 
-const MessageLeftText = ({message,name,lastName,updatedAt,_id}:IMessageLeftText) => {
+const MessageLeftText = ({message,name,lastName,createdAt,_id}:IMessageLeftText) => {
   const classes = useStyles();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [selected, setSelected] = useState<boolean>(false);
@@ -213,7 +213,7 @@ const MessageLeftText = ({message,name,lastName,updatedAt,_id}:IMessageLeftText)
           primaryTypographyProps={{color: "#0379af"}}
           secondary={message}
           secondaryTypographyProps={{ color: "#0e0d0d" }} />
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={message}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageLeftVideo/index.tsx

@@ -176,12 +176,12 @@ const useStyles = makeStyles({
 
 interface IMessageLeftVideo {
   url:string,
-  updatedAt: string,
+  createdAt: string,
   fullType: string,
   _id:string
 }
 
-const MessageLeftVideo = ({ url,updatedAt,fullType,_id }:IMessageLeftVideo) => {
+const MessageLeftVideo = ({ url,createdAt,fullType,_id }:IMessageLeftVideo) => {
   const classes = useStyles();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [selected, setSelected] = useState<boolean>(false);
@@ -219,7 +219,7 @@ const MessageLeftVideo = ({ url,updatedAt,fullType,_id }:IMessageLeftVideo) => {
         <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload}  >
             <FileDownloadIcon fontSize='medium'/>
         </IconButton>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageRightAudio/index.tsx

@@ -171,12 +171,12 @@ const useStyles = makeStyles({
 
 interface IMessageRightAudio {
   url:string,
-  updatedAt: string,
+  createdAt: string,
   fullType: string,
   _id:string
 }
 
-const MessageRightAudio = ({ url,updatedAt,fullType,_id }:IMessageRightAudio) => {
+const MessageRightAudio = ({ url,createdAt,fullType,_id }:IMessageRightAudio) => {
   const classes = useStyles();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [selected, setSelected] = useState<boolean>(false);
@@ -215,7 +215,7 @@ const MessageRightAudio = ({ url,updatedAt,fullType,_id }:IMessageRightAudio) =>
         <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload}>
             <FileDownloadIcon fontSize='medium'/>
         </IconButton>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageRightFile/index.tsx

@@ -189,12 +189,12 @@ const useStyles = makeStyles({
 
 interface IMessageRightFile {
   url:string,
-  updatedAt: string,
+  createdAt: string,
   type: string,
   _id:string
 }
 
-const MessageRightFile = ({ url,updatedAt,type,_id }:IMessageRightFile) => {
+const MessageRightFile = ({ url,createdAt,type,_id }:IMessageRightFile) => {
   const classes = useStyles();
   const [read, setRead] = useState<boolean>(false)
   const [anchorEl, setAnchorEl] = useState<any>(null);
@@ -243,7 +243,7 @@ const MessageRightFile = ({ url,updatedAt,type,_id }:IMessageRightFile) => {
              <FileDownloadIcon fontSize='medium'/>
            </IconButton>
         </a>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 4 - 4
src/components/HomePage/RightBar/ChatBar/Messages/MessageRightImage/index.tsx

@@ -194,7 +194,7 @@ const useStyles = makeStyles({
 
 interface IMessageRightImage {
   url:string,
-  updatedAt:string,
+  createdAt:string,
   color: string,
   message: string,
   messages: any,
@@ -202,7 +202,7 @@ interface IMessageRightImage {
   _id:string
 }
 
-const MessageRightImage = ({url,updatedAt,color,message,messages,fullType,_id}:IMessageRightImage) => {
+const MessageRightImage = ({url,createdAt,color,message,messages,fullType,_id}:IMessageRightImage) => {
   const classes = useStyles();
   const [watch, setWatch] = useState<boolean>(false)
   const [anchorEl, setAnchorEl] = useState<any>(null);
@@ -245,7 +245,7 @@ const MessageRightImage = ({url,updatedAt,color,message,messages,fullType,_id}:I
           return acc
         },[]).map((el:any) => <div>
               <img alt='pic' src={`http://localhost:3000/${el.message}`}/>
-                <p className="legend">{timeStampFilter(el.updatedAt)}</p>
+                <p className="legend">{timeStampFilter(el.createdAt)}</p>
             </div>)}
        </Carousel>
     </div> :
@@ -258,7 +258,7 @@ const MessageRightImage = ({url,updatedAt,color,message,messages,fullType,_id}:I
         <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload}>
             <FileDownloadIcon fontSize='medium'/>
         </IconButton>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageRightText/index.tsx

@@ -166,11 +166,11 @@ interface IMessageRightText {
   message:string,
   name:string,
   lastName:string,
-  updatedAt: string,
+  createdAt: string,
   _id:string
 }
 
-const MessageRightText = ({message,name,lastName,updatedAt,_id}:IMessageRightText) => {
+const MessageRightText = ({message,name,lastName,createdAt,_id}:IMessageRightText) => {
   const classes = useStyles();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [selected, setSelected] = useState<boolean>(false);
@@ -212,7 +212,7 @@ const MessageRightText = ({message,name,lastName,updatedAt,_id}:IMessageRightTex
           primaryTypographyProps={{color: "#42aee0"}}
           secondary={message}
           secondaryTypographyProps={{ color: "#0e0d0d" }} />
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={message}>

+ 3 - 3
src/components/HomePage/RightBar/ChatBar/Messages/MessageRightVideo/index.tsx

@@ -177,12 +177,12 @@ const useStyles = makeStyles({
 
 interface IMessageRightVideo {
   url:string,
-  updatedAt: string,
+  createdAt: string,
   fullType: string,
   _id:string
 }
 
-const MessageRightVideo = ({ url,updatedAt,fullType,_id }:IMessageRightVideo) => {
+const MessageRightVideo = ({ url,createdAt,fullType,_id }:IMessageRightVideo) => {
   const classes = useStyles();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [selected, setSelected] = useState<boolean>(false);
@@ -219,7 +219,7 @@ const MessageRightVideo = ({ url,updatedAt,fullType,_id }:IMessageRightVideo) =>
         <IconButton onClick={() => handleDownload(url, fullType)} className={classes.bntDownload}>
             <FileDownloadIcon fontSize='medium'/>
         </IconButton>
-        <div className={classes.time}>{timeStampMessage(updatedAt)}</div>
+        <div className={classes.time}>{timeStampMessage(createdAt)}</div>
       <StyledMenu id="demo-positioned-menu" aria-labelledby="demo-positioned-button"
         anchorEl={anchorEl} open={open} onClose={handleClose}>        
         <CopyToClipboard onCopy={() => handleClose('copy')} text={url}>

+ 24 - 24
src/components/HomePage/RightBar/ChatBar/index.tsx

@@ -115,31 +115,31 @@ const ChatBar = () => {
         className={messages.length > 0 ? classes.messagesScroll : classes.messagesEmpty}>
         <div className={classes.messagesBody}>
         {messages.length > 0 ? messages.map(({ message, name, lastName, color,
-          updatedAt, createdAt,number, type,fullType,_id }) => {
+           createdAt,number, type,fullType,_id }) => {
           let isTime
           if (!time) {
             isTime = true
-            time = updatedAt
-          } else if (timeStampFilter(time) !== timeStampFilter(updatedAt)) {
-            time = updatedAt
+            time = createdAt
+          } else if (timeStampFilter(time) !== timeStampFilter(createdAt)) {
+            time = createdAt
             isTime = true
           }
           const url = `http://localhost:3000/${message}`
           if (number !== userNumber) {
             if (type === 'text') return (<div key={createdAt}>
-              {isTime&&<MessageTime  message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime  message={timeStampFilter(createdAt)}/>}
                <MessageLeftText
                message={message}
-               updatedAt={updatedAt}
+               createdAt={createdAt}
                name={name}
                lastName={lastName}
                _id={_id}
                  /></div>)
             if (type === 'image') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageLeftImage   
                 url={url}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 color={color}
                 message={message}
                 messages={messages}
@@ -147,44 +147,44 @@ const ChatBar = () => {
                 _id={_id}
                   /></div>)
             if (type === 'audio') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageLeftAudio    
                 url={url}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 fullType={fullType}
                 _id={_id}
                   /></div>)
             if (type === 'video') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageLeftVideo    
                 url={url}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 fullType={fullType}
                 _id={_id}
                   /></div>)
             if (type) return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageLeftFile   
                 url={url}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 type={type}
                 _id={_id}
                   /></div>)             
           } else {
             if (type === 'text') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageRightText   
                 message={message}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 name={name}
                 lastName={lastName}
                 _id={_id}
                   /></div>)
             if (type === 'image') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageRightImage   
                 url={url}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 color={color}
                 message={message}
                 messages={messages}
@@ -192,26 +192,26 @@ const ChatBar = () => {
                 _id={_id}
                   /></div>)
             if (type === 'audio') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                 <MessageRightAudio    
                 url={url}
-                updatedAt={updatedAt}
+                createdAt={createdAt}
                 fullType={fullType}
                 _id={_id}
                   /></div>)
             if (type === 'video') return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                  <MessageRightVideo  
                  url={url}
-                 updatedAt={updatedAt}
+                 createdAt={createdAt}
                  fullType={fullType}
                  _id={_id}
                    /></div>)
             if (type) return (<div key={createdAt}>
-              {isTime&&<MessageTime message={timeStampFilter(updatedAt)}/>}
+              {isTime&&<MessageTime message={timeStampFilter(createdAt)}/>}
                  <MessageRightFile  
                  url={url}
-                 updatedAt={updatedAt}
+                 createdAt={createdAt}
                  type={type}
                  _id={_id}
                    /></div>)            

+ 1 - 3
src/components/HomePage/RightBar/RightListsAndBars/CredentialsList/ProfileLists/index.tsx

@@ -50,9 +50,7 @@ const ProfileLists = () => {
     const messagesMemo = useSelector(getMessagesMemo)
     const [isActive, setIsActive] = useState<number>(0)
     const handleIsActive = (newValue: number): void => setIsActive(newValue)
-  const sortedMessages: TMessages = handleSort('updatedAt', messagesMemo, sort)
-  //  const messages = useSelector(getMessages)
-  //const disabled = messages.length > 0 ? false : true
+    const sortedMessages: TMessages = handleSort('createdAt', messagesMemo, sort)
     return (
     <>
         <div className={classes.container}>

+ 1 - 1
src/components/HomePage/RightBar/RightListsAndBars/EditBar/index.tsx

@@ -33,7 +33,7 @@ const EditBar= () => {
       muteChat(companionId)
     }
     if (name !== Name || lastName !== LastName) {
-      updateContact(isContact._id,_id,name,lastName)
+      updateContact(isContact._id,_id,name,lastName,companionId)
     }    
     openBtn&&setOpenBtn(false)
   }

+ 1 - 1
src/components/HomePage/RightBar/RightListsAndBars/SearchList/index.tsx

@@ -47,7 +47,7 @@ const SearchList= () => {
         return el
       }
     })
-  const arr:TMessages =  filteredMessages(handleSort('updatedAt',messages,sort))
+  const arr:TMessages =  filteredMessages(handleSort('createdAt',messages,sort))
 return (
    <div className={classes.container}>
     <Search handleSearch={handleSearch} value={value}

+ 1 - 0
src/typescript/redux/allMessages/types.ts

@@ -9,6 +9,7 @@ export type TMessage = {
   type: string,
   fullType:string,
   companionId: string,
+  companionIdFlow: string,
   idTime: string,
   owner: any,
   createdAt: string,

+ 1 - 0
src/typescript/redux/messages/types.ts

@@ -10,6 +10,7 @@ export type TMessage = {
   fullType: string,
   idTime: string,
   companionId: string,
+  companionIdFlow: string,
   owner: any,
   createdAt: string,
   updatedAt: string,