berrypod/lib/berrypod_web/controllers/contact_controller.ex
jamey ca01f43d70
All checks were successful
deploy / deploy (push) Successful in 1m21s
add no-JS contact form and noscript banner
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>
2026-02-28 18:57:51 +00:00

28 lines
735 B
Elixir

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