2023-10-23 23:33:39 +02:00
|
|
|
import type { NextPage } from "next"
|
|
|
|
import useTranslation from "next-translate/useTranslation"
|
2022-03-05 18:22:30 +01:00
|
|
|
|
2023-10-23 23:33:39 +02:00
|
|
|
import { Head } from "../../../../components/Head"
|
|
|
|
import { Application } from "../../../../components/Application"
|
|
|
|
import type { PagePropsWithAuthentication } from "../../../../tools/authentication"
|
2022-03-05 18:22:30 +01:00
|
|
|
import {
|
|
|
|
authenticationFromServerSide,
|
2023-10-23 23:33:39 +02:00
|
|
|
AuthenticationProvider,
|
|
|
|
} from "../../../../tools/authentication"
|
|
|
|
import { CreateChannel } from "../../../../components/Application/CreateChannel"
|
|
|
|
import { GuildsProvider } from "../../../../contexts/Guilds"
|
|
|
|
import type { GuildMember } from "../../../../contexts/GuildMember"
|
|
|
|
import { GuildMemberProvider } from "../../../../contexts/GuildMember"
|
2022-03-05 18:22:30 +01:00
|
|
|
|
|
|
|
export interface CreateChannelPageProps extends PagePropsWithAuthentication {
|
|
|
|
guildId: number
|
|
|
|
guildMember: GuildMember
|
|
|
|
}
|
|
|
|
|
|
|
|
const CreateChannelPage: NextPage<CreateChannelPageProps> = (props) => {
|
|
|
|
const { guildId, authentication, guildMember } = props
|
2022-04-09 01:03:15 +02:00
|
|
|
const { t } = useTranslation()
|
2022-03-05 18:22:30 +01:00
|
|
|
|
|
|
|
const path = { guildId }
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AuthenticationProvider authentication={authentication}>
|
|
|
|
<GuildsProvider>
|
|
|
|
<GuildMemberProvider guildMember={guildMember} path={path}>
|
|
|
|
<Head
|
2023-10-23 23:33:39 +02:00
|
|
|
title={`Thream | ${t("application:create-a-channel")}`}
|
|
|
|
description={t("application:create-a-channel")}
|
2022-03-05 18:22:30 +01:00
|
|
|
/>
|
2023-10-23 23:33:39 +02:00
|
|
|
<Application path={path} title={t("application:create-a-channel")}>
|
2022-03-05 18:22:30 +01:00
|
|
|
<CreateChannel />
|
|
|
|
</Application>
|
|
|
|
</GuildMemberProvider>
|
|
|
|
</GuildsProvider>
|
|
|
|
</AuthenticationProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getServerSideProps = authenticationFromServerSide({
|
|
|
|
shouldBeAuthenticated: true,
|
|
|
|
fetchData: async (context, api) => {
|
2023-10-23 23:33:39 +02:00
|
|
|
const guildId = Number(context?.params?.["guildId"])
|
2023-07-22 16:34:23 +02:00
|
|
|
if (Number.isNaN(guildId)) {
|
2022-03-05 18:22:30 +01:00
|
|
|
return {
|
2023-10-23 23:33:39 +02:00
|
|
|
notFound: true,
|
2022-03-05 18:22:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const { data: guildMember } = await api.get(`/guilds/${guildId}`)
|
|
|
|
return {
|
|
|
|
guildId,
|
2023-10-23 23:33:39 +02:00
|
|
|
guildMember,
|
2022-03-05 18:22:30 +01:00
|
|
|
}
|
2023-10-23 23:33:39 +02:00
|
|
|
},
|
2022-03-05 18:22:30 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
export default CreateChannelPage
|