on creation callback

This commit is contained in:
counterweight 2025-03-30 19:05:09 +02:00
parent 95dd754992
commit 5f774dc475
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -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'
);