feat(mobile): 新增解忧商行移动端首页、详情与个人中心
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
import { apiClient, unwrapData } from '@/shared/api/client'
|
||||
import type { ApiResponse, PublicListingPage } from '@/shared/api/types'
|
||||
import type { ApiResponse, Listing, PublicListingPage } from '@/shared/api/types'
|
||||
|
||||
export interface ListingQuery {
|
||||
page?: number
|
||||
@@ -30,3 +30,15 @@ export function useListings(query: ListingQuery) {
|
||||
queryFn: () => fetchListings(query),
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchListingDetail(id: number | string) {
|
||||
return unwrapData<Listing>(apiClient.get<ApiResponse<Listing>>(`/listings/${id}`))
|
||||
}
|
||||
|
||||
export function useListingDetail(id?: string) {
|
||||
return useQuery({
|
||||
queryKey: ['listing-detail', id],
|
||||
queryFn: () => fetchListingDetail(id as string),
|
||||
enabled: Boolean(id),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user