-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from Chat-Your-Way/CHAT-236-Interface-for-non-…
…authenticated-user Chat 236 interface for non authenticated user
- Loading branch information
Showing
14 changed files
with
215 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-disable no-unused-vars */ | ||
import { useSelector } from 'react-redux'; | ||
import { useGetSubscribersQuery } from '../../../redux/topics-operations'; | ||
// eslint-disable-next-line max-len | ||
import { selectAccessToken } from '../../../redux/authOperatonsToolkit/authOperationsThunkSelectors'; | ||
import { Avatars } from '../../../ui-kit/images/avatars'; | ||
import Avatar from '../../../ui-kit/components/Avatar'; | ||
|
||
import { getUserInfo } from '../../../redux/userSlice'; | ||
import { useMediaQuery } from 'react-responsive'; | ||
import { | ||
UsersAvatarStyledList, | ||
UsersAvatarStyledWrapper, | ||
UsersAvatarStyledLi, | ||
} from './UsersAvatarStyled'; | ||
import { memo } from 'react'; | ||
|
||
const UsersAvatar = ({ topicId }) => { | ||
const accessTokenInStore = useSelector(selectAccessToken); | ||
const isTablet = useMediaQuery({ query: '(min-width: 768px' }); | ||
const isDesktop = useMediaQuery({ query: '(mint-width: 1200px)' }); | ||
|
||
const { | ||
isLoading, | ||
isError, | ||
error, | ||
data: usersSubscribers, | ||
} = useGetSubscribersQuery({ topicId, accessTokenInStore }); | ||
|
||
return ( | ||
<UsersAvatarStyledWrapper> | ||
<UsersAvatarStyledList> | ||
{usersSubscribers | ||
? // ? usersSubscribers.map(user => ( | ||
// <UsersAvatarStyledLi key={user.id}> | ||
// {Object.values(Avatars).map( | ||
// (Logo, index) => | ||
// user.avatarId - 1 === index && ( | ||
// <Avatar size={isTablet ? 'md' : 'sm'} key={index} isCurrent={'true'}> | ||
// <Logo /> | ||
// </Avatar> | ||
// ) | ||
// )} | ||
// </UsersAvatarStyledLi> | ||
// )) | ||
usersSubscribers.reduce((acuum, user, index, array) => { | ||
if (index === 4) { | ||
return [ | ||
...acuum, | ||
<UsersAvatarStyledLi | ||
key={user.id} | ||
$left={index === 0 ? 0 : index * (isTablet ? 30 : 10)} | ||
$width={isTablet ? '180px' : isDesktop ? '220px' : '94px'} | ||
> | ||
<Avatar | ||
size={isTablet ? 'md' : 'sm'} | ||
key={index} | ||
isCurrent={'true'} | ||
> | ||
{usersSubscribers.length} | ||
</Avatar> | ||
</UsersAvatarStyledLi>, | ||
]; | ||
} | ||
|
||
acuum.push( | ||
<UsersAvatarStyledLi | ||
key={user.id} | ||
$left={index === 0 ? 0 : index * (isTablet ? 30 : 10)} | ||
> | ||
{Object.values(Avatars).map( | ||
(Logo, index) => | ||
user.avatarId - 1 === index && ( | ||
<Avatar | ||
size={isTablet ? 'md' : 'sm'} | ||
key={index} | ||
isCurrent={'true'} | ||
> | ||
<Logo /> | ||
</Avatar> | ||
), | ||
)} | ||
</UsersAvatarStyledLi>, | ||
); | ||
|
||
return acuum; | ||
}, []) | ||
: null} | ||
</UsersAvatarStyledList> | ||
</UsersAvatarStyledWrapper> | ||
); | ||
}; | ||
|
||
export default memo(UsersAvatar); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const UsersAvatarStyledWrapper = styled.div` | ||
justify-self: right; | ||
/* display: flex; */ | ||
`; | ||
|
||
export const UsersAvatarStyledList = styled.ul` | ||
position: relative; | ||
display: flex; | ||
justify-content: right; | ||
/* flex-direction: row-reverse; */ | ||
margin: 0; | ||
padding: 0; | ||
width: 94px; | ||
list-style: none; | ||
@media screen and (min-width: 768px) { | ||
width: 180px; | ||
} | ||
@media screen and (min-width: 1200px) { | ||
width: 220px; | ||
} | ||
`; | ||
|
||
export const UsersAvatarStyledLi = styled.li` | ||
position: relative; | ||
position: absolute; | ||
left: ${(p) => `${p.$left}px`}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './UsersAvatar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.