Enable/disable affiliate sales data

This commit is contained in:
David Cook
2024-07-16 15:51:46 +10:00
parent 1742d2807f
commit da7bbcf82f
5 changed files with 61 additions and 15 deletions

View File

@@ -5,8 +5,12 @@ module Admin
def create
authorize! :admin, enterprise
app = ConnectedApp.create!(enterprise_id: enterprise.id)
app.connect(api_key: spree_current_user.spree_api_key, channel: SessionChannel.for_request(request))
attributes = {}
attributes[:type] = connected_app_params[:type] if connected_app_params[:type]
app = ConnectedApp.create!(enterprise_id: enterprise.id, **attributes)
app.connect(api_key: spree_current_user.spree_api_key,
channel: SessionChannel.for_request(request))
render_panel
end
@@ -14,7 +18,7 @@ module Admin
def destroy
authorize! :admin, enterprise
app = enterprise.connected_apps.first
app = enterprise.connected_apps.find(params.require(:id))
app.destroy
render_panel
@@ -29,5 +33,9 @@ module Admin
def render_panel
redirect_to "#{edit_admin_enterprise_path(enterprise)}#/connected_apps_panel"
end
def connected_app_params
params.permit(:type)
end
end
end