import { apiRequest } from "@/shared/api/request";

export interface PointWithdrawalCoinSellerDto {
    appCode: string;
    sellerUserId: string;
    displayUserId: string;
    nickname: string;
    avatar: string;
    countryName: string;
    sortOrder: number;
    pointAmount: number;
    sellerCoinAmount: number;
    serviceCountryCodes: string[];
    status: "active" | "disabled";
    createdAtMs: number;
    updatedAtMs: number;
}

export interface PointWithdrawalCoinSellerPayload {
    sellerUserId: number;
    sortOrder: number;
    pointAmount: number;
    sellerCoinAmount: number;
    serviceCountryCodes: string[];
    status: "active" | "disabled";
}

export function listPointWithdrawalCoinSellers(): Promise<{ items: PointWithdrawalCoinSellerDto[] }> {
    return apiRequest("/v1/admin/point-withdrawal/coin-sellers", { method: "GET" });
}

export function upsertPointWithdrawalCoinSeller(
    payload: PointWithdrawalCoinSellerPayload,
): Promise<PointWithdrawalCoinSellerDto> {
    return apiRequest("/v1/admin/point-withdrawal/coin-sellers", { body: payload, method: "PUT" });
}

export function deletePointWithdrawalCoinSeller(sellerUserId: string): Promise<{ deleted: boolean }> {
    return apiRequest(`/v1/admin/point-withdrawal/coin-sellers/${encodeURIComponent(sellerUserId)}`, {
        method: "DELETE",
    });
}
