diff --git a/src/front/pages/offers.js b/src/front/pages/offers.js index f0435a3..1414e0f 100644 --- a/src/front/pages/offers.js +++ b/src/front/pages/offers.js @@ -9,6 +9,7 @@ const BitcoinMethodCheckboxes = require('../components/BitcoinMethodCheckboxes') const TrustCheckboxes = require('../components/TrustCheckboxes'); const BigNotesCheckbox = require('../components/BigNotesCheckbox'); +const offerCreatedPopup = document.getElementById('offer-created-confirmation'); function toggleOfferCreatedAlert() { offerCreatedPopup.classList.remove('max-size-zero'); offerCreatedPopup.classList.add('revealed'); @@ -21,9 +22,12 @@ function toggleOfferCreatedAlert() { } class CreateOfferModal { - constructor({ parentElement }) { + // Actual creation logic to be provided by a service + // Stop relying on IDs + constructor({ parentElement, onCreationCallback }) { this.element = null; this.parentElement = parentElement; + this.onCreationCallback = onCreationCallback; this.publishOfferButton = null; this.buyOrSellButtonGroup = null; @@ -131,8 +135,7 @@ class CreateOfferModal { id: 'button-submit-offer', onClickCallback: async () => { await this.createOffer(); - //await myOffers.getOffersFromApi(); - //await myOffers.render(); + await this.onCreationCallback(); }, }); this.publishOfferButton.render(); @@ -254,6 +257,10 @@ class CreateOfferModal { function offersPage() { const createOfferModal = new CreateOfferModal({ parentElement: document.body, + onCreationCallback: async () => { + await myOffers.getOffersFromApi(); + await myOffers.render(); + }, }); createOfferModal.render(); // ----------- @@ -278,9 +285,6 @@ function offersPage() { ); const viewMyOffersRoot = document.getElementById('view-my-offers-root'); - const offerCreatedPopup = document.getElementById( - 'offer-created-confirmation' - ); const offerDeletedPopup = document.getElementById( 'offer-deleted-confirmation' );