diff --git a/config/test.exs b/config/test.exs index c08f445..c5daa67 100644 --- a/config/test.exs +++ b/config/test.exs @@ -21,7 +21,7 @@ config :basket, BasketWeb.Endpoint, server: false # In test we don't send emails. -config :basket, Basket.Mailer, adapter: Swoosh.Adapters.Test +config :basket, Basket.Pow.Mailer, adapter: Swoosh.Adapters.Test # Disable swoosh api client as it is only required for production adapters. config :swoosh, :api_client, false diff --git a/lib/basket/club.ex b/lib/basket/club.ex index bf220fb..c2e2f0e 100644 --- a/lib/basket/club.ex +++ b/lib/basket/club.ex @@ -1,6 +1,8 @@ defmodule Basket.Club do @moduledoc false + import Ecto.Changeset + use Ecto.Schema @type t :: %__MODULE__{} @@ -11,4 +13,10 @@ defmodule Basket.Club do timestamps() end + + def changeset(club, attrs) do + club + |> cast(attrs, [:name]) + |> validate_required([:name]) + end end diff --git a/lib/basket/club_member.ex b/lib/basket/club_member.ex new file mode 100644 index 0000000..9991ba6 --- /dev/null +++ b/lib/basket/club_member.ex @@ -0,0 +1,22 @@ +defmodule Basket.ClubMember do + @moduledoc false + + use Ecto.Schema + import Ecto.Changeset + + alias Basket.{Club, User} + + schema "club_members" do + belongs_to :user, User + belongs_to :club, Club + end + + @doc false + def changeset(club_member, attrs) do + club_member + |> cast(attrs, [:user_id, :club_id]) + |> validate_required([:user_id, :club_id]) + |> foreign_key_constraint(:user_id) + |> foreign_key_constraint(:club_id) + end +end diff --git a/lib/basket/club_officer.ex b/lib/basket/club_officer.ex new file mode 100644 index 0000000..439172e --- /dev/null +++ b/lib/basket/club_officer.ex @@ -0,0 +1,22 @@ +defmodule Basket.ClubOfficer do + @moduledoc false + + use Ecto.Schema + import Ecto.Changeset + + alias Basket.{Club, User} + + schema "club_officers" do + belongs_to :user, User + belongs_to :club, Club + end + + @doc false + def changeset(club_member, attrs) do + club_member + |> cast(attrs, [:user_id, :club_id]) + |> validate_required([:user_id, :club_id]) + |> foreign_key_constraint(:user_id) + |> foreign_key_constraint(:club_id) + end +end diff --git a/lib/basket_web/components/core_components.ex b/lib/basket_web/components/core_components.ex index 05a5200..938d7a2 100644 --- a/lib/basket_web/components/core_components.ex +++ b/lib/basket_web/components/core_components.ex @@ -116,7 +116,7 @@ defmodule BasketWeb.CoreComponents do phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("#{@id}")} role="alert" class={[ - "fixed top-2 right-2 mr-2 w-80 sm:w-96 z-50 rounded-lg p-3 ring-1", + "fixed top-2 left-1/2 transform -translate-x-1/2 w-80 sm:w-96 z-50 rounded-lg p-3 ring-1", @kind == :info && "bg-emerald-50 text-emerald-800 ring-emerald-500 fill-cyan-900", @kind == :error && "bg-rose-50 text-rose-900 shadow-md ring-rose-500 fill-rose-900" ]} @@ -238,7 +238,7 @@ defmodule BasketWeb.CoreComponents do def simple_form(assigns) do ~H""" <.form :let={f} for={@for} as={@as} {@rest}> -