use service to create offer
This commit is contained in:
parent
e046c8c118
commit
873493f697
3 changed files with 20 additions and 9 deletions
|
|
@ -10,13 +10,16 @@ const TrustCheckboxes = require('../components/TrustCheckboxes');
|
||||||
const BigNotesCheckbox = require('../components/BigNotesCheckbox');
|
const BigNotesCheckbox = require('../components/BigNotesCheckbox');
|
||||||
const PopupNotification = require('../components/PopupNotification');
|
const PopupNotification = require('../components/PopupNotification');
|
||||||
|
|
||||||
|
const offerService = require('../services/offerService');
|
||||||
|
|
||||||
class CreateOfferModal {
|
class CreateOfferModal {
|
||||||
// Actual creation logic to be provided by a service
|
// Actual creation logic to be provided by a service
|
||||||
// Stop relying on IDs
|
// Stop relying on IDs
|
||||||
constructor({ parentElement, onCreationCallback }) {
|
constructor({ parentElement, onCreationCallback, offerService }) {
|
||||||
this.element = null;
|
this.element = null;
|
||||||
this.parentElement = parentElement;
|
this.parentElement = parentElement;
|
||||||
this.onCreationCallback = onCreationCallback;
|
this.onCreationCallback = onCreationCallback;
|
||||||
|
this.offerService = offerService;
|
||||||
|
|
||||||
this.publishOfferButton = null;
|
this.publishOfferButton = null;
|
||||||
this.buyOrSellButtonGroup = null;
|
this.buyOrSellButtonGroup = null;
|
||||||
|
|
@ -230,13 +233,7 @@ class CreateOfferModal {
|
||||||
are_big_notes_accepted,
|
are_big_notes_accepted,
|
||||||
};
|
};
|
||||||
|
|
||||||
await fetch('/api/offer', {
|
await this.offerService.createOffer(offerDetails);
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ offerDetails }),
|
|
||||||
});
|
|
||||||
|
|
||||||
this.toggle();
|
this.toggle();
|
||||||
}
|
}
|
||||||
|
|
@ -262,6 +259,7 @@ function offersPage() {
|
||||||
await myOffers.render();
|
await myOffers.render();
|
||||||
offerCreatedPopup.displayTemporarily(3000);
|
offerCreatedPopup.displayTemporarily(3000);
|
||||||
},
|
},
|
||||||
|
offerService: offerService,
|
||||||
});
|
});
|
||||||
createOfferModal.render();
|
createOfferModal.render();
|
||||||
// -----------
|
// -----------
|
||||||
|
|
|
||||||
13
src/front/services/offerService.js
Normal file
13
src/front/services/offerService.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
const createOffer = async (offerDetails) => {
|
||||||
|
await fetch('/api/offer', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ offerDetails }),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createOffer,
|
||||||
|
};
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
<p>Vaya, no hay nada por aquí...</p>
|
<p>Vaya, no hay nada por aquí...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/javascript/offers.bundle.js"></script>
|
<script src="/javascript/offers.bundle.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue