diff --git a/lib/chore_tracker/chores.ex b/lib/chore_tracker/chores.ex index f71dcd5..56bcfab 100644 --- a/lib/chore_tracker/chores.ex +++ b/lib/chore_tracker/chores.ex @@ -5,8 +5,8 @@ defmodule ChoreTracker.Chores do import Ecto.Query, warn: false alias ChoreTracker.Repo - alias ChoreTracker.Chores.Chore + alias ChoreTracker.Accounts.User @doc """ Returns the list of chores. @@ -145,9 +145,10 @@ defmodule ChoreTracker.Chores do {:error, %Ecto.Changeset{}} """ - def create_chore_log(attrs \\ %{}) do + + def log_chore_execution(%User{} = user, %Chore{} = chore) do %ChoreLog{} - |> ChoreLog.changeset(attrs) + |> ChoreLog.changeset(%{user_id: user.id, chore_id: chore.id}) |> Repo.insert() end diff --git a/lib/chore_tracker/chores/chore.ex b/lib/chore_tracker/chores/chore.ex index 87758dd..e8eae1f 100644 --- a/lib/chore_tracker/chores/chore.ex +++ b/lib/chore_tracker/chores/chore.ex @@ -17,6 +17,6 @@ defmodule ChoreTracker.Chores.Chore do def changeset(chore, attrs) do chore |> cast(attrs, [:name, :description, :emoji, :period, :period_unit, :starts_at]) - |> validate_required([:name, :description, :emoji, :period, :period_unit, :starts_at]) + |> validate_required([:name, :emoji, :period, :period_unit, :starts_at]) end end diff --git a/lib/chore_tracker_web/live/chore_live/index.html.heex b/lib/chore_tracker_web/live/chore_live/index.html.heex index e5870b2..26e44a5 100644 --- a/lib/chore_tracker_web/live/chore_live/index.html.heex +++ b/lib/chore_tracker_web/live/chore_live/index.html.heex @@ -12,10 +12,9 @@ rows={@streams.chores} row_click={fn {_id, chore} -> JS.navigate(~p"/manage/chores/#{chore}") end} > - <:col :let={{_id, chore}}><%= chore.emoji %> - <:col :let={{_id, chore}} label="Chore"><%= chore.name %> - <:col :let={{_id, chore}} label="Period"><%= chore.period %> - <:col :let={{_id, chore}} label="Period unit"><%= chore.period_unit %> + <:col :let={{_id, chore}}><%= chore.emoji %> + <:col :let={{_id, chore}} label="Chore"><%= chore.name %> + <:col :let={{_id, chore}} label="Every"><%= chore.period %> <%= chore.period_unit %> <:col :let={{_id, chore}} label="Starts at"><%= chore.starts_at %> <:action :let={{_id, chore}}>