repare login

add search in sale detail
add refresh button in sale detail
This commit is contained in:
2024-11-26 15:10:38 +01:00
parent 848fc4909e
commit 23dbfff014
41 changed files with 192 additions and 127 deletions
View File
+48 -20
View File
@@ -4,43 +4,71 @@ const { LotDb } = require("../services/lotDb");
const lotDb = new LotDb();
const { SaleDb } = require("../services/saleDb");
const saleDb = new SaleDb();
const {Agent} = require('../services/agent');
const agent = new Agent();
const ApiURL = "http://host.docker.internal:3020/api";
// scrapping
// exports.getInfos = asyncHandler(async (req, res, next) => {
// let url = req.params.url
// url = encodeURIComponent(url);
// fetch(ApiURL+'/lot/getInfos/'+url)
// .then(response => response.json())
// .then(data => {
// res.json(data);
// })
// .catch(error => {
// console.error(error);
// res.json({error: error});
// });
// });
exports.getInfos = asyncHandler(async (req, res, next) => {
let url = req.params.url
url = encodeURIComponent(url);
fetch(ApiURL+'/lot/getInfos/'+url)
.then(response => response.json())
let url = req.params.url
url = encodeURIComponent(url);
agent.getLotInfos(url)
.then(data => {
res.json(data);
return res.status(200).json(data);
})
.catch(error => {
console.error(error);
res.json({error: error});
});
return res.status(500).send({error: error});
});
});
// exports.getPictures = asyncHandler(async (req, res, next) => {
// let url = req.params.url
// url = encodeURIComponent(url);
// fetch(ApiURL+'/lot/getPictures/'+url)
// .then(response => response.json())
// .then(data => {
// res.json(data);
// })
// .catch(error => {
// console.error(error);
// res.json({error: error});
// });
// });
exports.getPictures = asyncHandler(async (req, res, next) => {
let url = req.params.url
url = encodeURIComponent(url);
fetch(ApiURL+'/lot/getPictures/'+url)
.then(response => response.json())
.then(data => {
res.json(data);
})
.catch(error => {
console.error(error);
res.json({error: error});
});
agent.getPictures(url)
.then(data => {
return res.status(200).json(data);
})
.catch(error => {
console.error(error);
return res.status(500).send({error: error});
});
});
exports.getLotsBySale = asyncHandler(async (req, res, next) => {
let id = req.params.id
-1
View File
@@ -40,7 +40,6 @@ app.use(session({
const passport = require('passport');
app.use(passport.initialize());
app.use(passport.session());
app.use('/', require('./routes/auth'));
+27
View File
@@ -99,6 +99,33 @@ const Agent = class
});
}
async getLotInfos(url){
return new Promise((resolve, reject) => {
url = encodeURIComponent(url);
this.request(this.ApiAgentURL+'/lot/getInfos/'+url, 'GET')
.then(data => {
resolve(data);
})
.catch(error => {
reject(error);
});
});
}
async getPictures(url){
return new Promise((resolve, reject) => {
url = encodeURIComponent(url);
this.request(this.ApiAgentURL+'/lot/getPictures/'+url, 'GET')
.then(data => {
resolve(data);
})
.catch(error => {
reject(error);
});
});
}
}
module.exports = {Agent};