diff --git a/lib/who_need_help_web/live/request_live/show.ex b/lib/who_need_help_web/live/request_live/show.ex index 731dec0..3bd6a6f 100644 --- a/lib/who_need_help_web/live/request_live/show.ex +++ b/lib/who_need_help_web/live/request_live/show.ex @@ -20,6 +20,7 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do |> assign(:subscribed_assignment_id, nil) |> assign(:tracking_presence_key, nil) |> assign(:tracking_session_id, nil) + |> assign(:accept_confirmation_open?, false) |> assign(:native_client, native_client) |> assign( :e2e_runtime_node, @@ -142,12 +143,21 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do end @impl true + def handle_event("prepare-accept", _, socket) do + {:noreply, assign(socket, :accept_confirmation_open?, true)} + end + + def handle_event("cancel-accept", _, socket) do + {:noreply, assign(socket, :accept_confirmation_open?, false)} + end + def handle_event("accept", _, socket) do case Help.accept_request(socket.assigns.current_scope, socket.assigns.request.id) do {:ok, _} -> {:noreply, - put_action_flash( - socket, + socket + |> assign(:accept_confirmation_open?, false) + |> put_action_flash( :info, gettext("You accepted this request. Use private chat to coordinate safely.") )} @@ -1312,11 +1322,66 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do <%= cond do %> <% @request.status == :open && @request.requester_id != @current_scope.user.id -> %>
- {gettext("Accept only if you can complete this safely and for free.")} + {gettext( + "Accept only if you can help safely and voluntarily. Who Need Help does not process payments." + )}
- + <%= if @accept_confirmation_open? do %> +{gettext("Waiting for a nearby volunteer.")} diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 96cc31c..8498d8a 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -141,9 +141,49 @@ msgstr "" msgid "A signal requests human review; optional tracking absence is not proof of abuse." msgstr "" -#: lib/who_need_help_web/live/request_live/show.ex:1316 +#: lib/who_need_help_web/live/request_live/show.ex:1325 #, elixir-autogen, elixir-format -msgid "Accept only if you can complete this safely and for free." +msgid "Accept only if you can help safely and voluntarily. Who Need Help does not process payments." +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1337 +#, elixir-autogen, elixir-format +msgid "Before you accept" +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1343 +#, elixir-autogen, elixir-format +msgid "This request will be assigned to you and private chat will open." +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1349 +#, elixir-autogen, elixir-format +msgid "An exact location appears only if the requester chose to share it." +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1355 +#, elixir-autogen, elixir-format +msgid "If a purchase or reimbursement is involved, agree on it directly in chat before spending money." +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1361 +#, elixir-autogen, elixir-format +msgid "You can withdraw later, but please tell the requester as soon as possible." +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1372 +#, elixir-autogen, elixir-format +msgid "Accepting…" +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1374 +#, elixir-autogen, elixir-format +msgid "Confirm — I can help" +msgstr "" + +#: lib/who_need_help_web/live/request_live/show.ex:1382 +#, elixir-autogen, elixir-format +msgid "Not now" msgstr "" #: lib/who_need_help_web/live/request_live/show.ex:953 diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index d6ac092..8012ee1 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -141,10 +141,50 @@ msgstr "A link to confirm your email change has been sent to the new address." msgid "A signal requests human review; optional tracking absence is not proof of abuse." msgstr "A signal requests human review; optional tracking absence is not proof of abuse." -#: lib/who_need_help_web/live/request_live/show.ex:1316 +#: lib/who_need_help_web/live/request_live/show.ex:1325 #, elixir-autogen, elixir-format -msgid "Accept only if you can complete this safely and for free." -msgstr "Accept only if you can complete this safely and for free." +msgid "Accept only if you can help safely and voluntarily. Who Need Help does not process payments." +msgstr "Accept only if you can help safely and voluntarily. Who Need Help does not process payments." + +#: lib/who_need_help_web/live/request_live/show.ex:1337 +#, elixir-autogen, elixir-format +msgid "Before you accept" +msgstr "Before you accept" + +#: lib/who_need_help_web/live/request_live/show.ex:1343 +#, elixir-autogen, elixir-format +msgid "This request will be assigned to you and private chat will open." +msgstr "This request will be assigned to you and private chat will open." + +#: lib/who_need_help_web/live/request_live/show.ex:1349 +#, elixir-autogen, elixir-format +msgid "An exact location appears only if the requester chose to share it." +msgstr "An exact location appears only if the requester chose to share it." + +#: lib/who_need_help_web/live/request_live/show.ex:1355 +#, elixir-autogen, elixir-format +msgid "If a purchase or reimbursement is involved, agree on it directly in chat before spending money." +msgstr "If a purchase or reimbursement is involved, agree on it directly in chat before spending money." + +#: lib/who_need_help_web/live/request_live/show.ex:1361 +#, elixir-autogen, elixir-format +msgid "You can withdraw later, but please tell the requester as soon as possible." +msgstr "You can withdraw later, but please tell the requester as soon as possible." + +#: lib/who_need_help_web/live/request_live/show.ex:1372 +#, elixir-autogen, elixir-format +msgid "Accepting…" +msgstr "Accepting…" + +#: lib/who_need_help_web/live/request_live/show.ex:1374 +#, elixir-autogen, elixir-format +msgid "Confirm — I can help" +msgstr "Confirm — I can help" + +#: lib/who_need_help_web/live/request_live/show.ex:1382 +#, elixir-autogen, elixir-format +msgid "Not now" +msgstr "Not now" #: lib/who_need_help_web/live/request_live/show.ex:953 #, elixir-autogen, elixir-format diff --git a/priv/gettext/ru/LC_MESSAGES/default.po b/priv/gettext/ru/LC_MESSAGES/default.po index 2d6dd97..8fbebaf 100644 --- a/priv/gettext/ru/LC_MESSAGES/default.po +++ b/priv/gettext/ru/LC_MESSAGES/default.po @@ -145,11 +145,50 @@ msgstr "" "Сигнал требует проверки человеком; отсутствие необязательного отслеживания " "не является доказательством злоупотребления." -#: lib/who_need_help_web/live/request_live/show.ex:1316 +#: lib/who_need_help_web/live/request_live/show.ex:1325 #, elixir-autogen, elixir-format -msgid "Accept only if you can complete this safely and for free." -msgstr "" -"Принимайте заявку, только если можете безопасно и бесплатно её выполнить." +msgid "Accept only if you can help safely and voluntarily. Who Need Help does not process payments." +msgstr "Принимайте заявку, только если можете помочь безопасно и добровольно. Who Need Help не обрабатывает платежи." + +#: lib/who_need_help_web/live/request_live/show.ex:1337 +#, elixir-autogen, elixir-format +msgid "Before you accept" +msgstr "Перед принятием" + +#: lib/who_need_help_web/live/request_live/show.ex:1343 +#, elixir-autogen, elixir-format +msgid "This request will be assigned to you and private chat will open." +msgstr "Эта заявка будет закреплена за вами, и откроется приватный чат." + +#: lib/who_need_help_web/live/request_live/show.ex:1349 +#, elixir-autogen, elixir-format +msgid "An exact location appears only if the requester chose to share it." +msgstr "Точное местоположение появится, только если заявитель решил им поделиться." + +#: lib/who_need_help_web/live/request_live/show.ex:1355 +#, elixir-autogen, elixir-format +msgid "If a purchase or reimbursement is involved, agree on it directly in chat before spending money." +msgstr "Если потребуется покупка или возмещение расходов, договоритесь об этом напрямую в чате до того, как потратите деньги." + +#: lib/who_need_help_web/live/request_live/show.ex:1361 +#, elixir-autogen, elixir-format +msgid "You can withdraw later, but please tell the requester as soon as possible." +msgstr "Позже можно отказаться, но, пожалуйста, сообщите заявителю как можно скорее." + +#: lib/who_need_help_web/live/request_live/show.ex:1372 +#, elixir-autogen, elixir-format +msgid "Accepting…" +msgstr "Принимаем…" + +#: lib/who_need_help_web/live/request_live/show.ex:1374 +#, elixir-autogen, elixir-format +msgid "Confirm — I can help" +msgstr "Подтвердить — я помогу" + +#: lib/who_need_help_web/live/request_live/show.ex:1382 +#, elixir-autogen, elixir-format +msgid "Not now" +msgstr "Не сейчас" #: lib/who_need_help_web/live/request_live/show.ex:953 #, elixir-autogen, elixir-format diff --git a/priv/gettext/uk/LC_MESSAGES/default.po b/priv/gettext/uk/LC_MESSAGES/default.po index 0100343..6313842 100644 --- a/priv/gettext/uk/LC_MESSAGES/default.po +++ b/priv/gettext/uk/LC_MESSAGES/default.po @@ -145,11 +145,50 @@ msgstr "" "Сигнал потребує перевірки людиною; відсутність необов’язкового відстеження " "не є доказом зловживання." -#: lib/who_need_help_web/live/request_live/show.ex:1316 +#: lib/who_need_help_web/live/request_live/show.ex:1325 #, elixir-autogen, elixir-format -msgid "Accept only if you can complete this safely and for free." -msgstr "" -"Приймайте заявку, лише якщо можете безпечно й безкоштовно її виконати." +msgid "Accept only if you can help safely and voluntarily. Who Need Help does not process payments." +msgstr "Приймайте заявку, лише якщо можете допомогти безпечно й добровільно. Who Need Help не обробляє платежі." + +#: lib/who_need_help_web/live/request_live/show.ex:1337 +#, elixir-autogen, elixir-format +msgid "Before you accept" +msgstr "Перед прийняттям" + +#: lib/who_need_help_web/live/request_live/show.ex:1343 +#, elixir-autogen, elixir-format +msgid "This request will be assigned to you and private chat will open." +msgstr "Цю заявку буде закріплено за вами, і відкриється приватний чат." + +#: lib/who_need_help_web/live/request_live/show.ex:1349 +#, elixir-autogen, elixir-format +msgid "An exact location appears only if the requester chose to share it." +msgstr "Точне місцеперебування з’явиться, лише якщо заявник вирішив ним поділитися." + +#: lib/who_need_help_web/live/request_live/show.ex:1355 +#, elixir-autogen, elixir-format +msgid "If a purchase or reimbursement is involved, agree on it directly in chat before spending money." +msgstr "Якщо потрібна покупка або відшкодування витрат, домовтеся про це безпосередньо в чаті до того, як витрачати гроші." + +#: lib/who_need_help_web/live/request_live/show.ex:1361 +#, elixir-autogen, elixir-format +msgid "You can withdraw later, but please tell the requester as soon as possible." +msgstr "Пізніше можна відмовитися, але, будь ласка, повідомте заявника якомога швидше." + +#: lib/who_need_help_web/live/request_live/show.ex:1372 +#, elixir-autogen, elixir-format +msgid "Accepting…" +msgstr "Приймаємо…" + +#: lib/who_need_help_web/live/request_live/show.ex:1374 +#, elixir-autogen, elixir-format +msgid "Confirm — I can help" +msgstr "Підтвердити — я допоможу" + +#: lib/who_need_help_web/live/request_live/show.ex:1382 +#, elixir-autogen, elixir-format +msgid "Not now" +msgstr "Не зараз" #: lib/who_need_help_web/live/request_live/show.ex:953 #, elixir-autogen, elixir-format diff --git a/test/who_need_help_web/live/mutual_aid_live_test.exs b/test/who_need_help_web/live/mutual_aid_live_test.exs index ed0e4a4..7454a15 100644 --- a/test/who_need_help_web/live/mutual_aid_live_test.exs +++ b/test/who_need_help_web/live/mutual_aid_live_test.exs @@ -1194,7 +1194,28 @@ defmodule WhoNeedHelpWeb.MutualAidLiveTest do ) helper_view - |> element("button[phx-click='accept']") + |> element("#prepare-accept-request") + |> render_click() + + assert has_element?(helper_view, "#accept-request-confirmation") + assert has_element?(helper_view, "#confirm-accept-request") + assert has_element?(helper_view, "#cancel-accept-request") + assert is_nil(Repo.get_by(WhoNeedHelp.Help.Assignment, request_id: request.id)) + + helper_view + |> element("#cancel-accept-request") + |> render_click() + + refute has_element?(helper_view, "#accept-request-confirmation") + assert has_element?(helper_view, "#prepare-accept-request") + assert is_nil(Repo.get_by(WhoNeedHelp.Help.Assignment, request_id: request.id)) + + helper_view + |> element("#prepare-accept-request") + |> render_click() + + helper_view + |> element("#confirm-accept-request") |> render_click() assert render(helper_view) =~