feat: show room info on chat live view

This commit is contained in:
João Paulo Dubas 2024-10-09 00:12:59 +00:00
parent efd8914d74
commit 7d537c8148
Signed by: joao.dubas
SSH Key Fingerprint: SHA256:V1mixgOGRc/YMhGx/DNkOSmJxgA2vHNrDZEk3wt/kOA

View File

@ -2,9 +2,24 @@ defmodule SlaxWeb.ChatRoomLive do
@moduledoc false
use SlaxWeb, :live_view
alias Slax.Repo
alias Slax.Chat.Room
def render(assigns) do
~H"""
<div>Welcome to the chat!</div>
<div class="flex flex-col flex-grow shadow-lg">
<div class="flex justify-between items-center flex-shrink-0 h-16 bg-white border-b border-slate-300 px-4">
<div class="flex flex-col gap-1.5">
<h1 class="text-sm font-bold leading-none">#<%= @room.name %></h1>
<div class="text-xs leading-none h-3.5"><%= @room.topic %></div>
</div>
</div>
</div>
"""
end
def mount(_params, _session, socket) do
room = Room |> Repo.all() |> List.first()
{:ok, assign(socket, :room, room)}
end
end