feat(chat): add route to handle new room modal
Also, show/hide the modal using `live_action`.
This commit is contained in:
parent
cf925bb87b
commit
2ca3e26a6e
@ -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}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user