create offer stitched with backend

This commit is contained in:
counterweight 2025-02-26 00:48:16 +01:00
parent 4eef0a57e0
commit b430b42b60
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
5 changed files with 37 additions and 14 deletions

View file

@ -19,11 +19,11 @@ const OfferDetailsSet = sequelize.define(
allowNull: false,
},
premium: {
type: DataTypes.NUMBER,
type: DataTypes.DECIMAL(5, 2),
allowNull: false,
},
trade_amount_eur: {
type: DataTypes.NUMBER,
type: DataTypes.INTEGER,
allowNull: false,
},
location_details: {

View file

@ -115,14 +115,13 @@
}
#button-increase-premium {
border-top-right-radius: 10px
border-top-right-radius: 10px;
}
#button-decrease-premium {
border-bottom-right-radius: 10px
border-bottom-right-radius: 10px;
}
.premium-button {
width: 100%;
height: 50%;
@ -184,10 +183,10 @@
}
.place-and-time-box {
height: 100px;
width: 30%;
min-width: 200px;
resize: none;
height: 100px;
width: 30%;
min-width: 200px;
resize: none;
}
.checkbox-row {

View file

@ -223,7 +223,7 @@ router.post(
attachPublicKeyMiddleware,
async (req, res) => {
const publicKey = req.cookies.publicKey;
const { offerDetails } = req.body.offerDetails;
const offerDetails = req.body.offerDetails;
await offerService.createOffer(publicKey, offerDetails);

View file

@ -1,6 +1,30 @@
const uuid = require('uuid');
const OfferCreated = require('../models/OfferCreated');
const OfferDetailsSet = require('../models/OfferDetailsSet');
async function createOffer(publicKey, offerDetails) {
console.log('oui oui, je suis offer creation oui');
console.log(publicKey);
console.log(offerDetails);
const offerCreated = await OfferCreated.create({
uuid: uuid.v7(),
public_key: publicKey,
created_at: new Date().toISOString(),
});
const offerDetailsSet = await OfferDetailsSet.create({
uuid: uuid.v7(),
offer_uuid: offerCreated.uuid,
wants: offerDetails.wants,
premium: offerDetails.premium,
trade_amount_eur: offerDetails.trade_amount_eur,
location_details: offerDetails.location_details,
time_availability_details: offerDetails.time_availability_details,
show_offer_to_trusted: offerDetails.show_offer_to_trusted,
show_offer_to_trusted_trusted: offerDetails.show_offer_to_trusted_trusted,
show_offer_to_all_members: offerDetails.show_offer_to_all_members,
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: new Date().toISOString(),
});
}
module.exports = createOffer;
module.exports = { createOffer };