Skip to content

Commit

Permalink
✨ apply feedback for post actions (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
karinevieira authored Mar 20, 2023
1 parent 057773c commit 1852869
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/components/application/flash_message_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def render?
def flash_message
type, message = flash.first

render(Feedback::BannerComponent.new(type: type)) { message }
render(Feedback::BannerComponent.new(type: type.to_sym)) { message }
end
end
end
8 changes: 4 additions & 4 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create

respond_to do |format|
if result.success?
format.html { redirect_to root_path }
format.html { redirect_to root_path, notice: t(".notice") }
else
format.html do
render Posts::NewPage.new(post: result.post), status: :unprocessable_entity
Expand All @@ -42,7 +42,7 @@ def update

respond_to do |format|
if result.success?
format.html { redirect_to root_path }
format.html { redirect_to root_path, notice: t(".notice") }
else
format.html do
render Posts::EditPage.new(post: result.post), status: :unprocessable_entity
Expand All @@ -56,9 +56,9 @@ def destroy

respond_to do |format|
if result.success?
format.html { redirect_to root_path }
format.html { redirect_to root_path, notice: t(".notice") }
else
format.html { redirect_to root_path, status: :unprocessable_entity }
format.html { redirect_to root_path, alert: t(".alert"), status: :unprocessable_entity }
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions config/locales/pt-BR/controllers/posts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pt-BR:
posts:
create:
notice: Publicação criada com sucesso
update:
notice: Publicação atualizada com sucesso
destroy:
notice: Publicação excluída com sucesso
alert: Houve um erro ao excluir publicação

0 comments on commit 1852869

Please sign in to comment.