import { useAuth } from "@/app/auth/AuthProvider.jsx";
import { PERMISSIONS } from "@/app/permissions";

export function useCountryAbilities() {
    const { can } = useAuth();

    return {
        canCreate: can(PERMISSIONS.countryCreate),
        canStatus: can(PERMISSIONS.countryStatus),
        canUpdate: can(PERMISSIONS.countryUpdate),
        canView: can(PERMISSIONS.countryView),
    };
}

export function useRegionAbilities() {
    const { can } = useAuth();

    return {
        canCreate: can(PERMISSIONS.regionCreate),
        canStatus: can(PERMISSIONS.regionStatus),
        canUpdate: can(PERMISSIONS.regionUpdate),
        canView: can(PERMISSIONS.regionView),
    };
}

export function useAgencyAbilities() {
    const { can } = useAuth();

    return {
        canCreate: can(PERMISSIONS.agencyCreate),
        canDelete: can(PERMISSIONS.agencyDelete),
        canSalaryAdjust: can(PERMISSIONS.hostSalarySettlementSettle),
        canStatus: can(PERMISSIONS.agencyStatus),
        canView: can(PERMISSIONS.agencyView),
    };
}

export function useHostAbilities() {
    const { can } = useAuth();

    return {
        canSalaryAdjust: can(PERMISSIONS.hostSalarySettlementSettle),
        canView: can(PERMISSIONS.hostView),
    };
}

export function useBDAbilities() {
    const { can } = useAuth();

    return {
        canCreate: can(PERMISSIONS.bdCreate),
        canSalaryAdjust: can(PERMISSIONS.hostSalarySettlementSettle),
        canUpdate: can(PERMISSIONS.bdUpdate),
        canView: can(PERMISSIONS.bdView),
    };
}

export function useCoinSellerAbilities() {
    const { can } = useAuth();

    return {
        canCreate: can(PERMISSIONS.coinSellerCreate),
        canExchangeRate: can(PERMISSIONS.coinSellerExchangeRate),
        canLedger: can(PERMISSIONS.coinSellerLedgerView),
        canStockCredit: can(PERMISSIONS.coinSellerStockCredit),
        canUpdate: can(PERMISSIONS.coinSellerUpdate),
        canView: can(PERMISSIONS.coinSellerView),
    };
}

export function useCoinSellerSubApplicationAbilities() {
    const { can } = useAuth();

    return {
        canAudit: can(PERMISSIONS.coinSellerSubApplicationAudit),
        canView: can(PERMISSIONS.coinSellerSubApplicationView),
    };
}

export function useHostWithdrawalAbilities() {
    const { can } = useAuth();

    return {
        canView: can(PERMISSIONS.hostWithdrawalView),
    };
}
