diff --git a/src/public/javascript/offers.js b/src/public/javascript/offers.js index 1879a8d..921bab6 100644 --- a/src/public/javascript/offers.js +++ b/src/public/javascript/offers.js @@ -8,6 +8,8 @@ const buyOrSellButtonGroup = document.getElementById( 'button-group-buy-or-sell' ); const buyOrSellButtons = buyOrSellButtonGroup.querySelectorAll('button'); +const buyButton = document.getElementById('button-buy-bitcoin'); +const sellButton = document.getElementById('button-sell-bitcoin'); const premiumValue = document.getElementById('premium-value'); const buttonIncreasePremium = document.getElementById( @@ -21,11 +23,24 @@ const buttonDecreasePremium = document.getElementById( const eurAmountInput = document.getElementById('input-eur-amount'); const btcAmountInput = document.getElementById('input-btc-amount'); +const placeInput = document.getElementById('place-input'); +const timeInput = document.getElementById('time-input'); + const onchainCheckbox = document.getElementById('onchain-checkbox'); const lightningCheckbox = document.getElementById('lightning-checkbox'); const btcMethodCheckboxes = [onchainCheckbox, lightningCheckbox]; +const mytrustedCheckbox = document.getElementById('my-trusted-checkbox'); +const mytrustedtrustdCheckbox = document.getElementById( + 'my-trusted-trusted-checkbox' +); +const allMembersCheckbox = document.getElementById('all-members-checkbox'); + +const bigNotesAcceptedCheckbox = document.getElementById( + 'large-bills-checkbox' +); + const publishOfferButton = document.getElementById('button-submit-offer'); function toggleCreateOfferControls() { @@ -99,20 +114,35 @@ function validateBitcoinMethodCheckboxes(clickedCheckbox) { } function publishOffer() { - // read info from all elements - // compose a json - // hit the endpoint + let wants; + if (buyButton.classList.contains('selected')) { + wants = 'BTC'; + } + if (sellButton.classList.contains('selected')) { + wants = 'EUR'; + } + + const premium = parseInt(premiumValue.innerText.match(/\d+/)[0]) / 100; + const trade_amount_eur = eurAmountInput.value; + const location_details = placeInput.value; + const time_availability_details = timeInput.value; + const is_onchain_accepted = onchainCheckbox.checked; + const is_lightning_accepted = lightningCheckbox.checked; + const are_big_notes_accepted = bigNotesAcceptedCheckbox.checked; const offerDetails = { - wants: 'BTC', - premium: '0', - trade_amount_eur: '100', - location_details: 'this and there', - time_availability_details: 'then and then', - is_onchain_accepted: true, - is_lightning_accepted: true, - are_big_notes_accepted: false, + wants, + premium, + trade_amount_eur, + location_details, + time_availability_details, + is_onchain_accepted, + is_lightning_accepted, + + are_big_notes_accepted, }; + + console.log(offerDetails); } buttonStartCreateOffer.addEventListener('click', () => {