fe can read from back

This commit is contained in:
counterweight 2025-03-01 23:18:18 +01:00
parent 9e2af37158
commit 0e0a094dc8
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 48 additions and 2 deletions

View file

@ -24,6 +24,8 @@ app.use('/api', apiRoutes);
app.use(express.static(path.join(__dirname, 'public')));
app.disable('etag'); //avoids 304 responses
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});

View file

@ -172,6 +172,50 @@ async function publishOffer() {
toggleCreateOfferControls();
}
class Offer {
constructor(offerData) {
this.uuid = offerData.uuid;
this.public_key = offerData.public_key;
this.wants = offerData.wants;
this.premium = offerData.premium;
this.trade_amount_eur = offerData.trade_amount_eur;
this.location_details = offerData.location_details;
this.time_availability_details = offerData.time_availability_details;
this.show_offer_to_trusted = offerData.show_offer_to_trusted;
this.show_offer_to_trusted_trusted =
offerData.show_offer_to_trusted_trusted;
this.show_offer_to_all_members = offerData.show_offer_to_all_members;
this.is_onchain_accepted = offerData.is_onchain_accepted;
this.is_lightning_accepted = offerData.is_lightning_accepted;
this.are_big_notes_accepted = offerData.are_big_notes_accepted;
this.created_at = offerData.created_at;
this.last_updated_at = offerData.last_updated_at;
}
}
class MyOffers {
constructor() {
this.offers = [];
}
async getOffersFromApi() {
const offersResponse = await fetch('/api/publickey-offers');
if (!offersResponse.ok) {
this.offers = [];
}
const offersData = (await offersResponse.json()).data;
if (offersResponse.ok) {
for (const record of offersData) {
this.offers.push(new Offer(record));
}
}
}
async render() {}
}
buttonStartCreateOffer.addEventListener('click', () => {
toggleCreateOfferControls();
});

View file

@ -51,8 +51,6 @@ async function getOffersByPublicKey(publicKey) {
order: [['created_at', 'DESC']],
});
console.log(offerDetails);
offersToReturn.push({
uuid: someOffer.uuid,
public_key: someOffer.public_key,
@ -68,6 +66,8 @@ async function getOffersByPublicKey(publicKey) {
is_onchain_accepted: offerDetails.is_onchain_accepted,
is_lightning_accepted: offerDetails.is_lightning_accepted,
are_big_notes_accepted: offerDetails.are_big_notes_accepted,
created_at: someOffer.created_at,
last_updated_at: offerDetails.created_at,
});
}
}