Skip to content

Commit

Permalink
feat: add button redirect to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Barresi committed Apr 22, 2024
1 parent 4fb1638 commit 9b85303
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/entities/card-friends/ui/card-friends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const CardFriends: FC<ICardFriendsProps> = ({
{info}
</div>
<div className='mt-[10px] lg:max-w-[485px] whitespace-nowrap flex justify-between gap-[10px]'>
{isMine || children}
{children}
</div>
</Card>
)
Expand All @@ -81,7 +81,7 @@ const CardFriends: FC<ICardFriendsProps> = ({
{info}

<div className='mt-[15px] max-w-[485px] whitespace-nowrap flex justify-between gap-[10px]'>
{isMine || children}
{children}
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/features/button-redirect-profile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ButtonRedirectProfile } from './ui/button-redirect-profile'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { selectUser } from '@app/store/reducers/profileInfo/selectors'
import { useAppSelector } from '@shared/lib/hooks/store-hooks'
import { Button } from '@shared/ui/button'
import { type FC } from 'react'
import { useNavigate } from 'react-router-dom'

interface IButtonRedirectProfileProps {
className?: string
}
const ButtonRedirectProfile: FC<IButtonRedirectProfileProps> = ({ className }) => {
const navigate = useNavigate()
const user = useAppSelector(selectUser)
return (
<Button
className={className}
variant='outline'
onClick={() => {
navigate(`/main/users/${user?.id}`)
}}
>
Моя страница
</Button>
)
}
export { ButtonRedirectProfile }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CardFriends } from '@entities/card-friends/ui/card-friends'
import { ButtonRedirectProfile } from '@features/button-redirect-profile'
import { ButtonsFriendActions } from '@features/buttons-friend-actions/buttons-friend-actions'
import { useAppSelector } from '@shared/lib/hooks/store-hooks'
import { FriendTabs } from '@shared/lib/types/other'
Expand All @@ -24,14 +25,19 @@ const TabAllUsers: FC<ITabAllUsersProps> = ({ search }) => {
.filter((item) => filterUsers(item, search))
.map((friend, index) => {
if (!user?.id) return null
const isMine = friend.id === user?.id
return (
<CardFriends
key={index}
type={FriendTabs.ALL}
friendId={friend.id}
isMine={friend.id === user?.id}
isMine={isMine}
>
<ButtonsFriendActions friendId={friend.id} />
{isMine ? (
<ButtonRedirectProfile className='sm:w-[49%]' />
) : (
<ButtonsFriendActions friendId={friend.id} />
)}
</CardFriends>
)
})}
Expand Down

0 comments on commit 9b85303

Please sign in to comment.