import React from 'react'; import { Box, Flex } from '@chakra-ui/react'; import { IInfoProps, Info } from './Info'; import { ITimeProps, Time } from './Time'; import { IAvatarProps, Avatar } from './Avatar'; /** * Hooks */ import { useHistory, useLocation } from 'react-router-dom'; import { useColorModeValue } from '@chakra-ui/react'; interface IUserComposition { Avatar: React.FC; Info: React.FC; Time: React.FC; } interface IUserProps { id: string; } const User: React.FC & IUserComposition = props => { const history = useHistory(); const location = useLocation(); const chatId = new URLSearchParams(location.search).get('chat_id'); const bg = useColorModeValue('gray.50', 'gray.700'); const handleChat = () => { history.replace({ pathname: location.pathname, search: new URLSearchParams({ ['chat_id']: props.id }).toString() }); }; return ( {props.children} ); }; User.Avatar = Avatar; User.Info = Info; User.Time = Time; export { User };