Skip to content

Commit 4828eef

Browse files
committed
feat: add disabled prop to Advertisement component and update usage for search page
1 parent 3ce9e5d commit 4828eef

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

components/Advertisement.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import AdSense from 'react-adsense'
22

3-
const Advertisement: React.FC<AdvertisementProps> = ({ size = 'short' }) => {
3+
const Advertisement: React.FC<AdvertisementProps> = ({ size = 'short', disabled = false }) => {
4+
if (disabled) return null
5+
46
return (
57
<div className='py-5'>
68
<div
@@ -39,6 +41,7 @@ declare global {
3941

4042
interface AdvertisementProps {
4143
size?: 'short' | 'tall'
44+
disabled?: boolean
4245
}
4346

4447
export default Advertisement

pages/search.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { NextPage, NextPageContext } from 'next'
2-
import type { FC } from 'react'
32
import dynamic from 'next/dynamic'
43
import { ParsedUrlQuery } from 'querystring'
4+
import type { FC } from 'react'
55

6-
import { List, Bot, Server } from '@types'
6+
import { Bot, List, Server } from '@types'
7+
import { KoreanbotsEndPoints } from '@utils/Constants'
78
import { get } from '@utils/Query'
89
import { SearchQuerySchema } from '@utils/Yup'
9-
import { KoreanbotsEndPoints } from '@utils/Constants'
1010

1111
const Hero = dynamic(() => import('@components/Hero'))
1212
const Advertisement = dynamic(() => import('@components/Advertisement'))
@@ -58,7 +58,8 @@ const SearchComponent: FC<{
5858
const Search: NextPage<SearchProps> = ({ botData, serverData, priority, query }) => {
5959
if (!query?.q) return <Redirect text={false} to='/' />
6060
const list: ('bot' | 'server')[] = ['bot', 'server']
61-
const resultNotExists = (!botData || botData.data.length === 0) && (!serverData || serverData.data.length === 0)
61+
const resultNotExists =
62+
(!botData || botData.data.length === 0) && (!serverData || serverData.data.length === 0)
6263
return (
6364
<>
6465
<Hero
@@ -68,7 +69,7 @@ const Search: NextPage<SearchProps> = ({ botData, serverData, priority, query })
6869
/>
6970
<Container>
7071
<section id='list'>
71-
{resultNotExists ? null : <Advertisement />}
72+
<Advertisement disabled={resultNotExists} />
7273
{(priority === 'server' ? list.reverse() : list).map((el) => (
7374
<SearchComponent
7475
key={el}
@@ -77,7 +78,7 @@ const Search: NextPage<SearchProps> = ({ botData, serverData, priority, query })
7778
type={el}
7879
/>
7980
))}
80-
{resultNotExists ? null : <Advertisement />}
81+
<Advertisement disabled={resultNotExists} />
8182
</section>
8283
</Container>
8384
</>

0 commit comments

Comments
 (0)