Skip to content

Commit

Permalink
move profile controller
Browse files Browse the repository at this point in the history
  • Loading branch information
fermion committed Oct 15, 2024
1 parent b420a45 commit 0a2a285
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Users::ProfileController < ApplicationController
class Settings::ProfileController < ApplicationController
before_action :require_user!
def show
end
Expand All @@ -14,7 +14,7 @@ def update

if current_user.save
flash[:success] = 'Your profile was updated successfully'
redirect_to users_profile_path
redirect_to settings_profile_path
else
flash.now[:error] = 'There was a problem updating your profile'

Expand Down
5 changes: 1 addition & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
<div class="hidden md:block">
<div class="ml-4 flex items-center md:ml-6">
<%= header_link_to "Open Source", "https://github.com/goinvo/staffplan-next-app" %>
<%= link_to "Profile", users_profile_path, class: "px-6 relative rounded-full bg-gray-800 p-1 text-white hover:text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800", role: "menuitem" %>
<% if current_user.owner?(company: current_company) || current_user.admin?(company: current_company) %>
<%= header_link_to "Settings", settings_path %>
<% end %>
<%= header_link_to "Settings", settings_profile_path %>
<%= button_to("Sign out", auth_sign_out_url, method: :delete, class: "px-6 relative rounded-full bg-gray-800 p-1 text-white hover:text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800") %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for current_user, url: users_profile_path do |f| %>
<%= form_for current_user, url: settings_profile_path do |f| %>
<div class="space-y-12">
<div class="border-b border-gray-900/10 pb-12">
<h2 class="text-base font-semibold leading-7 text-gray-900">Your Profile</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="bg-white p-4 mt-4">
<%= turbo_frame_tag "users-profile-show", target: "_top" do %>
<%= render partial: "users/profile/form" %>
<%= render partial: "form" %>
<% end %>
</div>
2 changes: 2 additions & 0 deletions app/views/settings/profile/update.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= turbo_stream.update "users-profile-show", partial: "form" %>
<%= turbo_stream.replace "flash", partial: "shared/flash" %>
2 changes: 0 additions & 2 deletions app/views/users/profile/update.turbo_stream.erb

This file was deleted.

5 changes: 1 addition & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
end
end

namespace :users do
resource :profile, only: [:show, :update], controller: "profile"
end

resource :avatars, only: [:destroy]

resource :settings, only: [:show, :update], controller: "settings" do
Expand All @@ -51,6 +47,7 @@
post :toggle_status
end
end
resource :profile, only: [:show, :update], controller: "settings/profile"
end

namespace :webhooks do
Expand Down

0 comments on commit 0a2a285

Please sign in to comment.