diff --git a/app/controllers/AdminController.ts b/app/controllers/AdminController.ts index 715e1ce..7a8f86f 100644 --- a/app/controllers/AdminController.ts +++ b/app/controllers/AdminController.ts @@ -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)}); }); }); @@ -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)}); }) } @@ -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, @@ -111,7 +107,6 @@ 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)}); }) } @@ -119,7 +114,6 @@ export class AdminController { 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"); } @@ -127,7 +121,6 @@ export class AdminController { 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"); } @@ -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)}); }) } @@ -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{ @@ -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) => { @@ -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)}); }); } diff --git a/app/controllers/CandidatureController.ts b/app/controllers/CandidatureController.ts index ef62253..b44399b 100644 --- a/app/controllers/CandidatureController.ts +++ b/app/controllers/CandidatureController.ts @@ -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('tsoudar21@gmail.com', 'Tillai', 'Soudarsane', '0652645299', new Date('2020-10-10'), false, 'mdp', 'Candidat', "", null); let alerts: Alert[] = []; let numero: number = Number.parseInt(req.params.numero); @@ -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('candidat1@example.com', '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: diff --git a/app/controllers/OfferController.ts b/app/controllers/OfferController.ts index 53d4612..f0a235f 100644 --- a/app/controllers/OfferController.ts +++ b/app/controllers/OfferController.ts @@ -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"); + }) + } } diff --git a/app/repository/OfferRepository.ts b/app/repository/OfferRepository.ts index 387c40f..9416da3 100644 --- a/app/repository/OfferRepository.ts +++ b/app/repository/OfferRepository.ts @@ -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); } diff --git a/app/repository/UserRepository.ts b/app/repository/UserRepository.ts index 1cd1629..faef7f4 100644 --- a/app/repository/UserRepository.ts +++ b/app/repository/UserRepository.ts @@ -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, @@ -39,7 +38,6 @@ export class UserRepository { undefined ); - console.log(user); return resolve(user); } ) @@ -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, @@ -82,7 +79,6 @@ export class UserRepository { ); result[i] = user; } - console.log(result) return resolve(result); } @@ -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); } @@ -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); } diff --git a/app/routes/OfferRouter.ts b/app/routes/OfferRouter.ts index 1fe99e0..13b339e 100644 --- a/app/routes/OfferRouter.ts +++ b/app/routes/OfferRouter.ts @@ -1,6 +1,6 @@ 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(); @@ -8,3 +8,4 @@ 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); diff --git a/app/views/admin/offres.ejs b/app/views/admin/offres.ejs index 7d0fbd2..d2bbd5f 100644 --- a/app/views/admin/offres.ejs +++ b/app/views/admin/offres.ejs @@ -18,14 +18,16 @@ <% }) %> - +
<%= offer.ficheDePoste.description %>
-Organisation : <%= offer.ficheDePoste.siren %>
+Organisation : <%= offer.ficheDePoste.organisation.nom %>
Détail<%= candidature.offre.ficheDePoste.description %>
-Organisation : Nom de l'<%= candidature.offre.ficheDePoste.siren %>
+Organisation : <%= candidature.offre.ficheDePoste.organisation.nom %>
Status : <%= candidature.statut %> €
Voir la diff --git a/app/views/demandeRecruteur.ejs b/app/views/demandeRecruteur.ejs index f2889e8..2a2e66c 100644 --- a/app/views/demandeRecruteur.ejs +++ b/app/views/demandeRecruteur.ejs @@ -1,4 +1,5 @@ -<%- include('partials/header.ejs') %>. +<%- include('partials/header.ejs') %> +<%= offer.ficheDePoste.description %>
Organisation : <%= offer.ficheDePoste.organisation.nom %>
Postuler + Voir l'offre<%= offer.ficheDePoste.description %>
Organisation : <%= offer.ficheDePoste.organisation.nom %>
+ Voir l'offre