feat: disabled webhook

This commit is contained in:
wonderlandpark 2021-05-07 08:36:05 +09:00
parent 4d4bf56650
commit 094303fc9c

View File

@ -2,12 +2,10 @@ 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 { DeveloperBot, DeveloperBotSchema } from '@utils/Yup'
import { cleanObject, parseCookie, redirectTo } from '@utils/Tools'
import { parseCookie, redirectTo } from '@utils/Tools'
import { getToken } from '@utils/Csrf'
import Fetch from '@utils/Fetch'
@ -18,7 +16,6 @@ import NotFound from 'pages/404'
import Link from 'next/link'
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 Message = dynamic(() => import('@components/Message'))
@ -32,13 +29,13 @@ const BotApplication: NextPage<BotApplicationProps> = ({ user, spec, bot, theme,
const [ tokenCopied, setTokenCopied ] = useCopyClipboard(spec?.token, {
successDuration: 1000
})
async function updateApplication(d: DeveloperBot) {
const res = await Fetch(`/applications/bots/${bot.id}`, {
method: 'PATCH',
body: JSON.stringify(cleanObject(d))
})
setData(res)
}
// async function updateApplication(d: DeveloperBot) {
// const res = await Fetch(`/applications/bots/${bot.id}`, {
// method: 'PATCH',
// body: JSON.stringify(cleanObject(d))
// })
// setData(res)
// }
async function resetToken() {
const res = await Fetch<{ token: string }>(`/applications/bots/${bot.id}/reset`, {
@ -91,9 +88,19 @@ const BotApplication: NextPage<BotApplicationProps> = ({ user, spec, bot, theme,
<Button onClick={() => setShowToken(!showToken)}>{showToken ? '숨기기' : '보기'}</Button>
<Button onClick={setTokenCopied} className={tokenCopied ? 'bg-green-400 text-white' : null}>{tokenCopied ? '복사됨' : '복사'}</Button>
<Button onClick={()=> setModalOpen(true)}></Button>
<Modal isOpen={modalOpened} onClose={() => setModalOpen(false)} dark={theme === 'dark'} header='정말로 토큰을 재발급하시겠습니까?'>
<p> </p>
<div className='text-right pt-6'>
<Button className='bg-gray-500 text-white hover:opacity-90' onClick={()=> setModalOpen(false)}></Button>
<Button onClick={async ()=> {
const res = await resetToken()
spec.token = res.data.token
setModalOpen(false)
}}></Button>
</div>
<Formik validationSchema={DeveloperBotSchema} initialValues={{
</Modal>
</div>
{/* <Formik validationSchema={DeveloperBotSchema} initialValues={{
webhook: spec.webhook || '',
_csrf: csrfToken
}}
@ -107,20 +114,9 @@ const BotApplication: NextPage<BotApplicationProps> = ({ user, spec, bot, theme,
{touched.webhook && errors.webhook ? <div className='text-red-500 text-xs font-light mt-1'>{errors.webhook}</div> : null}
</div>
<Button type='submit'><i className='far fa-save'/> </Button>
<Modal isOpen={modalOpened} onClose={() => setModalOpen(false)} dark={theme === 'dark'} header='정말로 토큰을 재발급하시겠습니까?'>
<p> </p>
<div className='text-right pt-6'>
<Button className='bg-gray-500 text-white hover:opacity-90' onClick={()=> setModalOpen(false)}></Button>
<Button onClick={async ()=> {
const res = await resetToken()
spec.token = res.data.token
setModalOpen(false)
}}></Button>
</div>
</Modal>
</Form>
)}
</Formik>
</Formik> */}
</div>
</div>
</div>