File size: 1,099 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Box } from '@chakra-ui/react';
import React from 'react';
import { useSelector } from 'react-redux';
import { useAuth } from '../../context/auth';
import Card from './Card';
import NoDataMessage from './NoDataMessage';

const FollowingUser = () => {
   const user = useAuth();
   const { profileData } = useSelector((state) => state.profileData);

   const followingUsers = profileData?.filter((userData) =>
      userData.followers?.includes(user.userId)
   );

   if (!followingUsers.length) {
      return <NoDataMessage title={`You don't follow any users`} />;
   }

   return (
      <Box
         display='grid'
         gridTemplateColumns={{
            sm: 'repeat(2, minmax(0, 1fr))',
            lg: 'repeat(3, minmax(0, 1fr))',
         }}
         gap={{ sm: '.7rem' }}
      >
         {followingUsers.map((userData) => (
            <Card
               key={userData.id}
               name={userData.name}
               username={userData.username}
               profile={userData.profile}
            />
         ))}
      </Box>
   );
};

export default FollowingUser;