diff --git a/src/public/javascript/offers.js b/src/public/javascript/offers.js index e7b5982..b7c8b0c 100644 --- a/src/public/javascript/offers.js +++ b/src/public/javascript/offers.js @@ -21,6 +21,14 @@ const buttonDecreasePremium = document.getElementById( const eurAmountInput = document.getElementById('input-eur-amount'); const btcAmountInput = document.getElementById('input-btc-amount'); +const onchainCheckbox = document.getElementById('onchain-checkbox'); +const lightningCheckbox = document.getElementById('lightning-checkbox'); +const btcMethodCheckboxesWarning = document.getElementById( + 'at-least-one-checkbox' +); + +const btcMethodCheckboxes = [onchainCheckbox, lightningCheckbox]; + function toggleCreateOfferControls() { createOfferControls.style.display = createOfferControls.style.display === 'block' ? 'none' : 'block'; @@ -82,6 +90,22 @@ function updateBtcInput() { btcAmountInput.value = formattedSatsAmount; } +function validateBitcoinMethodCheckboxes() { + let noneChecked = true; + + for (const aCheckbox of btcMethodCheckboxes) { + if (aCheckbox.checked) { + noneChecked = false; + } + } + + if (noneChecked) { + btcMethodCheckboxesWarning.style.display = 'block'; + } else { + btcMethodCheckboxesWarning.style.display = 'none'; + } +} + buttonStartCreateOffer.addEventListener('click', () => { toggleCreateOfferControls(); }); @@ -112,3 +136,9 @@ eurAmountInput.addEventListener('blur', () => { eurAmountInput.addEventListener('input', () => { eurAmountInput.value = eurAmountInput.value.replace(/[^0-9]/g, ''); }); + +for (btcMethodCheckbox of btcMethodCheckboxes) { + btcMethodCheckbox.addEventListener('input', () => { + validateBitcoinMethodCheckboxes(); + }); +} diff --git a/src/views/offers.ejs b/src/views/offers.ejs index 4bc7fc2..4198ab2 100644 --- a/src/views/offers.ejs +++ b/src/views/offers.ejs @@ -22,7 +22,7 @@ class="clickable" width="5%" /> -
Añade los detalles de tu oferta
+¿Quién puede ver la oferta?
+ + +