From 072d6594258c8894774db27330a4cdc88eb560a7 Mon Sep 17 00:00:00 2001 From: xfarrow Date: Mon, 18 Mar 2024 17:28:46 +0100 Subject: [PATCH] Update job_offer_model.js --- .../apis/nodejs/src/models/job_offer_model.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/apis/nodejs/src/models/job_offer_model.js b/backend/apis/nodejs/src/models/job_offer_model.js index aa1e3fd..e272e7d 100644 --- a/backend/apis/nodejs/src/models/job_offer_model.js +++ b/backend/apis/nodejs/src/models/job_offer_model.js @@ -47,21 +47,23 @@ async function insert(requester, organizationId, title, description, requirement async function remove(requester, jobOfferId) { const jobOffer = await findById(jobOfferId); - - if(!jobOffer){ + + if (!jobOffer) { return false; } const isAdmin = await OrganizationAdmin.isAdmin(requester, jobOffer.organization_id); - if (isAdmin) { - const deletedRows = await knex('JobOffer') - .where({ - id: jobOfferId - }).del(); - return deletedRows === 1; - } else { + + if (!isAdmin) { return false; } + + const deletedRows = await knex('JobOffer') + .where({ + id: jobOfferId + }) + .del(); + return deletedRows === 1; } async function findById(jobOfferId) {