54 lines
2.3 KiB
JavaScript
54 lines
2.3 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Share card settings (single-row admin config for prediction + wallet op sharing).
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getSettings = getSettings;
|
|
exports.updateSettings = updateSettings;
|
|
const connection_1 = require("../db/connection");
|
|
const SELECT_COLS = `id, enabled, allow_main_wallet, allow_bonus_wallet, allow_test_wallet,
|
|
allow_won, allow_lost, allow_refunded,
|
|
wallet_ops_enabled, allow_deposit, allow_withdrawal, allow_transfer,
|
|
test_wallet_share_requires_real_deposit,
|
|
updated_at`;
|
|
async function getSettings() {
|
|
const rows = await (0, connection_1.query)(`SELECT ${SELECT_COLS} FROM share_card_settings WHERE id = 1`);
|
|
if (!rows[0]) {
|
|
throw new Error('Share card settings are not configured');
|
|
}
|
|
return rows[0];
|
|
}
|
|
async function updateSettings(input) {
|
|
const current = await getSettings();
|
|
const rows = await (0, connection_1.query)(`UPDATE share_card_settings SET
|
|
enabled = COALESCE($1, enabled),
|
|
allow_main_wallet = COALESCE($2, allow_main_wallet),
|
|
allow_bonus_wallet = COALESCE($3, allow_bonus_wallet),
|
|
allow_test_wallet = COALESCE($4, allow_test_wallet),
|
|
allow_won = COALESCE($5, allow_won),
|
|
allow_lost = COALESCE($6, allow_lost),
|
|
allow_refunded = COALESCE($7, allow_refunded),
|
|
wallet_ops_enabled = COALESCE($8, wallet_ops_enabled),
|
|
allow_deposit = COALESCE($9, allow_deposit),
|
|
allow_withdrawal = COALESCE($10, allow_withdrawal),
|
|
allow_transfer = COALESCE($11, allow_transfer),
|
|
test_wallet_share_requires_real_deposit = COALESCE($12, test_wallet_share_requires_real_deposit),
|
|
updated_at = NOW()
|
|
WHERE id = 1
|
|
RETURNING ${SELECT_COLS}`, [
|
|
input.enabled ?? null,
|
|
input.allowMainWallet ?? null,
|
|
input.allowBonusWallet ?? null,
|
|
input.allowTestWallet ?? null,
|
|
input.allowWon ?? null,
|
|
input.allowLost ?? null,
|
|
input.allowRefunded ?? null,
|
|
input.walletOpsEnabled ?? null,
|
|
input.allowDeposit ?? null,
|
|
input.allowWithdrawal ?? null,
|
|
input.allowTransfer ?? null,
|
|
input.testWalletShareRequiresRealDeposit ?? null,
|
|
]);
|
|
return rows[0] ?? current;
|
|
}
|
|
//# sourceMappingURL=shareCardRepository.js.map
|