@@ -9,7 +9,7 @@ import { ParsedUrlQuery } from 'querystring'
99import { getJosaPicker } from 'josa'
1010
1111import { get } from '@utils/Query'
12- import { checkUserFlag , cleanObject , makeBotURL , parseCookie , redirectTo } from '@utils/Tools'
12+ import { checkBotFlag , checkUserFlag , cleanObject , makeBotURL , parseCookie , redirectTo } from '@utils/Tools'
1313import { ManageBot , ManageBotSchema } from '@utils/Yup'
1414import { botCategories , botCategoryDescription , library } from '@utils/Constants'
1515import { Bot , Theme , User } from '@types'
@@ -58,7 +58,7 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
5858 else return null
5959 }
6060
61- if ( ! bot ) return < NotFound />
61+ if ( ! bot ?. id ) return < NotFound />
6262 if ( ! user )
6363 return (
6464 < Login >
@@ -70,6 +70,7 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
7070 ! checkUserFlag ( user . flags , 'staff' )
7171 )
7272 return < Forbidden />
73+ const isPerkAvailable = checkBotFlag ( bot . flags , 'trusted' ) || checkBotFlag ( bot . flags , 'partnered' )
7374 return (
7475 < Container paddingTop className = 'pb-10 pt-5' >
7576 < NextSeo title = { `${ bot . name } 수정하기` } description = '봇의 정보를 수정합니다.' />
@@ -87,6 +88,9 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
8788 url : bot . url ,
8889 git : bot . git ,
8990 discord : bot . discord ,
91+ vanity : isPerkAvailable && bot . vanity ,
92+ banner : isPerkAvailable && bot . banner ,
93+ bg : isPerkAvailable && bot . bg ,
9094 _csrf : csrfToken ,
9195 } ) }
9296 validationSchema = { ManageBotSchema }
@@ -269,6 +273,44 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
269273 < Markdown text = { values . desc } />
270274 </ Segment >
271275 </ Label >
276+ {
277+ isPerkAvailable && (
278+ < >
279+ < Divider />
280+ < h2 className = 'pt-2 text-2xl font-semibold text-koreanbots-green' > 신뢰된 봇 특전 설정</ h2 >
281+ < span className = 'mt-1 text-sm text-gray-400' > 신뢰된 봇의 혜택을 만나보세요. (커스텀 URL과 배너/배경 이미지는 이용약관 및 가이드라인을 준수해야하며 위반 시 신뢰된 봇 자격이 박탈될 수 있습니다.)</ span >
282+ < Label
283+ For = 'vanity'
284+ label = '한디리 커스텀 URL'
285+ labelDesc = '고유한 커스텀 URL을 설정해주세요.'
286+ error = { errors . vanity && touched . vanity ? errors . vanity : null }
287+
288+ >
289+ < div className = 'flex items-center' >
290+ koreanbots.dev/bots/
291+ < Input name = 'vanity' placeholder = 'koreanbots' />
292+ </ div >
293+
294+ </ Label >
295+ < Label
296+ For = 'banner'
297+ label = '배너 URL'
298+ labelDesc = '봇 목록의 카드에 표시되는 이미지입니다.'
299+ error = { errors . banner && touched . banner ? errors . banner : null }
300+ >
301+ < Input name = 'banner' placeholder = 'https://koreanbots.dev/logo.png' />
302+ </ Label >
303+ < Label
304+ For = 'bg'
305+ label = '배경 URL'
306+ labelDesc = '봇 페이지 배경에 표시되는 이미지입니다.'
307+ error = { errors . bg && touched . bg ? errors . bg : null }
308+ >
309+ < Input name = 'bg' placeholder = 'https://koreanbots.dev/logo.png' />
310+ </ Label >
311+ </ >
312+ )
313+ }
272314 < Divider />
273315 < p className = 'mb-5 mt-2 text-base' >
274316 < span className = 'font-semibold text-red-500' > *</ span > = 필수 항목
@@ -278,6 +320,7 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
278320 < i className = 'far fa-save' /> 저장
279321 </ >
280322 </ Button >
323+
281324 </ Form >
282325 ) }
283326 </ Formik >
@@ -574,9 +617,11 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
574617export const getServerSideProps = async ( ctx : Context ) => {
575618 const parsed = parseCookie ( ctx . req )
576619 const user = await get . Authorization ( parsed ?. token )
620+ const bot = await get . bot . load ( ctx . query . id )
621+ const spec = await get . botSpec ( bot ?. id || '' , user || '' )
577622 return {
578623 props : {
579- bot : await get . bot . load ( ctx . query . id ) ,
624+ bot : { ... bot , banner : spec ?. banner || null , bg : spec ?. bg || null } ,
580625 user : await get . user . load ( user || '' ) ,
581626 csrfToken : getToken ( ctx . req , ctx . res ) ,
582627 } ,
0 commit comments