defmodule LiveBeatsWeb.HomeLive do
use LiveBeatsWeb, :live_view
alias LiveBeats.MediaLibrary
def render(assigns) do
~H"""
<.title_bar>
LiveBeats - Chill
<:actions>
<.button>Share
<.button primary phx-click={show_modal("add-songs")}>Add Songs
<.modal id="add-songs">
<:title>Add Songs
a modal
<:cancel>Close
<:confirm>Add
<.table rows={@songs}>
<:col let={song} label="Song">
<%= song.title %>
<:col let={song} label="Artist">
<%= song.artist %>
<:col let={song} label="Time">
<%= song.duration %>
<:col label="">
"""
end
def mount(_parmas, _session, socket) do
{:ok, assign(socket, :songs, fetch_songs(socket))}
end
defp fetch_songs(_socket) do
MediaLibrary.list_songs()
end
end