feat(contexts): add GuildMember
This commit is contained in:
@ -8,33 +8,46 @@ import {
|
||||
AuthenticationProvider,
|
||||
PagePropsWithAuthentication
|
||||
} from 'utils/authentication'
|
||||
import { GuildMember, GuildMemberProvider } from 'contexts/GuildMember'
|
||||
import { GuildLeftSidebar } from 'components/Application/GuildLeftSidebar'
|
||||
|
||||
export interface ChannelPageProps extends PagePropsWithAuthentication {
|
||||
channelId: number
|
||||
guildId: number
|
||||
guildMember: GuildMember
|
||||
}
|
||||
|
||||
const ChannelPage: NextPage<ChannelPageProps> = (props) => {
|
||||
const { channelId, guildId, authentication } = props
|
||||
const { channelId, guildId, authentication, guildMember } = props
|
||||
|
||||
return (
|
||||
<AuthenticationProvider authentication={authentication}>
|
||||
<Head title='Thream | Application' />
|
||||
<Application
|
||||
path={{
|
||||
channelId,
|
||||
guildId
|
||||
}}
|
||||
>
|
||||
<Messages />
|
||||
</Application>
|
||||
<GuildMemberProvider guildMember={guildMember}>
|
||||
<Head title='Thream | Application' />
|
||||
<Application
|
||||
path={{
|
||||
channelId,
|
||||
guildId
|
||||
}}
|
||||
guildLeftSidebar={
|
||||
<GuildLeftSidebar
|
||||
path={{
|
||||
channelId,
|
||||
guildId
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Messages />
|
||||
</Application>
|
||||
</GuildMemberProvider>
|
||||
</AuthenticationProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps = authenticationFromServerSide({
|
||||
shouldBeAuthenticated: true,
|
||||
fetchData: async (context) => {
|
||||
fetchData: async (context, api) => {
|
||||
const channelId = Number(context?.params?.channelId)
|
||||
const guildId = Number(context?.params?.guildId)
|
||||
if (isNaN(channelId) || isNaN(guildId)) {
|
||||
@ -45,9 +58,11 @@ export const getServerSideProps = authenticationFromServerSide({
|
||||
}
|
||||
}
|
||||
}
|
||||
const { data: guildMember } = await api.get(`/guilds/${guildId}`)
|
||||
return {
|
||||
channelId,
|
||||
guildId
|
||||
guildId,
|
||||
guildMember
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user