Skip to content

Commit

Permalink
Merge pull request #22 from BaptisteBuvron/temp_admin
Browse files Browse the repository at this point in the history
correction admin
  • Loading branch information
BaptisteBuvron committed Jun 21, 2023
2 parents 3bb234e + e8e73da commit 80f4647
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
Expand All @@ -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) => {
Expand Down
23 changes: 23 additions & 0 deletions app/repository/UserRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/routes/AdminRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
91 changes: 91 additions & 0 deletions app/views/admin/ancienneDemande.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<%- include('../partials/adminHeader.ejs') %>.

<div class="container col-xxl-8 px-4 py-5">
<div class="row">
<div class="card shadow-sm">
<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Image création d'entreprise</title><rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef" dy=".3em"></text></svg>
<div class="card-body">
<h3 class="mb-3 text-center">Demande</h3>
<form class="needs-validation" novalidate="">
<div class="row g-3">
<div class="col-sm-6">
<label class="form-label fw-bold">Nom</label>
<p><%= user.nom %></p>
</div>

<div class="col-sm-6">
<label class="form-label fw-bold">Prénom</label>
<p><%= user.prenom %></p>
</div>

<div class="col-md-6">
<label class="form-label fw-bold">Courriel</label>
<p><%= user.email %></p>
</div>

<div class="col-md-4">
<label class="form-label fw-bold">Téléphone</label>
<p><%= user.telephone %></p>
</div>

<div class="col-md-4">
<label class="form-label fw-bold">Date</label>
<p><%= user.dateCreation %></p>
</div>

<div class="col-md-4">
<label class="form-label fw-bold">Statut</label>
<p class="<%= user.statut === 1 ? 'text-success' : 'text-danger' %>"><%= user.statut === 1 ? 'Actif' : 'Inactif' %></p>
</div>

<div class="col-md-4">
<label class="form-label fw-bold">Rôle</label>
<p><%= user.role %></p>
</div>

<div class="col-md-4">
<label class="form-label fw-bold">Demande à rejoindre une organisation</label>
<p><%= user.demande_organisation %></p>
</div>
</div>

<hr class="my-4">

<% if (user.organisation) { %>
<h3 class="mb-3 text-center">Organisation</h3>
<div class="row g-3">
<div class="col-md-4">
<label class="form-label fw-bold">Entreprise</label>
<p><%= user.organisation.nom %></p>
</div>
<div class="col-sm-4">
<label class="form-label fw-bold">Siège social</label>
<p><%= user.organisation.siege %></p>
</div>
<div class="col-sm-2">
<label class="form-label fw-bold">Type</label>
<p><%= user.organisation.type %></p>
</div>
<div class="col-md-2">
<label class="form-label fw-bold">Siren</label>
<p><%= user.organisation.siren %></p>
</div>
</div>
<% } %>

<hr class="my-4">

<div class="d-flex gap-2 justify-content-center py-2">
<a href="/admin/demandes" class="btn btn-primary">Retour</a>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion app/views/admin/demandes.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<td><%= user.prenom %></td>
<td><%= user.organisation.nom %></td>
<td>
<a href="/admin/demande/<%= user.email %>"
<a href="/admin/ancienneDemande/<%= user.email %>"
class="btn btn-outline-primary btn-sm">Détails</a>
</td>
<td class="<%= user.demande_organisation === 'acceptation' ? 'text-success' : (user.demande_organisation === 'refus' ? 'text-danger' : '') %>">
Expand Down
2 changes: 2 additions & 0 deletions app/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
</div>
<div class="col-lg-6">
<h1 class="display-5 fw-bold lh-1 mb-3">Site de recrutement</h1>
<% if(typeof userLogged === 'undefined'){ %>
<div class="d-grid gap-2 d-md-flex justify-content-md-start">
<a type="button" class="btn btn-primary btn-lg px-4 me-md-2" href="/login">Se connecter pour voir
les offres</a>
</div>
<% } %>
</div>
</div>
<div class="row">
Expand Down

0 comments on commit 80f4647

Please sign in to comment.