Skip to content

Commit 16c8e4e

Browse files
committed
feat(common): add users' name to settings invite users section
1 parent 4924e2b commit 16c8e4e

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

lib/media_server_web/components/user_invitation_component.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ defmodule MediaServerWeb.Components.UserInvitationComponent do
33

44
alias MediaServer.Accounts
55

6-
def handle_event("save", %{"email" => email}, socket) do
7-
create(socket, %{"user" => %{"email" => email, "password" => "#{ Enum.take_random(?a..?z, 12) }"}})
6+
def handle_event("save", %{"email" => email, "name" => name}, socket) do
7+
create(socket, %{"user" => %{"email" => email, "name" => name, "password" => "#{ Enum.take_random(?a..?z, 12) }"}})
88
end
99

1010
def create(socket, %{"user" => user_params}) do

lib/media_server_web/components/user_invitation_component.html.heex

+16-12
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@
1616
</p>
1717
</div>
1818

19-
<div class="space-y-1">
19+
<div>
20+
<label for="name" class="block text-sm font-medium text-gray-700">
21+
Name
22+
</label>
23+
<input type="text" name="name" id="name" class="mt-1 block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border-gray-300 rounded-md" placeholder="Name">
24+
</div>
25+
26+
<div>
2027
<label for="email" class="block text-sm font-medium text-gray-700">
2128
Email address
2229
</label>
23-
<div class="flex">
24-
<div class="flex-grow">
25-
<input type="text" name="email" id="email" class="block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border-gray-300 rounded-md" placeholder="Email address">
26-
</div>
27-
<span class="ml-3">
28-
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
29-
Invite
30-
</button>
31-
</span>
32-
</div>
30+
<input type="text" name="email" id="email" class="mt-1 block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border-gray-300 rounded-md" placeholder="Email address">
31+
</div>
32+
33+
<div class="flex justify-end">
34+
<button type="submit" class="ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
35+
Invite
36+
</button>
3337
</div>
3438

3539
<div>
@@ -43,7 +47,7 @@
4347
</svg>
4448
</span>
4549
<div class="ml-3 flex flex-col">
46-
<span class="text-sm font-medium text-gray-900">Calvin Hawkins</span>
50+
<span class="text-sm font-medium text-gray-900"><%= item.name %></span>
4751
<span class="text-sm text-gray-500"><%= item.email %></span>
4852
</div>
4953
</li>

test/media_server_web/components/user_invitation_component_test.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ defmodule MediaServerWeb.UserInvitationComponentTest do
2222

2323
{:ok, _, html} =
2424
index_live
25-
|> form("#user-invite-form", email: "[email protected]")
25+
|> form("#user-invite-form", email: "[email protected]", name: "Some Name")
2626
|> render_submit()
2727
|> follow_redirect(conn, Routes.settings_index_path(conn, :index))
2828

29+
assert html =~ "Some Name"
2930
assert html =~ "[email protected]"
3031
end
3132
end

0 commit comments

Comments
 (0)