Compare commits
No commits in common. "ddbd5ba6074eaf521269c0733288205d80e54e81" and "d85f081d3a5e08f2b9c346ccd4c711ffce019ba3" have entirely different histories.
ddbd5ba607
...
d85f081d3a
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@ const getToken = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
baseURL: 'https://enaklo-pos-be.altru.id/api/v1',
|
baseURL: 'http://127.0.0.1:4000/api/v1',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
|
||||||
import { VoucherRowsResponse } from '../../types/services/voucher'
|
|
||||||
import { api } from '../api'
|
|
||||||
|
|
||||||
export interface VouchersQueryParams {
|
|
||||||
rows?: number
|
|
||||||
winner_number?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
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, winner_number }],
|
|
||||||
queryFn: async () => {
|
|
||||||
const res = await api.get(`/vouchers/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 = 5, winner_number: number = 1): Promise<VoucherRowsResponse> {
|
|
||||||
const res = await api.get(`/vouchers/rows`, {
|
|
||||||
params: { rows, winner_number }
|
|
||||||
})
|
|
||||||
return res.data.data
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
export interface Voucher {
|
|
||||||
voucher_code: string
|
|
||||||
name: string
|
|
||||||
phone_number: string
|
|
||||||
is_winner: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VoucherRow {
|
|
||||||
row_number: number
|
|
||||||
vouchers: Voucher[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VoucherRowsResponse {
|
|
||||||
rows: VoucherRow[]
|
|
||||||
total_rows: number
|
|
||||||
total_vouchers: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VoucherApiResponse {
|
|
||||||
success: boolean
|
|
||||||
data: VoucherRowsResponse
|
|
||||||
errors: any
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user