Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
45d1ccf
created base. import cors, dotenv, postgres, seq. uppdated index
estherphang Feb 5, 2024
f755783
Create Sequelize Folders
estherphang Feb 5, 2024
ca12918
Merge pull request #1 from estney/base
estherphang Feb 5, 2024
aefc724
added primary tables models
estherphang Feb 6, 2024
c7bb591
created contollers and routers. Talent controller and router for gett…
estherphang Feb 6, 2024
dea347b
Merge pull request #2 from estney/primary_table
estherphang Feb 6, 2024
8b9e695
created controllers and routers for Benefit and Talent
estherphang Feb 7, 2024
9716e8f
completed benefit, employer, talent contoller and routers. corrected …
estherphang Feb 7, 2024
a31a303
to include employer controller
estherphang Feb 7, 2024
172c515
auth0 completed for adding new talent.
estherphang Feb 7, 2024
122ee97
edit comment
estherphang Feb 8, 2024
d86d8f3
Merge pull request #3 from estney/primary_table
estherphang Feb 8, 2024
3a91abf
sec and tert tables migration and seeders completed
estherphang Feb 12, 2024
fae196c
talent resume, education, skillset, work experience router and contro…
estherphang Feb 12, 2024
ad9a299
added routers and controllers for talent
estherphang Feb 12, 2024
3692bab
Merge pull request #4 from estney/secondary_table
estherphang Feb 12, 2024
8ff1616
create updateResume controller and router
estherphang Feb 13, 2024
74905b2
updated edit for skill, education and work experience
estherphang Feb 14, 2024
9920617
add benefits for talent works
estherphang Feb 14, 2024
c14dc81
save file
estherphang Feb 14, 2024
d12b178
added delete function for work exp, edu and skill
estherphang Feb 15, 2024
8a15009
Merge pull request #5 from estney/secondary_table
estherphang Feb 15, 2024
ed20274
a new router to show job listing to talents
estherphang Feb 15, 2024
376842d
added application works
estherphang Feb 15, 2024
a3b78fd
added checkJWT to edu routers
estherphang Feb 15, 2024
b5c44f7
added checkjwt to benefits
estherphang Feb 15, 2024
32ffed8
added jwt to skill
estherphang Feb 15, 2024
0120902
added jwt to work exp
estherphang Feb 15, 2024
b910352
created get function for talent's applied job
estherphang Feb 15, 2024
a43a0fe
created controller to only display jobs that are not applied
estherphang Feb 16, 2024
211ea40
added edit names function
estherphang Feb 16, 2024
ee29a84
Merge pull request #6 from estney/secondary_table
estherphang Feb 16, 2024
5e2f1c5
Update Employer Controller
Mystjerne Feb 16, 2024
92dbf2b
can now accept and deny applications via a put request in the Applica…
Mystjerne Feb 17, 2024
407f2cf
Merge pull request #7 from Mystjerne/EmployerCanAcceptandDenyApplicat…
Mystjerne Feb 17, 2024
508138c
add more employers data, job_listings data
Mystjerne Jul 8, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
node_modules
dist
.env
8 changes: 8 additions & 0 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require("path");

module.exports = {
config: path.resolve("config", "database.js"),
"models-path": path.resolve("db", "models"),
"seeders-path": path.resolve("db", "seeders"),
"migrations-path": path.resolve("db", "migrations"),
};
11 changes: 11 additions & 0 deletions config/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require("dotenv").config();

module.exports = {
development: {
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOST,
dialect: process.env.DB_DIALECT,
},
};
18 changes: 18 additions & 0 deletions controllers/BaseController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class BaseController {
constructor(model) {
this.model = model;
}

/* All controllers that extend this BASE controller will have access to the below function **/
async getAll(req, res) {
try {
console.log("hello world!");
const output = await this.model.findAll();
return res.json(output);
} catch (err) {
return res.status(400).json({ error: true, msg: err });
}
}
}

module.exports = BaseController;
12 changes: 12 additions & 0 deletions controllers/BenefitController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const BaseController = require("./BaseController");

class BenefitController extends BaseController {
constructor(model) {
super(model);
}
}

// allow users to read info, and select data only.
// user cannot add, edit or delete benefits.

module.exports = BenefitController;
204 changes: 204 additions & 0 deletions controllers/EmployerController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
const BaseController = require("./BaseController");

