From 523819f37de62018c7a5e8313b3a5bba5c0bb77d Mon Sep 17 00:00:00 2001 From: soudarsane Date: Tue, 20 Jun 2023 18:08:24 +0200 Subject: [PATCH 1/4] change of display and date to the right format --- app/controllers/AdminController.ts | 43 ++++++++++++ app/package-lock.json | 36 ++++++++-- app/package.json | 2 + app/repository/OfferRepository.ts | 2 + app/routes/AdminRouter.ts | 1 + app/views/admin/offre.ejs | 35 +++++----- app/views/admin/utilisateur.ejs | 103 ++++++++++++++++++----------- app/views/partials/adminHeader.ejs | 2 +- app/views/partials/header.ejs | 14 ++-- 9 files changed, 169 insertions(+), 69 deletions(-) diff --git a/app/controllers/AdminController.ts b/app/controllers/AdminController.ts index c8fc7dd..4a40bf6 100644 --- a/app/controllers/AdminController.ts +++ b/app/controllers/AdminController.ts @@ -140,5 +140,48 @@ export class AdminController { res.render("admin/offre", {title: "Offre", offer: offer, userLogged: loggedInNoRedirection(req, res)}); }) } + + static async modifierOffre(req: express.Request, res: express.Response) { + if (req.method === "POST") { + const alerts: Alert[] = []; + let user = new User( + req.body.email, + req.body.nom, + req.body.prenom, + req.body.telephone, + req.body.date_creation, + req.body.statut, + "", + req.body.role, + null, + null, + undefined, + ); + + await UserRepository.update(user).then((user: User) => { + let alert = new Alert("success", "L'utilisateur a été modifié"); + alerts.push(alert); + }) + .catch((err) => { + let alert = new Alert("danger", "L'utilisateur n'a pas été modifié"); + alerts.push(alert); + console.log(err); + }); + UserRepository.getById(req.body.email).then((user: User) => { + console.log(user); + res.render("admin/utilisateur", {title: "Utilisateur", user: user, alerts: alerts, userLogged: loggedInNoRedirection(req, res)}); + }) + }else{ + let email = req.params.email; + UserRepository.getById(email).then((user: User) => { + console.log(user); + res.render("admin/modifierUtilisateur", { + title: "Modifier un utilisateur", + user: user, + userLogged: loggedInNoRedirection(req, res) + }); + }) + } + } } diff --git a/app/package-lock.json b/app/package-lock.json index c6a5fd9..99da544 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -12,10 +12,12 @@ "bcrypt": "^5.1.0", "body-parser": "^1.20.2", "cors": "^2.8.5", + "date-fns": "^2.30.0", "dotenv": "^16.0.3", "ejs": "^3.1.9", "express": "^4.18.2", "express-session": "^1.17.3", + "moment": "^2.29.4", "multer": "^1.4.5-lts.1", "mysql": "^2.18.1", "passport": "^0.6.0", @@ -35,6 +37,17 @@ "typescript": "^4.9.5" } }, + "node_modules/@babel/runtime": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz", + "integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==", + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@mapbox/node-pre-gyp": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", @@ -656,10 +669,12 @@ } }, "node_modules/date-fns": { - "version": "2.29.3", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", - "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", - "dev": true, + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, "engines": { "node": ">=0.11" }, @@ -1462,6 +1477,14 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1849,6 +1872,11 @@ "node": ">=8.10.0" } }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", diff --git a/app/package.json b/app/package.json index 790fe14..385ded8 100644 --- a/app/package.json +++ b/app/package.json @@ -23,10 +23,12 @@ "bcrypt": "^5.1.0", "body-parser": "^1.20.2", "cors": "^2.8.5", + "date-fns": "^2.30.0", "dotenv": "^16.0.3", "ejs": "^3.1.9", "express": "^4.18.2", "express-session": "^1.17.3", + "moment": "^2.29.4", "multer": "^1.4.5-lts.1", "mysql": "^2.18.1", "passport": "^0.6.0", diff --git a/app/repository/OfferRepository.ts b/app/repository/OfferRepository.ts index 54d9689..952484d 100644 --- a/app/repository/OfferRepository.ts +++ b/app/repository/OfferRepository.ts @@ -71,6 +71,8 @@ export class OfferRepository { if (result.length == 0 || err) { return reject("Not found"); } + result[0].date_validite = new Date(result[0].date_validite).toLocaleDateString('fr-FR') + let organisation = new Organisation(result[0].siren, result[0].nom, result[0].type, result[0].siege); let ficheDePoste = new FicheDePoste(result[0].fiche, result[0].status, result[0].responsable, result[0].type_metier, result[0].lieu, result[0].teletravail, result[0].nbheure, result[0].salaire, result[0].description, result[0].siren, organisation); let offer = new OffreDePoste(result[0].numero, result[0].etat, result[0].date_validite, result[0].nb_piece, result[0].liste_piece, ficheDePoste); diff --git a/app/routes/AdminRouter.ts b/app/routes/AdminRouter.ts index c246de2..877480a 100644 --- a/app/routes/AdminRouter.ts +++ b/app/routes/AdminRouter.ts @@ -23,5 +23,6 @@ adminRouter.get("/accepterDemande/:email", AdminController.accepterDemande); adminRouter.get("/refuserDemande/:email", AdminController.refuserDemande); adminRouter.get("/offres", AdminController.offres); adminRouter.get("/offre/:numero", AdminController.offre); +adminRouter.get("/modifierOffre/:numero", AdminController.modifierOffre); diff --git a/app/views/admin/offre.ejs b/app/views/admin/offre.ejs index 11b106b..5554a6e 100644 --- a/app/views/admin/offre.ejs +++ b/app/views/admin/offre.ejs @@ -1,5 +1,4 @@ - -<%- include('../partials/adminHeader.ejs') %>. +<%- include('../partials/adminHeader.ejs') %>
@@ -11,17 +10,17 @@
-

