refactor(member-live): modularize the overview and drop the superseded in-memory paths
Extract the cookie parser, export-payload builder and fee-status helper into their own modules and remove the filter/sort/load helpers the database pushdown made dead, so the overview LiveView stays a thin coordinator over focused units.
This commit is contained in:
parent
c2cb3edab8
commit
77fc11a0b0
17 changed files with 375 additions and 875 deletions
|
|
@ -29,6 +29,8 @@ defmodule MvWeb.MemberLive.Index.FieldSelection do
|
|||
Comma-separated list: `?fields=first_name,email,custom_field_abc-123`
|
||||
"""
|
||||
|
||||
alias MvWeb.MemberLive.Index.Cookie
|
||||
|
||||
@cookie_name "member_field_selection"
|
||||
@cookie_max_age 365 * 24 * 60 * 60
|
||||
@session_key "member_field_selection"
|
||||
|
|
@ -80,7 +82,7 @@ defmodule MvWeb.MemberLive.Index.FieldSelection do
|
|||
%{}
|
||||
|
||||
[cookie_header | _rest] ->
|
||||
cookies = parse_cookie_header(cookie_header)
|
||||
cookies = Cookie.parse_header(cookie_header)
|
||||
|
||||
case Map.get(cookies, @cookie_name) do
|
||||
nil -> %{}
|
||||
|
|
@ -90,19 +92,6 @@ defmodule MvWeb.MemberLive.Index.FieldSelection do
|
|||
end
|
||||
end
|
||||
|
||||
# Parses cookie header string into a map
|
||||
defp parse_cookie_header(cookie_header) when is_binary(cookie_header) do
|
||||
cookie_header
|
||||
|> String.split(";")
|
||||
|> Enum.map(&String.trim/1)
|
||||
|> Enum.map(&String.split(&1, "=", parts: 2))
|
||||
|> Enum.reduce(%{}, fn
|
||||
[key, value], acc -> Map.put(acc, key, URI.decode(value))
|
||||
[key], acc -> Map.put(acc, key, "")
|
||||
_, acc -> acc
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Saves field selection to cookie.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue