Compare commits
1 Commits
dbdebae45e
...
core/route
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a707d2785f |
@@ -16,11 +16,28 @@ router.get("/", (req,res) => {
|
||||
<form action="/new-purchase/file" method="POST" enctype="multipart/form-data">
|
||||
<input type="file" name="image" multiple>
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>`;
|
||||
</form>
|
||||
<form action="/new-purchase/new" method="POST">
|
||||
<label for="nom_produit">Nom du produit:</label>
|
||||
<input type="text" name="nom_produit" >
|
||||
</br>
|
||||
<label for="quantite">Quantité:</label>
|
||||
<input type="text" name="quantite" >
|
||||
</br>
|
||||
<label for="prixHT">Prix HT:</label>
|
||||
<input type="text" name="prixHT" >
|
||||
</br>
|
||||
<label for="tva">TVA:</label>
|
||||
<input type="text" name="tva" >
|
||||
</br>
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
`;
|
||||
|
||||
res.send(html);
|
||||
});
|
||||
|
||||
// gère la réception d'un ou de plusieurs fichiers PDF
|
||||
router.post("/file", async (req,res) => {
|
||||
try {
|
||||
const files = await file_form_handler(req);
|
||||
@@ -51,6 +68,23 @@ router.post("/file", async (req,res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// gère la récéption de produit saisie manuellement
|
||||
router.post("/new", async (req, res) => {
|
||||
const nom_produit : string = req.body.nom_produit ;
|
||||
const quantite : number = Number(req.body.quantite);
|
||||
const prixHT : number = Number(req.body.prixHT);
|
||||
const tva : string = req.body.tva;
|
||||
|
||||
res.send({
|
||||
[nom_produit]: {
|
||||
quantité: quantite,
|
||||
prixHT: prixHT,
|
||||
TVA: tva
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// fonction pour gérer la récéption des fichier par un form
|
||||
function file_form_handler(req: ExpressRequest): Promise<Files> {
|
||||
return new Promise<Files>((resolve, reject) => {
|
||||
|
||||
Reference in New Issue
Block a user