import type { CardProps } from '@mui/material/Card'; import type { IUserProfileFollower } from 'src/types/user'; import { useState, useCallback } from 'react'; import Box from '@mui/material/Box'; import Card from '@mui/material/Card'; import Button from '@mui/material/Button'; import Avatar from '@mui/material/Avatar'; import Typography from '@mui/material/Typography'; import ListItemText from '@mui/material/ListItemText'; import { Iconify } from 'src/components/iconify'; // ---------------------------------------------------------------------- type Props = { followers: IUserProfileFollower[]; }; export function ProfileFollowers({ followers }: Props) { const _mockFollowed = followers.slice(4, 8).map((i) => i.id); const [followed, setFollowed] = useState(_mockFollowed); const handleClick = useCallback( (item: string) => { const selected = followed.includes(item) ? followed.filter((value) => value !== item) : [...followed, item]; setFollowed(selected); }, [followed] ); return ( <> Followers {followers.map((follower) => ( handleClick(follower.id)} /> ))} ); } // ---------------------------------------------------------------------- type CardItemProps = CardProps & { selected: boolean; onSelected: () => void; follower: IUserProfileFollower; }; function CardItem({ follower, selected, onSelected, sx, ...other }: CardItemProps) { return ( ({ display: 'flex', alignItems: 'center', p: theme.spacing(3, 2, 3, 3), }), ...(Array.isArray(sx) ? sx : [sx]), ]} {...other} > {follower?.country} } slotProps={{ primary: { noWrap: true }, secondary: { noWrap: true, sx: { mt: 0.5, display: 'flex', alignItems: 'center', typography: 'caption', color: 'text.disabled', }, }, }} /> ); }