# frozen_string_literal: true
module Admin
  class ProfileController < AdminController
    def view
    end

    def edit
      @user = current_admin
    end

    def update
      @user = current_admin

      if @user.update_attributes(user_params)
        redirect_to admin_profile_path,
                    flash: { success: "Sucessfully updated profile" }
      else
        flash[:error] = "Failed to update profile."
        render :edit
      end
    end

    private

      def user_params
        params.require(:user).permit(:name, :email, :password, :password_confirmation)
      end
  end
end
