tooot/src/screens/Me/Root/MyInfo.tsx

37 lines
1.0 KiB
TypeScript
Raw Normal View History

2020-12-18 00:00:45 +01:00
import React, { useEffect } from 'react'
2020-11-22 00:46:23 +01:00
import { useQuery } from 'react-query'
2020-12-13 14:04:25 +01:00
import { accountFetch } from '@utils/fetches/accountFetch'
import AccountHeader from '@screens/Shared/Account/Header'
import AccountInformation from '@screens/Shared/Account/Information'
import { useSelector } from 'react-redux'
2020-12-13 14:04:25 +01:00
import { getLocalAccountId } from '@utils/slices/instancesSlice'
2020-12-18 00:00:45 +01:00
import { AccountState } from '@root/screens/Shared/Account'
2020-11-22 00:46:23 +01:00
2020-12-18 00:00:45 +01:00
export interface Props {
setData: React.Dispatch<React.SetStateAction<Mastodon.Account | undefined>>
}
const MyInfo: React.FC<Props> = ({ setData }) => {
const localAccountId = useSelector(getLocalAccountId)
const { data } = useQuery(['Account', { id: localAccountId }], accountFetch)
2020-12-18 00:00:45 +01:00
useEffect(() => {
if (data) {
setData(data)
}
}, [data])
2020-11-22 00:46:23 +01:00
return (
<>
2020-12-18 00:00:45 +01:00
<AccountHeader
accountState={{ headerRatio: 0.4 } as AccountState}
account={data}
limitHeight
/>
2020-11-22 00:46:23 +01:00
<AccountInformation account={data} />
</>
)
}
export default MyInfo