diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss index 90dce17..5a0a5b5 100644 --- a/app/assets/stylesheets/application.bootstrap.scss +++ b/app/assets/stylesheets/application.bootstrap.scss @@ -13,6 +13,20 @@ $primary: #262626; @import 'search_location'; @import 'visas'; +.delete-button { + background: none; + color: inherit; + border: none; + padding: 0; + font: inherit; + cursor: pointer; + outline: inherit; + + i { + color: $danger; + } +} + .navbar-actions { display: flex; } diff --git a/app/assets/stylesheets/visas.scss b/app/assets/stylesheets/visas.scss index 7610a70..cfc782b 100644 --- a/app/assets/stylesheets/visas.scss +++ b/app/assets/stylesheets/visas.scss @@ -1,17 +1,3 @@ -.delete-button { - background: none; - color: inherit; - border: none; - padding: 0; - font: inherit; - cursor: pointer; - outline: inherit; - - i { - color: $danger; - } -} - .eligible-country-container { display: flex; } diff --git a/app/controllers/citizenships_controller.rb b/app/controllers/citizenships_controller.rb index 665842b..e51a296 100644 --- a/app/controllers/citizenships_controller.rb +++ b/app/controllers/citizenships_controller.rb @@ -36,7 +36,30 @@ def create end def destroy - raise NotImplementedError, "TODO" + @citizenship = Citizenship.find(params[:id]) + + authorize(@citizenship) + @citizenship.destroy! + + respond_to do |format| + format.turbo_stream do + render turbo_stream: turbo_stream.replace( + "profile-citizenship-section", + partial: "profiles/citizenships" + ) + end + end + end + + def cancel + respond_to do |format| + format.turbo_stream do + render turbo_stream: turbo_stream.replace( + "profile-citizenship-section", + partial: "profiles/citizenships" + ) + end + end end private diff --git a/app/policies/citizenship_policy.rb b/app/policies/citizenship_policy.rb index 89dbea8..8d8d2a5 100644 --- a/app/policies/citizenship_policy.rb +++ b/app/policies/citizenship_policy.rb @@ -2,4 +2,8 @@ class CitizenshipPolicy < ApplicationPolicy def create? record.user == user end + + def destroy? + create? + end end diff --git a/app/views/citizenships/_add_citizenship_form.html.erb b/app/views/citizenships/_add_citizenship_form.html.erb index e7a4f51..87a5c3b 100644 --- a/app/views/citizenships/_add_citizenship_form.html.erb +++ b/app/views/citizenships/_add_citizenship_form.html.erb @@ -3,15 +3,6 @@ data-controller="search-countries" data-search-countries-search-url-value=<%= citizenships_search_countries_path %> > -