import createAxios from '/@/utils/axios'

export const url = '/admin/Dashboard/'

export function index(params: { start: string; end: string; page?: number }) {
    return createAxios({
        url: url + 'index',
        method: 'get',
        params,
    })
}

export function bankTransact(data: { money: number | string; bank_from: number | string; bank_to: number | string; remark: string }) {
    return createAxios(
        {
            url: url + 'bankTransact',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export interface DashboardTransactPayload {
    create_time: number
    category: number | string
    type: number | string
    user_name: string
    memo: string
    money: number | string
    bank_id: number | string
    label: number | string
    game_ticket: 0 | 1
}

export function newTransact(data: DashboardTransactPayload) {
    return createAxios(
        {
            url: url + 'newTransact',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function editTransact(data: DashboardTransactPayload & { id: number | string }) {
    return createAxios(
        {
            url: url + 'editTransact',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function delTransact(data: { id: number | string }) {
    return createAxios({
        url: url + 'delTransact',
        method: 'get',
        params: data,
    })
}

export function logHistory(params: { id: number | string }) {
    return createAxios({
        url: url + 'logHistory',
        method: 'get',
        params,
    })
}
