Team membership management — the person ↔ team join.
Extracted from PhoenixKitStaff.Staff, which keeps thin delegators
(Staff.add_team_person/2, Staff.list_team_memberships/1, …) so the public
API is unchanged. Rosters exclude trashed people — the membership row
survives a trash, so restoring the person brings them back.
Summary
Functions
Adds a person to a team and broadcasts :team_person_added.
All memberships a given person belongs to, with team and department preloaded.
Memberships on a given team, preloaded with staff_person and user. Trashed people are excluded — the team roster shows the active members only (the membership row survives a trash, so restore brings them back).
People not already on this team (for the add-to-team picker).
Removes a team membership (by struct or by team/person uuids) and broadcasts :team_person_removed.
Functions
@spec add_team_person(UUIDv7.t() | String.t(), UUIDv7.t() | String.t()) :: {:ok, PhoenixKitStaff.Schemas.TeamMembership.t()} | {:error, Ecto.Changeset.t(PhoenixKitStaff.Schemas.TeamMembership.t())}
Adds a person to a team and broadcasts :team_person_added.
@spec list_memberships_for_person(UUIDv7.t() | String.t()) :: [ PhoenixKitStaff.Schemas.TeamMembership.t() ]
All memberships a given person belongs to, with team and department preloaded.
@spec list_team_memberships(UUIDv7.t() | String.t()) :: [ PhoenixKitStaff.Schemas.TeamMembership.t() ]
Memberships on a given team, preloaded with staff_person and user. Trashed people are excluded — the team roster shows the active members only (the membership row survives a trash, so restore brings them back).
@spec people_not_on_team(UUIDv7.t() | String.t()) :: [ PhoenixKitStaff.Schemas.Person.t() ]
People not already on this team (for the add-to-team picker).
@spec remove_team_person(PhoenixKitStaff.Schemas.TeamMembership.t()) :: {:ok, PhoenixKitStaff.Schemas.TeamMembership.t()} | {:error, Ecto.Changeset.t(PhoenixKitStaff.Schemas.TeamMembership.t())}
Removes a team membership (by struct or by team/person uuids) and broadcasts :team_person_removed.
@spec remove_team_person(UUIDv7.t() | String.t(), UUIDv7.t() | String.t()) :: {:ok, PhoenixKitStaff.Schemas.TeamMembership.t()} | {:error, Ecto.Changeset.t(PhoenixKitStaff.Schemas.TeamMembership.t())} | {:error, :not_found}