From e8e73dafdc3b755271e0275183b8cf5dd4bd4306 Mon Sep 17 00:00:00 2001 From: soudarsane Date: Wed, 21 Jun 2023 22:49:31 +0200 Subject: [PATCH] correction admin --- app/controllers/AdminController.ts | 10 +++- app/repository/UserRepository.ts | 23 ++++++++ app/routes/AdminRouter.ts | 1 + app/views/admin/ancienneDemande.ejs | 91 +++++++++++++++++++++++++++++ app/views/admin/demandes.ejs | 2 +- app/views/index.ejs | 2 + 6 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/ancienneDemande.ejs diff --git a/app/controllers/AdminController.ts b/app/controllers/AdminController.ts index 715e1ce..5997f9b 100644 --- a/app/controllers/AdminController.ts +++ b/app/controllers/AdminController.ts @@ -99,7 +99,7 @@ export class AdminController { } static demandes(req: express.Request, res: express.Response) { - UserRepository.getRecruiterDemand().then((users: User[]) => { + UserRepository.getNewRecruiterDemand().then((users: User[]) => { UserRepository.getOldRecruiterDemand().then((oldUsers: User[]) => { OrganisationRepository.getAll().then((organisations : Organisation[]) => { res.render("admin/demandes", {title: "Demandes", users: users, organisations: organisations, oldUsers: oldUsers, userLogged: loggedInNoRedirection(req, res)}); @@ -116,6 +116,14 @@ export class AdminController { }) } + static ancienneDemande(req: express.Request, res: express.Response) { + let email = req.params.email; + UserRepository.getById(email).then((user: User) => { + console.log(user); + res.render("admin/ancienneDemande", {title: "Demande", user: user, userLogged: loggedInNoRedirection(req, res)}); + }) + } + static async accepterDemande(req: express.Request, res: express.Response) { let email = req.params.email; await UserRepository.setDemandAccepted(email).then((email) => { diff --git a/app/repository/UserRepository.ts b/app/repository/UserRepository.ts index 1cd1629..01abcde 100644 --- a/app/repository/UserRepository.ts +++ b/app/repository/UserRepository.ts @@ -137,6 +137,29 @@ export class UserRepository { ); } + static getNewRecruiterDemand(): Promise<[User]> { + const query = `SELECT u.email, u.nom, u.prenom, o.siren, o.nom as organisation, o.type, o.siege + FROM ${UserRepository.tableName} u + INNER JOIN ${OrganisationRepository.tableName} o using (siren) + WHERE u.demande_organisation = 'En cours'`; + return new Promise<[User]>( + (resolve, reject) => + pool.query(query, (err, result) => { + if (err) { + return reject(err); + } + if(result[0]){ + console.log(result[0]); + let organisation = new Organisation(result[0].siren, result[0].organisation, result[0].type, result[0].siege); + result[0].organisation = organisation; + console.log(result); + } + return resolve(result); + } + ) + ); + } + static getRecruiterDemand(): Promise<[User]> { const query = `SELECT u.email, u.nom, u.prenom, o.siren, o.nom as organisation, o.type, o.siege FROM ${UserRepository.tableName} u diff --git a/app/routes/AdminRouter.ts b/app/routes/AdminRouter.ts index 77ec0dd..b6a18fc 100644 --- a/app/routes/AdminRouter.ts +++ b/app/routes/AdminRouter.ts @@ -19,6 +19,7 @@ adminRouter.get("/supprimerUtilisateur/:email", AdminController.supprimerUtilisa adminRouter.get("/demandes", AdminController.demandes); adminRouter.get("/demande/:email", AdminController.demande); +adminRouter.get("/ancienneDemande/:email", AdminController.ancienneDemande); adminRouter.get("/accepterDemande/:email", AdminController.accepterDemande); adminRouter.get("/refuserDemande/:email", AdminController.refuserDemande); adminRouter.get("/offres", AdminController.offres); diff --git a/app/views/admin/ancienneDemande.ejs b/app/views/admin/ancienneDemande.ejs new file mode 100644 index 0000000..8ad1bf9 --- /dev/null +++ b/app/views/admin/ancienneDemande.ejs @@ -0,0 +1,91 @@ +<%- include('../partials/adminHeader.ejs') %>. + +
+
+
+ Image création d'entreprise +
+

Demande

+
+
+
+ +

<%= user.nom %>

+
+ +
+ +

<%= user.prenom %>

+
+ +
+ +

<%= user.email %>

+
+ +
+ +

<%= user.telephone %>

+
+ +
+ +

<%= user.dateCreation %>

+
+ +
+ +

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

+
+ +
+ +

<%= user.role %>

+
+ +
+ +

<%= user.demande_organisation %>

+
+
+ +
+ + <% if (user.organisation) { %> +

Organisation

+
+
+ +

<%= user.organisation.nom %>

+
+ +
+ +

<%= user.organisation.siege %>

+
+ +
+ +

<%= user.organisation.type %>

+
+ +
+ +

<%= user.organisation.siren %>

+
+
+ + <% } %> + +
+ +
+ Retour +
+
+
+
+
+
+ + diff --git a/app/views/admin/demandes.ejs b/app/views/admin/demandes.ejs index 6398d08..18e8fa5 100644 --- a/app/views/admin/demandes.ejs +++ b/app/views/admin/demandes.ejs @@ -90,7 +90,7 @@ <%= user.prenom %> <%= user.organisation.nom %> - Détails diff --git a/app/views/index.ejs b/app/views/index.ejs index a70d710..c5f8179 100644 --- a/app/views/index.ejs +++ b/app/views/index.ejs @@ -9,10 +9,12 @@

Site de recrutement

+ <% if(typeof userLogged === 'undefined'){ %> + <% } %>