refactor: DRY - use Mv.Constants.custom_field_prefix() instead of string literals
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Moritz 2025-12-03 18:47:27 +01:00
parent fabfe64468
commit cf6a108049
4 changed files with 28 additions and 8 deletions

View file

@ -37,7 +37,7 @@ defmodule MvWeb.MemberLive.Index do
alias MvWeb.MemberLive.Index.FieldVisibility
# Prefix used in sort field names for custom fields (e.g., "custom_field_<id>")
@custom_field_prefix "custom_field_"
@custom_field_prefix Mv.Constants.custom_field_prefix()
# Member fields that are loaded for the overview
# Uses constants from Mv.Constants to ensure consistency
@ -796,7 +796,7 @@ defmodule MvWeb.MemberLive.Index do
# Format: "custom_field_<id>" -> <id>
defp extract_custom_field_ids(visible_custom_fields) do
Enum.map(visible_custom_fields, fn field_string ->
case String.split(field_string, "custom_field_") do
case String.split(field_string, @custom_field_prefix) do
["", id] -> id
_ -> nil
end