add no-JS contact form and noscript banner
All checks were successful
deploy / deploy (push) Successful in 1m21s
All checks were successful
deploy / deploy (push) Successful in 1m21s
Wire up the contact form with action/method/name attrs so it works without JavaScript. Add ContactNotifier, ContactController, and a noscript info banner in the shop root layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
27
lib/berrypod_web/controllers/contact_controller.ex
Normal file
27
lib/berrypod_web/controllers/contact_controller.ex
Normal file
@@ -0,0 +1,27 @@
|
||||
defmodule BerrypodWeb.ContactController do
|
||||
use BerrypodWeb, :controller
|
||||
|
||||
alias Berrypod.ContactNotifier
|
||||
|
||||
@doc """
|
||||
Handles contact form submission (no-JS fallback).
|
||||
"""
|
||||
def create(conn, params) do
|
||||
case ContactNotifier.deliver_contact_message(params) do
|
||||
{:ok, _} ->
|
||||
conn
|
||||
|> put_flash(:info, "Message sent! We'll get back to you soon.")
|
||||
|> redirect(to: ~p"/contact")
|
||||
|
||||
{:error, :invalid_params} ->
|
||||
conn
|
||||
|> put_flash(:error, "Please fill in all required fields.")
|
||||
|> redirect(to: ~p"/contact")
|
||||
|
||||
{:error, _} ->
|
||||
conn
|
||||
|> put_flash(:error, "Sorry, something went wrong. Please try again.")
|
||||
|> redirect(to: ~p"/contact")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user