diff --git a/pages/developers/applications/bots/[id].tsx b/pages/developers/applications/bots/[id].tsx index 5f2d586..f0a73e2 100644 --- a/pages/developers/applications/bots/[id].tsx +++ b/pages/developers/applications/bots/[id].tsx @@ -1,28 +1,35 @@ import { NextPage, NextPageContext } from 'next' import dynamic from 'next/dynamic' +import { useRouter } from 'next/router' import { useState } from 'react' +import { Form, Formik } from 'formik' import useCopyClipboard from 'react-use-clipboard' import { get } from '@utils/Query' -import { parseCookie } from '@utils/Tools' +import { DeveloperBotSchema } from '@utils/Yup' +import { parseCookie, redirectTo } from '@utils/Tools' import { ParsedUrlQuery } from 'querystring' -import { Bot, BotSpec, User } from '@types' +import { Bot, BotSpec } from '@types' + import NotFound from 'pages/404' -import { Form, Formik } from 'formik' -import { DeveloperBotSchema } from '@utils/Yup' const Button = dynamic(() => import('@components/Button')) const Input = dynamic(() => import('@components/Form/Input')) const DeveloperLayout = dynamic(() => import('@components/DeveloperLayout')) const DiscordAvatar = dynamic(() => import('@components/DiscordAvatar')) -const BotApplication: NextPage = ({ spec, bot }) => { +const BotApplication: NextPage = ({ user, spec, bot }) => { + const router = useRouter() const [ showToken, setShowToken ] = useState(false) const [ tokenCopied, setTokenCopied ] = useCopyClipboard(spec?.token, { successDuration: 1000 }) - + if(!user) { + localStorage.redirectTo = window.location.href + redirectTo(router, 'login') + return + } if(!bot || !spec) return return

봇 설정

@@ -65,7 +72,7 @@ const BotApplication: NextPage = ({ spec, bot }) => { } interface BotApplicationProps { - user: User + user: string spec: BotSpec bot: Bot } @@ -75,7 +82,7 @@ export const getServerSideProps = async (ctx: Context) => { const user = await get.Authorization(parsed?.token) || '' return { - props: { spec: await get.botSpec(ctx.query.id, user), bot: await get.bot.load(ctx.query.id) } + props: { user, spec: await get.botSpec(ctx.query.id, user), bot: await get.bot.load(ctx.query.id) } } } diff --git a/pages/developers/applications/index.tsx b/pages/developers/applications/index.tsx index 3f1b1cd..961f223 100644 --- a/pages/developers/applications/index.tsx +++ b/pages/developers/applications/index.tsx @@ -1,8 +1,9 @@ import { NextPage, NextPageContext } from 'next' import dynamic from 'next/dynamic' +import { useRouter } from 'next/router' import { get } from '@utils/Query' -import { parseCookie } from '@utils/Tools' +import { parseCookie, redirectTo } from '@utils/Tools' import { Bot, User } from '@types' @@ -10,6 +11,12 @@ const Application = dynamic(() => import('@components/Application')) const DeveloperLayout = dynamic(() => import('@components/DeveloperLayout')) const Applications: NextPage = ({ user }) => { + const router = useRouter() + if(!user) { + localStorage.redirectTo = window.location.href + redirectTo(router, 'login') + return + } return

나의 봇

한국 디스코드봇 리스트 API를 활용하여 봇에 다양한 기능을 추가해보세요.