Membership Fee 6 - UI Components & LiveViews closes #280 #304

Open
moritz wants to merge 65 commits from feature/280_membership_fee_ui into main
Showing only changes of commit 004bf67f54 - Show all commits

View file

@ -328,6 +328,34 @@ defmodule MvWeb.MembershipFeeTypeLive.Form do
assign(socket, form: to_form(form)) assign(socket, form: to_form(form))
end end
# Validates amount format and cleans invalid characters
defp validate_amount_format(params) do
case Map.get(params, "amount") do
nil -> params
"" -> params
amount_str when is_binary(amount_str) ->
# Check if it's a valid number format
case Decimal.parse(amount_str) do
{_decimal, ""} ->
# Valid decimal
params
{_decimal, _rest} ->
# Has trailing characters - invalid, but let Ash handle validation
params
:error ->
# Not a valid number - try to clean it up
# Remove non-numeric characters except decimal point
cleaned = String.replace(amount_str, ~r/[^\d.]/, "")
Map.put(params, "amount", cleaned)
end
_ ->
params
end
end
# Helper to extract existing form values to preserve them when only one field changes # Helper to extract existing form values to preserve them when only one field changes
defp get_existing_form_values(form) do defp get_existing_form_values(form) do
# Extract values directly from form fields to get current state # Extract values directly from form fields to get current state