import createAxios from '/@/utils/axios'

export interface GameRtpParams {
    provider: string
    game_name: string
    page: number
}

export function gameRtp(params: GameRtpParams) {
    return createAxios({
        url: '/admin/embed.Embed/gameRtp',
        method: 'get',
        params,
    })
}

export interface AddGamePayload {
    provider_site: string
    game_name: string
    image_url: string
    rtp: number
    status: 0 | 1
}

export function addGame(data: AddGamePayload) {
    return createAxios(
        {
            url: '/admin/embed.Embed/addGame',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export interface EditGamePayload extends AddGamePayload {
    id: number | string
}

export function editGame(data: EditGamePayload) {
    return createAxios(
        {
            url: '/admin/embed.Embed/editGame',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function del(data: { ids: (number | string)[] }) {
    return createAxios(
        {
            url: '/admin/embed.Embed/del',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export interface SaveGameRtpPayload {
    auto_game_rtp: 0 | 1
    auto_rtp_amount: Record<string, string | number>
    auto_frequency: number
    provider_display: Record<string, unknown> | unknown[]
    custom_config: Record<string, unknown>
    header_image_url: string
    text_color: string
    button_text_color: string
    base_color: string
    button_bg_color: string
    outline_color: string
    progress_bar_bg_color: string
}

export function saveGameRtp(data: SaveGameRtpPayload) {
    return createAxios(
        {
            url: '/admin/embed.Embed/saveGameRtp',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function domainStatus() {
    return createAxios({
        url: '/admin/embed.Embed/domainStatus',
        method: 'get',
    })
}

export interface SaveDomainPayload {
    header_image_url: string
    custom_config: Record<string, unknown>
    base_color: string
    border_color: string
    online_color: string
    offline_color: string
    title_color: string
    text_color: string
    tag_color: string
}

export function saveDomain(data: SaveDomainPayload) {
    return createAxios(
        {
            url: '/admin/embed.Embed/saveDomain',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}

export function partnership() {
    return createAxios({
        url: '/admin/embed.Embed/partnership',
        method: 'get',
    })
}

export interface SavePartnershipSetPayload {
    header_image_url: string
    footer_config: Record<string, unknown>
    custom_config: Record<string, unknown>
    base_color_1: string
    base_color_2: string
    border_color: string
    highlight_color: string
    title_color: string
    text_color: string
}

export function savePartnershipSet(data: SavePartnershipSetPayload) {
    return createAxios(
        {
            url: '/admin/embed.Embed/savePartnershipSet',
            method: 'post',
            data,
        },
        {
            showSuccessMessage: true,
        }
    )
}
