defmodule TasksComponent do
use PlannerWeb, :live_component
alias Planner.Tasks
alias Planner.Tasks.Task
def update(%{:changeset => changeset, :id => _id}, socket) do
{:ok, assign(socket, :changeset, changeset)}
end
def update(assigns, socket) do
socket =
socket
|> assign(assigns)
|> assign(:changeset, Tasks.change_task(%Task{}))
{:ok, socket}
end
def render(assigns) do
~L"""
<%= f = form_for(@changeset, "#", [phx_submit: "new-task"]) %>
"""
end
end
defmodule TaskEditComponent do
use PlannerWeb, :live_component
alias Planner.Tasks
def update(%{:changeset => changeset, :id => _id}, socket) do
{:ok, assign(socket, :changeset, changeset)}
end
def update(assigns, socket) do
socket =
socket
|> assign(assigns)
|> assign(:changeset, Tasks.change_task(assigns.task))
{:ok, socket}
end
def render(assigns) do
~L"""