From 496f53a0f9928665c9d3e3e5503d21196167f894 Mon Sep 17 00:00:00 2001 From: wonderlandpark Date: Sun, 28 Mar 2021 13:27:56 +0900 Subject: [PATCH] feat: added danger zone --- pages/manage/[id].tsx | 136 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/pages/manage/[id].tsx b/pages/manage/[id].tsx index 837e09f..df4d3c1 100644 --- a/pages/manage/[id].tsx +++ b/pages/manage/[id].tsx @@ -1,10 +1,11 @@ import { NextPage, NextPageContext } from 'next' -import { useState } from 'react' +import { useRef, useState } from 'react' import { useRouter } from 'next/router' import dynamic from 'next/dynamic' import Link from 'next/link' import { Form, Formik } from 'formik' import { ParsedUrlQuery } from 'node:querystring' +import { getJosaPicker } from 'josa' import { get } from '@utils/Query' import { checkUserFlag, cleanObject, makeBotURL, parseCookie, redirectTo } from '@utils/Tools' @@ -29,11 +30,18 @@ const Selects = dynamic(() => import('@components/Form/Selects')) const Button = dynamic(() => import('@components/Button')) const Container = dynamic(() => import('@components/Container')) const DiscordAvatar = dynamic(() => import('@components/DiscordAvatar')) +const Tag = dynamic(() => import('@components/Tag')) const Message = dynamic(() => import('@components/Message')) +const Modal = dynamic(() => import('@components/Modal')) +const Captcha = dynamic(() => import('@components/Captcha')) const SEO = dynamic(() => import('@components/SEO')) const ManageBotPage:NextPage = ({ bot, user, csrfToken, theme }) => { const [ data, setData ] = useState(null) + const [ adminModal, setAdminModal ] = useState(false) + const [ transferModal, setTransferModal ] = useState(false) + const [ deleteModal, setDeleteModal ] = useState(false) + const deleteRef = useRef() const router = useRouter() function toLogin() { localStorage.redirectTo = window.location.href @@ -44,6 +52,13 @@ const ManageBotPage:NextPage = ({ bot, user, csrfToken, theme }) const res = await Fetch(`/bots/${bot.id}`, { method: 'PATCH', body: JSON.stringify(cleanObject(value)) }) setData(res) } + + async function getUser(id: string) { + const u = await Fetch(`/users/${encodeURIComponent(id)}`) + if(u.code === 200 && u.data) return u.data + else return null + } + if(!bot) return if(!user) { toLogin() @@ -147,7 +162,6 @@ const ManageBotPage:NextPage = ({ bot, user, csrfToken, theme }) - + setAdminModal(false)} closeIcon> + alert(JSON.stringify(v.owners.map(el => el.id)))}> + { + ({ values, setFieldValue }) =>
+ +

소유자는 삭제할 수 없습니다. 소유권을 이전하고 싶으시다면 소유권 이전을 사용해주세요.

+
+
+

이전하실 유저 ID를 입력해주세요.

+
+ { + (values.owners as User[]).map((el, n) => + {el.username}#{el.tag} + { + n !== 0 && + } + } key={el.id} />) + } +
+
+
+ +
+ +
+
+ + + } +
+
+ + +
+
+

소유권 이전

+

봇의 소유권을 이전합니다. 소유권을 이전하게 되면 소유권을 잃게 됩니다.

+
+ + setTransferModal(false)} closeIcon> + alert(JSON.stringify(v))}> + { + ({ values, setFieldValue }) =>
+ +

봇의 소유권을 이전하게 되면 봇의 소유자 권한을 이전하게 됩니다.

+
+
+

이전하실 유저 ID를 입력해주세요.

+ + +

계속 하시려면 {bot.name}{getJosaPicker('을')(bot.name)} 입력해주세요.

+ +
+ setFieldValue('_captcha', k)} /> + + + } +
+
+
+ +
+
+

봇 삭제하기

+

봇을 삭제하게 되면 되돌릴 수 없습니다.

+
+ + setDeleteModal(false)} closeIcon> + alert(JSON.stringify(v))}> + { + ({ values, setFieldValue }) =>
+ +

봇을 삭제하게 되면 되돌릴 수 없습니다.
하트 수를 포함한 모든 봇 정보가 영구적으로 삭제됩니다.

+

계속 하시려면 봇의 이름 {bot.name}{getJosaPicker('을')(bot.name)} 입력해주세요.

+
+
+ +
+ setFieldValue('_captcha', k)} /> + + + } +
+
+
+ + + } }