Add followers in profile

This commit is contained in:
AkiraFukushima 2023-12-02 15:06:47 +09:00
parent 482034fe86
commit 555fb288d1
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
2 changed files with 32 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import { FaEllipsisVertical } from 'react-icons/fa6'
import { FormattedMessage, useIntl } from 'react-intl'
import Timeline from './profile/Timeline'
import Followings from './profile/Followings'
import Followers from './profile/Followers'
type Props = {
client: MegalodonInterface
@ -116,7 +117,7 @@ export default function Profile(props: Props) {
<Followings client={props.client} user_id={props.user_id} />
</Tabs.Item>
<Tabs.Item title={formatMessage({ id: 'profile.followers' })} className="focus:ring-0">
followers
<Followers client={props.client} user_id={props.user_id} />
</Tabs.Item>
</Tabs.Group>
</div>

View File

@ -0,0 +1,30 @@
import { Entity, MegalodonInterface } from 'megalodon'
import { useEffect, useState } from 'react'
import User from './User'
type Props = {
client: MegalodonInterface
user_id: string
}
export default function Followers(props: Props) {
const [users, setUsers] = useState<Array<Entity.Account>>([])
useEffect(() => {
if (props.user_id) {
const f = async () => {
const res = await props.client.getAccountFollowers(props.user_id)
setUsers(res.data)
}
f()
}
}, [props.client, props.user_id])
return (
<>
{users.map((user, index) => (
<User user={user} key={index} />
))}
</>
)
}