Skip to content

Commit 448b710

Browse files
feat: hide perks menu for non-trusted bots
1 parent 2157e61 commit 448b710

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

pages/bots/[id]/edit.tsx

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ParsedUrlQuery } from 'querystring'
99
import { getJosaPicker } from 'josa'
1010

1111
import { 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'
1313
import { ManageBot, ManageBotSchema } from '@utils/Yup'
1414
import { botCategories, botCategoryDescription, library } from '@utils/Constants'
1515
import { Bot, Theme, User } from '@types'
@@ -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,9 +88,9 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
8788
url: bot.url,
8889
git: bot.git,
8990
discord: bot.discord,
90-
vanity: bot.vanity,
91-
banner: bot.banner,
92-
bg: bot.bg,
91+
vanity: isPerkAvailable && bot.vanity,
92+
banner: isPerkAvailable && bot.banner,
93+
bg: isPerkAvailable && bot.bg,
9394
_csrf: csrfToken,
9495
})}
9596
validationSchema={ManageBotSchema}
@@ -272,38 +273,44 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
272273
<Markdown text={values.desc} />
273274
</Segment>
274275
</Label>
275-
<Divider />
276-
<h2 className='pt-2 text-2xl font-semibold text-koreanbots-green'>신뢰된 봇 특전 설정</h2>
277-
<span className='mt-1 text-sm text-gray-400'>신뢰된 봇의 혜택을 만나보세요. (커스텀 URL과 배너/배경 이미지는 이용약관 및 가이드라인을 준수해야하며 위반 시 신뢰된 봇 자격이 박탈될 수 있습니다.)</span>
278-
<Label
279-
For='vanity'
280-
label='한디리 커스텀 URL'
281-
labelDesc='고유한 커스텀 URL을 설정해주세요.'
282-
error={errors.vanity && touched.vanity ? errors.vanity : null}
283-
284-
>
285-
<div className='flex items-center'>
286-
koreanbots.dev/bots/
287-
<Input name='vanity' placeholder='koreanbots' />
288-
</div>
289-
290-
</Label>
291-
<Label
292-
For='banner'
293-
label='배너 URL'
294-
labelDesc='봇 목록의 카드에 표시되는 이미지입니다.'
295-
error={errors.banner && touched.banner ? errors.banner : null}
296-
>
297-
<Input name='banner' placeholder='https://koreanbots.dev' />
298-
</Label>
299-
<Label
300-
For='bg'
301-
label='배경 URL'
302-
labelDesc='봇 페이지 배경에 표시되는 이미지입니다.'
303-
error={errors.bg && touched.bg ? errors.bg : null}
304-
>
305-
<Input name='bg' placeholder='https://koreanbots.dev' />
306-
</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+
}
307314
<Divider />
308315
<p className='mb-5 mt-2 text-base'>
309316
<span className='font-semibold text-red-500'> *</span> = 필수 항목

0 commit comments

Comments
 (0)