Fix
This commit is contained in:
@@ -4,28 +4,31 @@ import { api } from '../api'
|
||||
|
||||
export interface VouchersQueryParams {
|
||||
rows?: number
|
||||
winner_number?: number
|
||||
}
|
||||
|
||||
export function useVoucherRows(params: VouchersQueryParams = {}) {
|
||||
const { rows = 4 } = params
|
||||
export function useVoucherRows(params: VouchersQueryParams = {}, options: { enabled?: boolean } = {}) {
|
||||
const { rows = 5, winner_number = 1 } = params
|
||||
const { enabled = true } = options
|
||||
|
||||
return useQuery<VoucherRowsResponse>({
|
||||
queryKey: ['voucher-rows', { rows }],
|
||||
queryKey: ['voucher-rows', { rows, winner_number }],
|
||||
queryFn: async () => {
|
||||
const res = await api.get(`/vouchers/rows`, {
|
||||
params: { rows }
|
||||
params: { rows, winner_number }
|
||||
})
|
||||
return res.data.data
|
||||
},
|
||||
enabled,
|
||||
staleTime: 5 * 60 * 1000,
|
||||
refetchOnWindowFocus: false
|
||||
})
|
||||
}
|
||||
|
||||
// Manual fetch function for cases where you need to fetch without using the hook
|
||||
export async function fetchVoucherRows(rows: number = 4): Promise<VoucherRowsResponse> {
|
||||
export async function fetchVoucherRows(rows: number = 5, winner_number: number = 1): Promise<VoucherRowsResponse> {
|
||||
const res = await api.get(`/vouchers/rows`, {
|
||||
params: { rows }
|
||||
params: { rows, winner_number }
|
||||
})
|
||||
return res.data.data
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user