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 @@ <% }) %> - +

Offres d'emploi

- <% offers.forEach((offer) => {%> + <% offers.forEach((offer) => { %>
-

<%= offer.ficheDePoste.typeMetier %> 45000 €

+

<%= offer.ficheDePoste.typeMetier %> <%= offer.ficheDePoste.salaire %> € +

<%= offer.ficheDePoste.description %>

-

Organisation : <%= offer.ficheDePoste.siren %>

+

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

Détail
<% }) %> diff --git a/app/views/admin/utilisateurs.ejs b/app/views/admin/utilisateurs.ejs index cf60056..a760c34 100644 --- a/app/views/admin/utilisateurs.ejs +++ b/app/views/admin/utilisateurs.ejs @@ -1,16 +1,3 @@ - - - - - Utilisateurs - - - - - <%- include('../partials/adminHeader.ejs') %>.
diff --git a/app/views/candidatures.ejs b/app/views/candidatures.ejs index 3cdfdca..87bac5e 100644 --- a/app/views/candidatures.ejs +++ b/app/views/candidatures.ejs @@ -9,7 +9,7 @@ class="badge text-bg-secondary float-end"><%= candidature.offre.ficheDePoste.salaire %> €

<%= 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') %> +
- - - diff --git a/app/views/fiche/creation.ejs b/app/views/fiche/creation.ejs index fdad785..5a47e57 100644 --- a/app/views/fiche/creation.ejs +++ b/app/views/fiche/creation.ejs @@ -1,16 +1,3 @@ - - - - - <%= title %> - - - - - <%- include('../partials/recruteurHeader.ejs') %>
diff --git a/app/views/index.ejs b/app/views/index.ejs index a70d710..32b4911 100644 --- a/app/views/index.ejs +++ b/app/views/index.ejs @@ -44,6 +44,7 @@

<%= offer.ficheDePoste.description %>

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

Postuler + Voir l'offre
<% }) %>
diff --git a/app/views/offre/creation.ejs b/app/views/offre/creation.ejs index 1d5bdc6..d06b45b 100644 --- a/app/views/offre/creation.ejs +++ b/app/views/offre/creation.ejs @@ -1,17 +1,5 @@ - - - - - <%= title %> - - - - - <%- include('../partials/recruteurHeader.ejs') %> +<%- include('../partials/recruteurHeader.ejs') %>
diff --git a/app/views/offre/offre.ejs b/app/views/offre/offre.ejs new file mode 100644 index 0000000..86488df --- /dev/null +++ b/app/views/offre/offre.ejs @@ -0,0 +1,126 @@ +<% if (user) { %> + <% if (user.role === 'Recruteur') { %> + <%- include('../partials/recruteurheader.ejs') %> + <% } else { %> + <%- include('../partials/header.ejs') %> + <% } %> +<% } %> + +
+
+
+ + Image création d'entreprise + + + +
+

Offre : <%= offer.ficheDePoste.typeMetier %>

+
+
+
+

Description

+

<%= offer.ficheDePoste.description %>

+
+
+

Offre

+
+ + +
+
+ + +
+ +
+

Organisation

+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+

Pièces à déposer

+ + <% var list = offer.listePiece.split(',') %> + <% list.forEach((element) => { %> +

•<%= element %>

+ <% }) %> + +
+
+ +
+ +

Fiche de poste

+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+ + diff --git a/app/views/recruteur/offres.ejs b/app/views/recruteur/offres.ejs index 2d828c7..c3fb95e 100644 --- a/app/views/recruteur/offres.ejs +++ b/app/views/recruteur/offres.ejs @@ -6,10 +6,11 @@ <% offers.forEach((offer) => { %>

<%= offer.ficheDePoste.typeMetier %> 45000 € + class="badge text-bg-secondary float-end"><%= offer.ficheDePoste.salaire %> €

<%= offer.ficheDePoste.description %>

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

+ Voir l'offre
<% }) %>