11import { useInfiniteQuery } from '@tanstack/react-query'
22import { axios } from 'src/lib/axios'
33import { InfiniteQueryConfig } from 'src/lib/react-query'
4- import { FeedItem } from 'src/types'
4+ import { FeedItemData } from 'src/types'
55
66type Response = {
7- data : FeedItem [ ]
7+ data : FeedItemData [ ]
88 metadata : {
99 next : string | null
1010 hasNextPage : boolean
1111 }
1212}
13- const getAIArticles = async ( {
13+ const getFeed = async ( {
1414 tags,
1515 next,
1616} : {
1717 tags : string [ ]
1818 next ?: string | null
1919} ) : Promise < Response > => {
20- return axios . get ( '/TO_ADD ' , {
20+ return axios . get ( '' , {
2121 auth : {
22- username : 'hidden ' ,
23- password : 'hidden ' ,
22+ username : '' ,
23+ password : '' ,
2424 } ,
2525 params : {
2626 tags : [ ...tags ] . sort ( ) . join ( ',' ) ,
@@ -30,18 +30,18 @@ const getAIArticles = async ({
3030 } )
3131}
3232
33- type QueryFnType = typeof getAIArticles
33+ type QueryFnType = typeof getFeed
3434
3535type UseGetArticlesOptions = {
3636 tags : string [ ]
3737 config ?: InfiniteQueryConfig < QueryFnType >
3838}
3939
40- export const useGetAIArticles = ( { tags, config } : UseGetArticlesOptions ) => {
40+ export const useGetFeed = ( { tags, config } : UseGetArticlesOptions ) => {
4141 return useInfiniteQuery < Response > ( {
4242 ...config ,
4343 queryKey : [ 'feed' , 'v2' , tags . join ( ',' ) ] ,
44- queryFn : ( { pageParam } ) => getAIArticles ( { tags, next : pageParam } ) ,
44+ queryFn : ( { pageParam } ) => getFeed ( { tags, next : pageParam } ) ,
4545 getNextPageParam : ( lastPage ) => {
4646 return lastPage . metadata . hasNextPage ? JSON . stringify ( lastPage . metadata . next ) : undefined
4747 } ,
0 commit comments