Implement removing job skills

This lets users remove job skills, for if they accidentally set them.
This commit is contained in:
Justin Edmund 2023-06-19 02:17:30 -07:00
parent 34feab4a2e
commit 94c8f7f040
2 changed files with 11 additions and 3 deletions

View file

@ -3,8 +3,8 @@
module Api
module V1
class JobsController < Api::V1::ApiController
before_action :set, only: %w[update_job update_job_skills]
before_action :authorize, only: %w[update_job update_job_skills]
before_action :set, only: %w[update_job update_job_skills destroy_job_skill]
before_action :authorize, only: %w[update_job update_job_skills destroy_job_skill]
def all
render json: JobBlueprint.render(Job.all)
@ -80,6 +80,12 @@ module Api
render json: PartyBlueprint.render(@party, view: :jobs) if @party.save!
end
def destroy_job_skill
position = job_params[:skill_position].to_i
@party["skill#{position}_id"] = nil
render json: PartyBlueprint.render(@party, view: :jobs) if @party.save
end
private
def merge_skills_with_existing_skills(
@ -180,7 +186,8 @@ module Api
:skill0_id,
:skill1_id,
:skill2_id,
:skill3_id
:skill3_id,
:skill_position
)
end
end

View file

@ -26,6 +26,7 @@ Rails.application.routes.draw do
put 'parties/:id/jobs', to: 'jobs#update_job'
put 'parties/:id/job_skills', to: 'jobs#update_job_skills'
delete 'parties/:id/job_skills', to: 'jobs#destroy_job_skill'
post 'check/email', to: 'users#check_email'
post 'check/username', to: 'users#check_username'