From a3be22ec48e65708c05b69c5d41e5e1378c31a22 Mon Sep 17 00:00:00 2001 From: Rafael Mori <103967050+Rafael-Mori-2022@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:02:32 -0300 Subject: [PATCH] Feat/contact responses (#215) * extract common tasks aliases * feat: contact response pages * Update config.exs --------- Co-authored-by: Zoey de Souza Pessanha --- assets/css/contact.scss | 49 ++++ .../controllers/contact_controller.ex | 16 +- lib/pescarte_web/router.ex | 2 + .../templates/contact_html/failed.html.heex | 24 ++ .../templates/contact_html/success.html.heex | 24 ++ priv/static/images/contato/fish.png | Bin 0 -> 527 bytes priv/static/images/contato/fishing2.svg | 274 ++++++++++++++++++ 7 files changed, 386 insertions(+), 3 deletions(-) create mode 100644 lib/pescarte_web/templates/contact_html/failed.html.heex create mode 100644 lib/pescarte_web/templates/contact_html/success.html.heex create mode 100644 priv/static/images/contato/fish.png create mode 100644 priv/static/images/contato/fishing2.svg diff --git a/assets/css/contact.scss b/assets/css/contact.scss index afc46403..8c0495df 100644 --- a/assets/css/contact.scss +++ b/assets/css/contact.scss @@ -2,9 +2,38 @@ display: flex; align-items: center; justify-content: center; + max-width: 100vw; margin-bottom: 40px; padding: 80px 120px; + .contact-message { + display: flex; + flex-direction: column; + justify-content: center; + width: 50%; + + h2 { + margin-bottom: 20px; + } + + .text-black-80 { + margin-bottom: 20px; + } + + .return-button { + display: flex; + align-items: center; + justify-content: center; + background: #0064C8; + border-radius: 4px; + gap: 8px; + padding: 16px 24px; + width: 267px; + cursor: pointer; + } + + } + .contact-form { width: 50%; .form-inputs { @@ -51,4 +80,24 @@ } } } +} + +@media (min-width: 769px) and (max-width: 1024px) { + .contact-area { + margin: 20px 40px; + } +} + +@media (min-width: 360px) and (max-width: 768px) { + .contact-area { + display: flex; + padding: 10px 5px; + flex-direction: column; + text-align: center; + gap: 40px; + + .contact-message { + align-items: center; + } + } } \ No newline at end of file diff --git a/lib/pescarte_web/controllers/contact_controller.ex b/lib/pescarte_web/controllers/contact_controller.ex index 7c5697eb..91e49159 100644 --- a/lib/pescarte_web/controllers/contact_controller.ex +++ b/lib/pescarte_web/controllers/contact_controller.ex @@ -6,6 +6,16 @@ defmodule PescarteWeb.ContactController do @sender_email Application.compile_env!(:pescarte, [PescarteWeb, :sender_email]) @receiver_email Application.compile_env!(:pescarte, [PescarteWeb, :receiver_email]) + def success(conn, _params) do + current_path = conn.request_path + render(conn, :success, current_path: current_path, error_message: nil) + end + + def failed(conn, _params) do + current_path = conn.request_path + render(conn, :failed, current_path: current_path, error_message: nil) + end + def show(conn, _params) do changeset = ContactForm.changeset(%{}) current_path = conn.request_path @@ -21,7 +31,7 @@ defmodule PescarteWeb.ContactController do {:ok, _} <- send_confirmation_email(client, contact_form) do conn |> put_flash(:info, "Email enviado com sucesso!") - |> redirect(to: ~p"/") + |> redirect(to: ~p"/contato/success") else {:error, reason} -> Logger.error(""" @@ -32,13 +42,13 @@ defmodule PescarteWeb.ContactController do conn |> put_flash(:error, "Erro ao enviar email.") - |> redirect(to: ~p"/") + |> redirect(to: ~p"/contato/failed") end {:error, _changeset} -> conn |> put_flash(:error, "Erro na validação do formulário.") - |> redirect(to: ~p"/") + |> redirect(to: ~p"/contato/failed") end end diff --git a/lib/pescarte_web/router.ex b/lib/pescarte_web/router.ex index 1cefe2b2..68dfb3ec 100644 --- a/lib/pescarte_web/router.ex +++ b/lib/pescarte_web/router.ex @@ -64,6 +64,8 @@ defmodule PescarteWeb.Router do scope "/contato" do get "/", ContactController, :show + get "/success", ContactController, :success + get "/failed", ContactController, :failed post "/", ContactController, :send_email end end diff --git a/lib/pescarte_web/templates/contact_html/failed.html.heex b/lib/pescarte_web/templates/contact_html/failed.html.heex new file mode 100644 index 00000000..5d84f426 --- /dev/null +++ b/lib/pescarte_web/templates/contact_html/failed.html.heex @@ -0,0 +1,24 @@ +
+
+
+ <.text size="h2" color="text-blue-100"> + Ops! Algo deu errado... + + <.text size="lg" color="text-black-80"> + Não pudemos receber sua mensagem por conta de um erro. Mas não se preocupe, você pode tentar novamente mais tarde! + + + +
+ + <.text size="base" color="text-white-100"> + Voltar para a homepage + +
+
+
+ +
+ + +
diff --git a/lib/pescarte_web/templates/contact_html/success.html.heex b/lib/pescarte_web/templates/contact_html/success.html.heex new file mode 100644 index 00000000..3282c73d --- /dev/null +++ b/lib/pescarte_web/templates/contact_html/success.html.heex @@ -0,0 +1,24 @@ +
+
+
+ <.text size="h2" color="text-blue-100"> + Recebemos sua mensagem! + + <.text size="lg" color="text-black-80"> + Agradecemos seu contato. Em breve, um membro da nossa equipe irá lhe retornar. Enquanto isso, fique à vontade para conferir mais conteúdos no nosso site. + + + +
+ + <.text size="base" color="text-white-100"> + Voltar para a homepage + +
+
+
+ +
+ + +
diff --git a/priv/static/images/contato/fish.png b/priv/static/images/contato/fish.png new file mode 100644 index 0000000000000000000000000000000000000000..8dea61ea29bc8f1a8ecd4280a21f43f739df8252 GIT binary patch literal 527 zcmV+q0`UEbP)P000>X1^@s6#OZ}&00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yP4y_cc7#KN^m-`J8(L{9XK73Q~<6Zqyn4@l+$>LmmBez;V-_K9oZ*o zcke*LnEw*1sRhotRE8+HdA0g9OG5F*dbR!pat?F zkqiVI5^bq{Eyy>tC+AkdT!oyS6hUrBt*E`Q+T#h!Ku0Q=inK`5wTp6=+7kuHdg}vR z`%pD4JJao$QF%(g3$EsY_8tWrTKp`i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +