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, allowNull: false,
}, },
premium: { premium: {
type: DataTypes.NUMBER, type: DataTypes.DECIMAL(5, 2),
allowNull: false, allowNull: false,
}, },
trade_amount_eur: { trade_amount_eur: {
type: DataTypes.NUMBER, type: DataTypes.INTEGER,
allowNull: false, allowNull: false,
}, },
location_details: { location_details: {

View file

@ -115,14 +115,13 @@
} }
#button-increase-premium { #button-increase-premium {
border-top-right-radius: 10px border-top-right-radius: 10px;
} }
#button-decrease-premium { #button-decrease-premium {
border-bottom-right-radius: 10px border-bottom-right-radius: 10px;
} }
.premium-button { .premium-button {
width: 100%; width: 100%;
height: 50%; height: 50%;

View file

@ -223,7 +223,7 @@ router.post(
attachPublicKeyMiddleware, attachPublicKeyMiddleware,
async (req, res) => { async (req, res) => {
const publicKey = req.cookies.publicKey; const publicKey = req.cookies.publicKey;
const { offerDetails } = req.body.offerDetails; const offerDetails = req.body.offerDetails;
await offerService.createOffer(publicKey, 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) { async function createOffer(publicKey, offerDetails) {
console.log('oui oui, je suis offer creation oui'); const offerCreated = await OfferCreated.create({
console.log(publicKey); uuid: uuid.v7(),
console.log(offerDetails); 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 };