Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #23

Merged
merged 2 commits into from
Jun 21, 2023
Merged

Fix: #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class AdminController {
static utilisateurs(req: express.Request, res: express.Response) {
UserRepository.getAll().then((users: User[]) => {
OrganisationRepository.getAll().then((organisations : Organisation[]) => {
console.log(users);
res.render("admin/utilisateurs", { title: "Utilisateurs", organisations: organisations, users, userLogged: loggedInNoRedirection(req, res)});
});
});
Expand All @@ -31,7 +30,6 @@ export class AdminController {
static utilisateur(req: express.Request, res: express.Response) {
let email = req.params.email;
UserRepository.getById(email).then((user: User) => {
console.log(user);
res.render("admin/utilisateur", {title: "Utilisateur", user: user, userLogged: loggedInNoRedirection(req, res)});
})
}
Expand Down Expand Up @@ -63,13 +61,11 @@ export class AdminController {
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,
Expand Down Expand Up @@ -111,23 +107,20 @@ export class AdminController {
static demande(req: express.Request, res: express.Response) {
let email = req.params.email;
UserRepository.getById(email).then((user: User) => {
console.log(user);
res.render("admin/demande", {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) => {
console.log(email);
});
res.redirect("/admin/demandes");
}

static async refuserDemande(req: express.Request, res: express.Response) {
let email = req.params.email;
await UserRepository.setDemandRefused(email).then((email) => {
console.log(email);
});
res.redirect("/admin/demandes");
}
Expand All @@ -143,7 +136,6 @@ export class AdminController {
static offre(req: express.Request, res: express.Response) {
let numero = req.params.numero;
OfferRepository.getById(Number.parseInt(numero)).then((offer: OffreDePoste) => {
console.log(offer);
res.render("admin/offre", {title: "Offre", offer: offer, userLogged: loggedInNoRedirection(req, res)});
})
}
Expand Down Expand Up @@ -204,7 +196,6 @@ export class AdminController {
});

OfferRepository.getById(Number.parseInt(idOffre)).then((offer: OffreDePoste) => {
console.log(offer);
res.render("admin/offre", {title: "Offre", offer: offer, alerts: alerts, userLogged: loggedInNoRedirection(req, res)});
})
}else{
Expand All @@ -219,7 +210,6 @@ export class AdminController {
const alerts: Alert[] = [];
let numero = req.params.numero;
await OfferRepository.supprimer(Number.parseInt(numero)).then((suppression: boolean) => {
console.log(suppression);
let alert = new Alert("success", "L'offre a été supprimée");
alerts.push(alert);
}).catch((err) => {
Expand All @@ -228,7 +218,6 @@ export class AdminController {
alerts.push(alert);
});
OfferRepository.getAll().then((offers: OffreDePoste[]) => {
console.log(offers);
res.render("admin/offres", {title: "Offres", alerts: alerts, offers: offers, userLogged: loggedInNoRedirection(req, res)});
});
}
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/CandidatureController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class CandidatureController {
static candidater(req: express.Request, res: express.Response) {

//TODO Vérifier que l'utilisateur est bien un candidat
let user: User = new User('[email protected]', 'Tillai', 'Soudarsane', '0652645299', new Date('2020-10-10'), false, 'mdp', 'Candidat', "", null);

let alerts: Alert[] = [];
let numero: number = Number.parseInt(req.params.numero);
Expand All @@ -26,7 +25,7 @@ export class CandidatureController {
let alert = new Alert("danger", "La motivation doit faire plus de 20 caractères.");
alerts.push(alert);
} else {
let user: User = new User('[email protected]', 'Doe', 'John', '123456789', new Date(), true, 'password123', 'Candidat', 'En attente', null);
let user: User = req.user as User;
let candidature: Candidature = new Candidature(new Date(), user, offer, StatutCandidatureEnum.EN_ATTENTE, req.body.motivation);
await CandidatureRepository.create(candidature).then(async (candidature) => {
//upload file:
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/OfferController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@ export class OfferController {
csrfToken: req.session.csrfSecret
});
}

public static offre(req: express.Request, res: express.Response) {
let id: number = parseInt(req.params.numero);
OfferRepository.getById(id).then((offer: OffreDePoste) => {
return res.render("offre/offre", {
title: "Offre",
offer: offer,
userLogged: loggedInNoRedirection(req, res),
csrfToken: req.session.csrfSecret
});
}).catch((err) => {
console.log(err);
return res.redirect("/offre/liste");
})
}
}
2 changes: 1 addition & 1 deletion app/repository/OfferRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class OfferRepository {
let ficheDePoste;
let organisation;
for (let i = 0; i < result.length; i++) {
organisation = new Organisation(result[0].siren, result[0].nom, result[0].type, result[0].siege);
organisation = new Organisation(result[i].siren, result[i].nom, result[i].type, result[i].siege);
ficheDePoste = new FicheDePoste(result[i].fiche_numero, result[i].status, result[i].responsable, result[i].type_metier, result[i].lieu, result[i].teletravail, result[i].nb_heures, result[i].salaire, result[i].description, result[i].siren, organisation);
result[i] = new OffreDePoste(result[i].offre_numero, result[i].etat, result[i].date_validite, result[i].nb_piece, result[i].liste_piece, ficheDePoste);
}
Expand Down
8 changes: 0 additions & 8 deletions app/repository/UserRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class UserRepository {
if (err) {
return reject(err);
}
console.log(result);
let organisation = new Organisation(
result[0].siren,
result[0].organisation,
Expand All @@ -39,7 +38,6 @@ export class UserRepository {
undefined
);

console.log(user);
return resolve(user);
}
)
Expand All @@ -59,7 +57,6 @@ export class UserRepository {

let organisation;
let user;
console.log(result)
for (let i = 0; i < result.length; i++) {
organisation = new Organisation(
result[i].siren,
Expand All @@ -82,7 +79,6 @@ export class UserRepository {
);
result[i] = user;
}
console.log(result)

return resolve(result);
}
Expand Down Expand Up @@ -151,10 +147,8 @@ export class UserRepository {
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);
}
Expand All @@ -175,10 +169,8 @@ export class UserRepository {
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);
}
Expand Down
3 changes: 2 additions & 1 deletion app/routes/OfferRouter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import express from "express";
import {OfferController} from "../controllers/OfferController";
import {defaultRouter} from "./MainRouter";

const { passport, loggedIn, checkRole } = require("../passport/passportFunctions");

export const offerRouter = express.Router();
offerRouter.use(passport.initialize());
offerRouter.use(passport.session());
offerRouter.get("/creation", checkRole("Recruteur"), OfferController.creation);
offerRouter.post("/creation", checkRole("Recruteur"), OfferController.creation);
offerRouter.get("/:numero", OfferController.offre);
14 changes: 1 addition & 13 deletions app/views/admin/index.ejs
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Accueil</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
crossorigin="anonymous"></script>
</head>
<body>

<%- include('../partials/adminHeader.ejs') %>.

<div class="container col-xxl-8 px-4 py-5">
Expand Down Expand Up @@ -50,6 +37,7 @@
</h4>
<p><%= offer.ficheDePoste.description %></p>
<p>Organisation : <%= offer.ficheDePoste.organisation.nom %></p>
<a href="/offre/<%= offer.numero %>" class="btn btn-secondary">Voir l'offre</a>
</div>
<% }) %>
</div>
Expand Down
10 changes: 6 additions & 4 deletions app/views/admin/offres.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
<option value="<%= region %>"><%= region %></option>
<% }) %>
</select>
</div>
</div>
<div class="col-md-9">
<h4>Offres d'emploi</h4>
<% offers.forEach((offer) => {%>
<% offers.forEach((offer) => { %>
<div class="border-1 border p-2 my-2">
<h4 class=""><%= offer.ficheDePoste.typeMetier %> <span class="badge text-bg-secondary float-end">45000 €</span></h4>
<h4 class=""><%= offer.ficheDePoste.typeMetier %> <span
class="badge text-bg-secondary float-end"><%= offer.ficheDePoste.salaire %> €</span>
</h4>
<p><%= offer.ficheDePoste.description %></p>
<p>Organisation : <%= offer.ficheDePoste.siren %></p>
<p>Organisation : <%= offer.ficheDePoste.organisation.nom %></p>
<a href="/admin/offre/<%= offer.numero %>" class="btn btn-primary">Détail</a>
</div>
<% }) %>
Expand Down
13 changes: 0 additions & 13 deletions app/views/admin/utilisateurs.ejs
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Utilisateurs</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
crossorigin="anonymous"></script>
</head>
<body>

<%- include('../partials/adminHeader.ejs') %>.

<div class="container col-xxl-8 px-4 py-5">
Expand Down
2 changes: 1 addition & 1 deletion app/views/candidatures.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class="badge text-bg-secondary float-end"><%= candidature.offre.ficheDePoste.salaire %> €</span>
</h4>
<p><%= candidature.offre.ficheDePoste.description %></p>
<p>Organisation : Nom de l'<%= candidature.offre.ficheDePoste.siren %></p>
<p>Organisation : <%= candidature.offre.ficheDePoste.organisation.nom %></p>
<p>Status : <span class="badge text-bg-secondary"><%= candidature.statut %> €</span></p>
<a class="btn btn-primary"
href="/candidature/<%= candidature.candidat.email %>/<%= candidature.offre.numero %>">Voir la
Expand Down
6 changes: 2 additions & 4 deletions app/views/demandeRecruteur.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%- include('partials/header.ejs') %>.
<%- include('partials/header.ejs') %>

<div class="container border rounded-3 bg-light p-3">
<ul class="nav nav-tabs mb-3">
<li class="nav-item">
Expand Down Expand Up @@ -50,8 +51,6 @@
</div>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<script>
function showInputTab() {
$('a[href="#select-tab"]').removeClass('active');
Expand All @@ -67,4 +66,3 @@
$('#select-tab').addClass('active show');
}
</script>

13 changes: 0 additions & 13 deletions app/views/fiche/creation.ejs
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= title %></title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
crossorigin="anonymous"></script>
</head>
<body>

<%- include('../partials/recruteurHeader.ejs') %>

<div class="container col-xxl-8 px-4 py-5">
Expand Down
1 change: 1 addition & 0 deletions app/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<p><%= offer.ficheDePoste.description %></p>
<p>Organisation : <%= offer.ficheDePoste.organisation.nom %></p>
<a href="/canditature/<%= offer.numero %>" class="btn btn-primary">Postuler</a>
<a href="/offre/<%= offer.numero %>" class="btn btn-secondary">Voir l'offre</a>
</div>
<% }) %>
</div>
Expand Down
14 changes: 1 addition & 13 deletions app/views/offre/creation.ejs
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= title %></title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
crossorigin="anonymous"></script>
</head>
<body>

<%- include('../partials/recruteurHeader.ejs') %>
<%- include('../partials/recruteurHeader.ejs') %>

<div class="container col-xxl-8 px-4 py-5">
<div class="row">
Expand Down
Loading