mirror of
https://github.com/xfarrow/blink
synced 2025-02-16 08:00:35 +01:00
update
This commit is contained in:
parent
072d659425
commit
86bb9717d8
@ -54,13 +54,14 @@ app.use(rateLimit({
|
|||||||
===== BEGIN ROUTE HANDLING =====
|
===== BEGIN ROUTE HANDLING =====
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.use('/api', personRoutes.publicRoutes);
|
// app.use('/api', personRoutes.publicRoutes);
|
||||||
app.use('/api', organizationRoutes.publicRoutes);
|
// app.use('/api', personRoutes.protectedRoutes);
|
||||||
app.use('/api', personRoutes.protectedRoutes);
|
app.use('/api', jobOffersRoutes.publicRoutes);
|
||||||
app.use('/api', organizationRoutes.protectedRoutes);
|
|
||||||
app.use('/api', organizationAdminRoutes.protectedRoutes);
|
|
||||||
app.use('/api', organizationPostRoutes.protectedRoutes);
|
|
||||||
app.use('/api', jobOffersRoutes.protectedRoutes);
|
app.use('/api', jobOffersRoutes.protectedRoutes);
|
||||||
|
app.use('/api', organizationRoutes.publicRoutes);
|
||||||
|
app.use('/api', organizationRoutes.protectedRoutes);
|
||||||
|
// app.use('/api', organizationPostRoutes.protectedRoutes);
|
||||||
|
// app.use('/api', organizationAdminRoutes.protectedRoutes);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===== END ROUTE HANDLING =====
|
===== END ROUTE HANDLING =====
|
||||||
|
@ -72,6 +72,14 @@ async function findById(jobOfferId) {
|
|||||||
}).select().first();
|
}).select().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function findByOrganizationId(organizationId){
|
||||||
|
const result = await knex('JobOffer')
|
||||||
|
.where({organization_id: organizationId})
|
||||||
|
.select();
|
||||||
|
console.log(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// test
|
// test
|
||||||
async function filter(title, description, requirements, salary, salaryOperator, salaryFrequency, location, tags) {
|
async function filter(title, description, requirements, salary, salaryOperator, salaryFrequency, location, tags) {
|
||||||
let query = knex('JobOffer');
|
let query = knex('JobOffer');
|
||||||
@ -105,5 +113,6 @@ async function filter(title, description, requirements, salary, salaryOperator,
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
insert,
|
insert,
|
||||||
remove
|
remove,
|
||||||
|
findByOrganizationId
|
||||||
}
|
}
|
@ -80,11 +80,33 @@ async function remove(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET Request
|
||||||
|
* @param {*} req
|
||||||
|
* @param {*} res
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async function findByOrganizationId(req, res) {
|
||||||
|
try {
|
||||||
|
const result = await JobOffer.findByOrganizationId(req.params.id);
|
||||||
|
return res.status(200).send(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error in function ${insert.name}: ${error}`);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Internal server error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const publicRoutes = express.Router();
|
||||||
|
publicRoutes.get('/organizations/:id/joboffers', findByOrganizationId);
|
||||||
|
|
||||||
const protectedRoutes = express.Router();
|
const protectedRoutes = express.Router();
|
||||||
protectedRoutes.use(jwtUtils.verifyToken);
|
protectedRoutes.use(jwtUtils.verifyToken);
|
||||||
protectedRoutes.post('/organizations/:id/joboffers', insert);
|
protectedRoutes.post('/organizations/:id/joboffers', insert);
|
||||||
protectedRoutes.delete('/organizations/joboffers/:jobOfferId', remove);
|
protectedRoutes.delete('/organizations/joboffers/:jobOfferId', remove);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
publicRoutes,
|
||||||
protectedRoutes
|
protectedRoutes
|
||||||
}
|
}
|
@ -38,14 +38,14 @@
|
|||||||
alert("Invalid URL.");
|
alert("Invalid URL.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const response = await fetch(`${API_URL}/organization/${idToDisplay}`, {
|
const response = await fetch(`${API_URL}/organizations/${idToDisplay}`, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-type": "application/json; charset=UTF-8",
|
"Content-type": "application/json; charset=UTF-8",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
populateFields(data.name, data.location, data.description, data.is_hiring);
|
populateFields(data.name, data.location, data.description, isOrganizationHiring(idToDisplay));
|
||||||
document.body.style.display = "block"; // Show page
|
document.body.style.display = "block"; // Show page
|
||||||
} else {
|
} else {
|
||||||
alert(data.error);
|
alert(data.error);
|
||||||
@ -67,6 +67,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function isOrganizationHiring(organizationId) {
|
||||||
|
const response = await fetch(`${API_URL}/organizations/${organizationId}/joboffers`, {
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
return data.length > 0;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user