Skip to content

Commit

Permalink
feat: add trusted bots page (#649)
Browse files Browse the repository at this point in the history
* feat: add trusted bots page

* feat: add button for trusted bots

* chore: reduce trusted bot count to 4
  • Loading branch information
skinmaker1345 authored Jul 7, 2024
1 parent d736370 commit 5532d17
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pages/bots/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
<BotCard key={bot.id} bot={bot} />
))}
</ResponsiveGrid>
{trusted.data.length > 4 && (
<LongButton href='/bots/list/trusted' center>
더보기
</LongButton>
)}
<h1 className='mb-2 mt-20 text-3xl font-bold'>
<i className='far fa-star mr-3 text-amber-500' /> 새로운 봇
</h1>
Expand Down
68 changes: 68 additions & 0 deletions pages/bots/list/trusted.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { NextPage, NextPageContext } from 'next'
import dynamic from 'next/dynamic'

import { get } from '@utils/Query'
import { Bot, List } from '@types'
import { ParsedUrlQuery } from 'querystring'
import { PageCount } from '@utils/Yup'

const Hero = dynamic(() => import('@components/Hero'))
const Advertisement = dynamic(() => import('@components/Advertisement'))
const BotCard = dynamic(() => import('@components/BotCard'))
const Container = dynamic(() => import('@components/Container'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))

const Trusted: NextPage<TrustedProps> = ({ data }) => {
return (
<>
<Hero
type='bots'
header='신뢰된 봇'
description='한국 디스코드 리스트에서 엄격한 기준을 통과한 봇들입니다!'
/>
<Container className='pb-10'>
<Advertisement />
<ResponsiveGrid>
{data.data.map((bot) => (
<BotCard key={bot.id} bot={bot} />
))}
</ResponsiveGrid>
{/* <Paginator
totalPage={data.totalPage}
currentPage={data.currentPage}
pathname='/bots/list/trusted'
/> */}
<Advertisement />
</Container>
</>
)
}

export const getServerSideProps = async (ctx: Context) => {
let data: List<Bot>
if (!ctx.query.page) ctx.query.page = '1'
const validate = await PageCount.validate(ctx.query.page)
.then((el) => el)
.catch(() => null)
if (!validate || isNaN(Number(ctx.query.page))) data = null
else data = await get.list.trusted.load(Number(ctx.query.page))
return {
props: {
data,
},
}
}

interface Context extends NextPageContext {
query: URLQuery
}

interface URLQuery extends ParsedUrlQuery {
page: string
}

interface TrustedProps {
data: List<Bot>
}

export default Trusted

0 comments on commit 5532d17

Please sign in to comment.