Skip to content

Commit 73da20c

Browse files
committed
refactor: simplify getAd function by removing additionalAdQueries parameter
1 parent 1b1911e commit 73da20c

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/features/adv/api/getAd.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@ import { axios } from 'src/lib/axios'
33
import { ExtractFnReturnType, QueryConfig } from 'src/lib/react-query'
44
import { Ad } from '../types'
55

6-
const getAd = async (
7-
keywords: string[],
8-
feed: boolean = false,
9-
aditionalAdQueries: { [key: string]: string } | undefined
10-
): Promise<Ad | null> => {
6+
const getAd = async (keywords: string[], feed: boolean = false): Promise<Ad | null> => {
117
let params = { keywords: keywords.join(','), feed: feed ? 'true' : 'false' }
12-
if (aditionalAdQueries) {
13-
params = { ...params, ...aditionalAdQueries }
14-
}
158
return axios.get('/engine/ads/', { params })
169
}
1710

@@ -21,12 +14,11 @@ type UseGetAdOptions = {
2114
keywords: string[]
2215
feed?: boolean
2316
config?: QueryConfig<QueryFnType>
24-
aditionalAdQueries: { [key: string]: string } | undefined
2517
}
26-
export const useGetAd = ({ keywords, feed, config, aditionalAdQueries }: UseGetAdOptions) => {
18+
export const useGetAd = ({ keywords, feed, config }: UseGetAdOptions) => {
2719
return useQuery<ExtractFnReturnType<QueryFnType>>({
2820
...config,
2921
queryKey: ['ad', keywords.join(',')],
30-
queryFn: () => getAd(keywords, feed, aditionalAdQueries),
22+
queryFn: () => getAd(keywords, feed),
3123
})
3224
}

0 commit comments

Comments
 (0)