class EmployerController extends BaseController {
constructor(model, jobListingModel, benefitModel, applicationModel) {
super(model);
this.jobListingModel = jobListingModel;
this.benefitModel = benefitModel;
this.applicationModel = applicationModel;
}

// Create employer
async addEmployer(req, res) {
const {
firstName,
lastName,
companyName,
email,
photo,
description,
mission_statement,
headquarters,
phone,
} = req.body;
try {
// Create new employer
const newEmployer = await this.model.create({
firstName: firstName,
lastName: lastName,
companyName: companyName,
email: email,
photo: photo,
description: description,
mission_statement: mission_statement,
headquarters: headquarters,
phone: phone,
});
// Respond with new employer
return res.json(newEmployer);
} catch (err) {
return res.status(400).json({ error: true, msg: err });
}
}

// Edit and Update Employer
async updateEmployer(req, res) {
const {
firstName,
lastName,
companyName,
email,
photo,
description,
mission_statement,
headquarters,
phone,
} = req.body;
const { employerId } = req.params;
//if employerID /= in the list of employers, should throw error and not be able to update

try {
let employer_data = await this.model.findOne({
where: { id: employerId },
});
if (employer_data == null) {
throw new Error(
"Employer you are trying to edit does not exist in the database."
);
}
await this.model.update(
{
firstName: firstName,
lastName: lastName,
companyName: companyName,
email: email,
photo: photo,
description: description,
mission_statement: mission_statement,
headquarters: headquarters,
phone: phone,
},
{
where: {
id: employerId,
},
}
);
const output = await this.model.findAll();
return res.json(output);
} catch (err) {
return res.status(400).json({ error: true, msg: err.message });
}
}

// <------------------------ JOB LISTING ------------------------ >

async addJobListing(req, res) {
const { employerId } = req.params;
const {
jobTitle,
description,
jobResponsibility,
skillSet,
applicationStartDate,
applicationEndDate,
} = req.body;

console.log(req.body);
try {
//tag to employerID
const newJobListing = await this.jobListingModel.create({
jobTitle: jobTitle,
description: description,
jobResponsibility: jobResponsibility,
skillSet: skillSet,
applicationStartDate: applicationStartDate,
applicationEndDate: applicationEndDate,
employerId: employerId,
});
// Respond with the new work experience
{
const { employerId } = req.params;
const { benefit1, benefit2, benefit3 } = req.body;

try {
// Check if the talent exists
console.log("req.body", req.body);
const employer = await this.model.findByPk(employerId);
if (!employer) {
return res
.status(404)
.json({ error: true, msg: "Employer not found" });
}
// Create a new benefit and associate it with the talent
const addJobListingBenefit = await this.benefitModel.findAll({
where: {
id: [benefit1, benefit2, benefit3],
},
});
await newJobListing.setBenefits(addJobListingBenefit);
// Respond with the newly created benefit
return res.json(addJobListingBenefit);
} catch (err) {
return res.status(400).json({ error: true, msg: err });
}
}
} catch (err) {
return res.status(400).json({ error: true, msg: err });
}
}

async getJobListing(req, res) {
console.log("getJobListing is being called");
const { employerId } = req.params;
try {
//tag to talent ID
const jobListing = await this.jobListingModel.findAll({
where: {
employerId: employerId,
},
});
// Respond with the new work experience
return res.json(jobListing);
} catch (err) {
return res.status(400).json({ error: true, msg: err });
}
}

async getOneJobListingApps(req, res) {
console.log("req.params in getOneJobListing:", req.params);
const { employerId, jobListingId } = req.params;

try {
//tag to talent ID
const jobListing = await this.jobListingModel.findByPk(jobListingId);

const appsForJobListing = await jobListing.getApplications();
console.log("i am apps for job listing", appsForJobListing);

console.log("jobListing", jobListing);
console.log("applications for job listing", appsForJobListing);
const response = {
applications: appsForJobListing,
jobListing: jobListing,
};

return res.json(response);
} catch (err) {
console.log("err", err);
return res.status(400).json({ error: true, msg: err });
}
}
//return res.json(jobListing);
//get all applications relating to the job listing.
//-> get the id of all applications that have a specific job listing id
//use stuff from the documentation
}

//Employer Dashboard should get all job listings posted by the employer.
//Clicking on a job listing should bring the employer to a page where they can reject or accept applications associated with the job listing.

// get all user info under base controller
// delete is not required - user can't delete profile

module.exports = EmployerController;
Loading