@@ -9,9 +9,16 @@ import { ParsedUrlQuery } from 'querystring'
99import { getJosaPicker } from 'josa'
1010
1111import { get } from '@utils/Query'
12- import { checkBotFlag , checkUserFlag , cleanObject , makeBotURL , parseCookie , redirectTo } from '@utils/Tools'
12+ import {
13+ checkBotFlag ,
14+ checkUserFlag ,
15+ cleanObject ,
16+ makeBotURL ,
17+ parseCookie ,
18+ redirectTo ,
19+ } from '@utils/Tools'
1320import { ManageBot , getManageBotSchema } from '@utils/Yup'
14- import { botCategories , botCategoryDescription , library } from '@utils/Constants'
21+ import { botCategories , botCategoryDescription , botEnforcements , library } from '@utils/Constants'
1522import { Bot , Theme , User } from '@types'
1623import { getToken } from '@utils/Csrf'
1724import Fetch from '@utils/Fetch'
@@ -82,6 +89,7 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
8289 prefix : bot . prefix ,
8390 library : bot . lib ,
8491 category : bot . category ,
92+ enforcements : bot . enforcements ,
8593 intro : bot . intro ,
8694 desc : bot . desc ,
8795 website : bot . web ,
@@ -98,8 +106,12 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
98106 >
99107 { ( { errors, touched, values, setFieldTouched, setFieldValue } ) => (
100108 < Form >
101- < div className = 'text-center md:flex md:text-left' >
102- < DiscordAvatar userID = { bot . id } className = 'mx-auto rounded-full md:mx-1' hash = { bot . avatar } />
109+ < div className = 'text-ceznter md:flex md:text-left' >
110+ < DiscordAvatar
111+ userID = { bot . id }
112+ className = 'mx-auto rounded-full md:mx-1'
113+ hash = { bot . avatar }
114+ />
103115 < div className = 'px-8 py-6 md:w-2/3' >
104116 < h1 className = 'text-3xl font-bold' >
105117 { bot . name } #{ bot . tag }
@@ -165,7 +177,11 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
165177 error = { errors . category && touched . category ? ( errors . category as string ) : null }
166178 >
167179 < Selects
168- options = { botCategories . map ( ( el ) => ( { label : el , value : el , description : botCategoryDescription [ el ] } ) ) }
180+ options = { botCategories . map ( ( el ) => ( {
181+ label : el ,
182+ value : el ,
183+ description : botCategoryDescription [ el ] ,
184+ } ) ) }
169185 handleChange = { ( value ) => {
170186 setFieldValue (
171187 'category' ,
@@ -273,24 +289,26 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
273289 < Markdown text = { values . desc } />
274290 </ Segment >
275291 </ Label >
276- {
277- isPerkAvailable && (
278- < >
292+ { isPerkAvailable && (
293+ < >
279294 < 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 >
295+ < h2 className = 'pt-2 text-2xl font-semibold text-koreanbots-green' >
296+ 신뢰된 봇 특전 설정
297+ </ h2 >
298+ < span className = 'mt-1 text-sm text-gray-400' >
299+ 신뢰된 봇의 혜택을 만나보세요. (커스텀 URL과 배너/배경 이미지는 이용약관 및
300+ 가이드라인을 준수해야하며 위반 시 신뢰된 봇 자격이 박탈될 수 있습니다.)
301+ </ span >
282302 < Label
283303 For = 'vanity'
284304 label = '한디리 커스텀 URL'
285305 labelDesc = '고유한 커스텀 URL을 설정해주세요.'
286306 error = { errors . vanity && touched . vanity ? errors . vanity : null }
287-
288307 >
289308 < div className = 'flex items-center' >
290309 koreanbots.dev/bots/
291310 < Input name = 'vanity' placeholder = 'koreanbots' />
292311 </ div >
293-
294312 </ Label >
295313 < Label
296314 For = 'banner'
@@ -308,9 +326,36 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
308326 >
309327 < Input name = 'bg' placeholder = 'https://koreanbots.dev/logo.png' />
310328 </ Label >
311- </ >
312- )
313- }
329+ </ >
330+ ) }
331+ < Divider />
332+ < Label
333+ For = 'enforcements'
334+ label = '필수 고지 내용'
335+ labelDesc = '내용에 해당하는 경우 필수로 선택해야 합니다.'
336+ required
337+ error = {
338+ errors . enforcements && touched . enforcements ? ( errors . enforcements as string ) : null
339+ }
340+ >
341+ < Selects
342+ options = { Object . entries ( botEnforcements ) . map ( ( [ k , v ] ) => ( {
343+ label : v . label ,
344+ value : k ,
345+ } ) ) }
346+ handleChange = { ( value ) => {
347+ setFieldValue (
348+ 'enforcements' ,
349+ value . map ( ( v ) => v . value )
350+ )
351+ } }
352+ handleTouch = { ( ) => setFieldTouched ( 'enforcements' , true ) }
353+ values = { values . enforcements ?? ( [ ] as string [ ] ) }
354+ setValues = { ( value ) => {
355+ setFieldValue ( 'enforcements' , value )
356+ } }
357+ />
358+ </ Label >
314359 < Divider />
315360 < p className = 'mb-5 mt-2 text-base' >
316361 < span className = 'font-semibold text-red-500' > *</ span > = 필수 항목
@@ -320,7 +365,6 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
320365 < i className = 'far fa-save' /> 저장
321366 </ >
322367 </ Button >
323-
324368 </ Form >
325369 ) }
326370 </ Formik >
0 commit comments