<%= offer.ficheDePoste.typeMetier %>

+
-

<%= offer.ficheDePoste.organisation.nom %>

+
-

<%= offer.ficheDePoste.organisation.siege %>

+

@@ -39,7 +38,7 @@

Publication

-

<%= offer.dateValidite %>

+
@@ -48,35 +47,35 @@
- -

<%= offer.ficheDePoste.typeMetier %>

+ +
- -

<%= offer.ficheDePoste.organisation.nom %>

+ +
- -

<%= offer.ficheDePoste.organisation.siege %>

+ +
- -

<%= offer.ficheDePoste.organisation.siege %>

+ +
- -

<%= offer.ficheDePoste.organisation.siege %>

+ +

diff --git a/app/views/admin/utilisateur.ejs b/app/views/admin/utilisateur.ejs index b9691e8..a78acbe 100644 --- a/app/views/admin/utilisateur.ejs +++ b/app/views/admin/utilisateur.ejs @@ -1,51 +1,66 @@ -<%- include('../partials/adminHeader.ejs') %>. +<%- include('../partials/adminHeader.ejs') %>
- Image création d'entreprise

Informations Utilisateur

- -

<%= user.nom %>

+
+ + +
- -

<%= user.prenom %>

+
+ + +
- -

<%= user.email %>

+
+ + +
- -

<%= user.telephone %>

+
+ + +
- -

<%= user.dateCreation %>

+
+ + +
- -

<%= user.statut === 1 ? 'Actif' : 'Inactif' %>

+
+ + +
- -

<%= user.role %>

+
+ + +
- -

<%= user.demande_organisation ? user.demande_organisation : 'Aucune' %>

+
+ + +
@@ -54,26 +69,33 @@

Organisation

- -

<%= user.organisation.nom %>

+
+ + +
-
+
+
-

<%= user.organisation.siege %>

+
+
-
+
+
-

<%= user.organisation.type %>

+
+
-
+
+
-

<%= user.organisation.siren %>

+
+
- <% } %>
@@ -87,23 +109,24 @@
+
+ <%- include('alert.ejs') %> From d1b9ec5abdc2a0579bf1fdd08f3d90799757f6ef Mon Sep 17 00:00:00 2001 From: soudarsane Date: Wed, 21 Jun 2023 08:38:33 +0200 Subject: [PATCH 3/4] =?UTF-8?q?am=C3=A9lioration=20de=20l'affichage=20cot?= =?UTF-8?q?=C3=A9=20admin=20en=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/partials/adminHeader.ejs | 19 +++++++++++++------ app/views/partials/header.ejs | 10 +++++++--- app/views/partials/recruteurHeader.ejs | 11 +++++++++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/views/partials/adminHeader.ejs b/app/views/partials/adminHeader.ejs index 004dfd0..757e068 100644 --- a/app/views/partials/adminHeader.ejs +++ b/app/views/partials/adminHeader.ejs @@ -35,12 +35,19 @@
- +
<%- include('alert.ejs') %> diff --git a/app/views/partials/header.ejs b/app/views/partials/header.ejs index f6d8137..a5b9b3f 100644 --- a/app/views/partials/header.ejs +++ b/app/views/partials/header.ejs @@ -23,7 +23,7 @@ - <% if(typeof userLogged !== 'undefined' && userLogged){ %> + <% if(typeof userLogged !== 'undefined' && userLogged && userLogged.role === 'Candidat'){ %> @@ -40,8 +40,12 @@ <% } %> diff --git a/app/views/partials/recruteurHeader.ejs b/app/views/partials/recruteurHeader.ejs index d017b28..ce9d938 100644 --- a/app/views/partials/recruteurHeader.ejs +++ b/app/views/partials/recruteurHeader.ejs @@ -36,8 +36,15 @@
From d22c8ec8e0c9a6bda860ed0dcddacdfdc95bf9b4 Mon Sep 17 00:00:00 2001 From: soudarsane Date: Wed, 21 Jun 2023 10:19:34 +0200 Subject: [PATCH 4/4] redirige vers lebon endroit --- app/routes/MainRouter.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/app/routes/MainRouter.ts b/app/routes/MainRouter.ts index e228efc..d804798 100644 --- a/app/routes/MainRouter.ts +++ b/app/routes/MainRouter.ts @@ -72,17 +72,8 @@ defaultRouter.post( return res.redirect(`/login?message=${info.message}`); } req.login(user, async () => { - let role = user.role; - let url; - if (role == "Administrateur") { - url="admin"; - } else if(role == "Recruteur"){ - url="recruteur"; - }else{ - url=""; - } - - return res.redirect(`/${url}`); + + return res.redirect(`/`); }); })(req, res, next); }