feat(chat): add route to handle new room modal

Also, show/hide the modal using `live_action`.
This commit is contained in:
João Paulo Dubas 2025-02-03 23:37:11 +00:00
parent cf925bb87b
commit 2ca3e26a6e
Signed by: joao.dubas
SSH Key Fingerprint: SHA256:V1mixgOGRc/YMhGx/DNkOSmJxgA2vHNrDZEk3wt/kOA
2 changed files with 7 additions and 2 deletions

View File

@ -48,7 +48,7 @@ defmodule SlaxWeb.ChatRoomLive do
</.link>
<.link
class="block select-none cursor-pointer whitespace-nowrap text-gray-800 hover:text-white px-6 py-1 hover:bg-sky-600"
phx-click={show_modal("new-room-modal")}
navigate={~p"/rooms/#{@room}/new"}
>
Create a new room
</.link>
@ -209,7 +209,11 @@ defmodule SlaxWeb.ChatRoomLive do
</div>
</div>
</div>
<.modal id="new-room-modal">
<.modal
id="new-room-modal"
show={@live_action == :new}
on_cancel={JS.navigate(~p"/rooms/#{@room}")}
>
<.header>New chat room</.header>
<.simple_form
for={@new_room_form}

View File

@ -63,6 +63,7 @@ defmodule SlaxWeb.Router do
live "/", ChatRoomLive
live "/rooms", ChatRoomLive.Index
live "/rooms/:id", ChatRoomLive
live "/rooms/:id/new", ChatRoomLive, :new
live "/rooms/:id/edit", ChatRoomLive.Edit
live "/users/settings", UserSettingsLive, :edit
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email