export const FINANCE_PERMISSIONS = {
    auditApplication: "finance-application:audit",
    auditWithdrawalApplications: "finance-withdrawal:audit",
    createApplication: "finance-application:create",
    viewAppRechargeDetails: "payment-bill:view",
    viewWithdrawalApplications: "finance-withdrawal:view",
};

export const FINANCE_OPERATIONS = [
    {
        allowsZeroRechargeAmount: true,
        label: "增加用户金币",
        permissionCode: "finance-operation:user-coin-credit",
        value: "user_coin_credit",
    },
    {
        allowsZeroRechargeAmount: true,
        label: "减少用户金币",
        permissionCode: "finance-operation:user-coin-debit",
        value: "user_coin_debit",
    },
    {
        label: "用户钱包扣减",
        permissionCode: "finance-operation:user-wallet-debit",
        requiresWalletIdentity: true,
        value: "user_wallet_debit",
    },
    {
        label: "用户钱包增加",
        permissionCode: "finance-operation:user-wallet-credit",
        requiresWalletIdentity: true,
        value: "user_wallet_credit",
    },
    {
        label: "增加币商金币",
        permissionCode: "finance-operation:coin-seller-coin-credit",
        value: "coin_seller_coin_credit",
    },
    {
        label: "减少币商金币",
        permissionCode: "finance-operation:coin-seller-coin-debit",
        value: "coin_seller_coin_debit",
    },
];

export const WALLET_IDENTITIES = [
    ["host", "Host 钱包"],
    ["agency", "Agency 钱包"],
    ["bd", "BD 钱包"],
];

export const APPLICATION_STATUS = [
    ["pending", "待审核"],
    ["approved", "已通过"],
    ["rejected", "已拒绝"],
];

export const DEFAULT_APPLICATION_FORM = {
    appCode: "",
    coinAmount: "",
    credentialImageUrl: "",
    credentialText: "",
    operation: "",
    rechargeAmount: "",
    targetUserId: "",
    walletIdentity: "",
};

export function operationRequiresWalletIdentity(operation) {
    return FINANCE_OPERATIONS.some((item) => item.value === operation && item.requiresWalletIdentity);
}

export function operationAllowsZeroRechargeAmount(operation) {
    return FINANCE_OPERATIONS.some((item) => item.value === operation && item.allowsZeroRechargeAmount);
}
