defmodule MvWeb.ContributionSettingsLive do @moduledoc """ Mock-up LiveView for Contribution Settings (Admin). This is a preview-only page that displays the planned UI for managing global contribution settings. It shows static mock data and is not functional. ## Planned Features (Future Implementation) - Set default contribution type for new members - Configure whether joining period is included in contributions - Explanatory text with examples ## Settings - `default_contribution_type_id` - UUID of the default contribution type - `include_joining_period` - Boolean whether to include joining period ## Note This page is intentionally non-functional and serves as a UI mockup for the upcoming Membership Contributions feature. """ use MvWeb, :live_view @impl true def mount(_params, _session, socket) do {:ok, socket |> assign(:page_title, gettext("Contribution Settings")) |> assign(:contribution_types, mock_contribution_types()) |> assign(:selected_type_id, "1") |> assign(:include_joining_period, true)} end @impl true def render(assigns) do ~H""" <.mockup_warning /> <.header> {gettext("Contribution Settings")} <:subtitle> {gettext("Configure global settings for membership contributions.")}
<%!-- Settings Form --%>

<.icon name="hero-cog-6-tooth" class="size-5" /> {gettext("Global Settings")}

<%!-- Default Contribution Type --%>

{gettext( "This contribution type is automatically assigned to all new members. Can be changed individually per member." )}

<%!-- Include Joining Period --%>

{gettext("When active: Members pay from the period of their joining.")}

{gettext("When inactive: Members pay from the next full period after joining.")}

<%!-- Examples Card --%>

<.icon name="hero-light-bulb" class="size-5" /> {gettext("Examples")}

<.example_section title={gettext("Yearly Interval - Joining Period Included")} joining_date="15.03.2023" include_joining={true} start_date="01.01.2023" periods={["2023", "2024", "2025"]} note={gettext("Member pays for the year they joined")} />
<.example_section title={gettext("Yearly Interval - Joining Period Excluded")} joining_date="15.03.2023" include_joining={false} start_date="01.01.2024" periods={["2024", "2025"]} note={gettext("Member pays from the next full year")} />
<.example_section title={gettext("Quarterly Interval - Joining Period Excluded")} joining_date="15.05.2024" include_joining={false} start_date="01.07.2024" periods={["Q3/2024", "Q4/2024", "Q1/2025"]} note={gettext("Member pays from the next full quarter")} />
<.example_section title={gettext("Monthly Interval - Joining Period Included")} joining_date="15.03.2024" include_joining={true} start_date="01.03.2024" periods={["03/2024", "04/2024", "05/2024", "..."]} note={gettext("Member pays from the joining month")} />
<.example_member_card />
""" end # Example member card with link to period view defp example_member_card(assigns) do ~H"""

<.icon name="hero-user" class="size-5" /> {gettext("Example: Member Contribution View")}

{gettext( "See how the contribution periods will be displayed for an individual member. This example shows Maria Weber with multiple contribution periods." )}

<.link navigate={~p"/contributions/member/example"} class="btn btn-primary btn-sm"> <.icon name="hero-eye" class="size-4" /> {gettext("View Example Member")}
""" end # Mock-up warning banner component - subtle orange style defp mockup_warning(assigns) do ~H"""
<.icon name="hero-exclamation-triangle" class="size-5 shrink-0" />
{gettext("Preview Mockup")} – {gettext("This page is not functional and only displays the planned features.")}
""" end # Example section component attr :title, :string, required: true attr :joining_date, :string, required: true attr :include_joining, :boolean, required: true attr :start_date, :string, required: true attr :periods, :list, required: true attr :note, :string, required: true defp example_section(assigns) do ~H"""

{@title}

{gettext("Joining date")}: {@joining_date}

{gettext("Contribution start")}: {@start_date}

{gettext("Generated periods")}: {Enum.join(@periods, ", ")}

→ {@note}

""" end # Mock data for demonstration defp mock_contribution_types do [ %{ id: "1", name: gettext("Regular"), amount: Decimal.new("60.00"), interval: :yearly }, %{ id: "2", name: gettext("Reduced"), amount: Decimal.new("30.00"), interval: :yearly }, %{ id: "3", name: gettext("Student"), amount: Decimal.new("5.00"), interval: :monthly }, %{ id: "4", name: gettext("Family"), amount: Decimal.new("25.00"), interval: :quarterly } ] end defp format_currency(%Decimal{} = amount) do "#{Decimal.to_string(amount)} €" end defp format_interval(:monthly), do: gettext("Monthly") defp format_interval(:quarterly), do: gettext("Quarterly") defp format_interval(:half_yearly), do: gettext("Half-yearly") defp format_interval(:yearly), do: gettext("Yearly") end