add date range to range page
This commit is contained in:
@ -141,6 +141,20 @@ defmodule CanneryWeb.CoreComponents do
|
||||
"""
|
||||
def datetime(assigns)
|
||||
|
||||
attr :id, :string, required: true
|
||||
attr :name, :string, required: true
|
||||
|
||||
attr :start_date, :string,
|
||||
default: Date.utc_today() |> Date.shift(year: -1) |> Date.to_iso8601()
|
||||
|
||||
attr :end_date, :string, default: Date.utc_today() |> Date.to_iso8601()
|
||||
|
||||
@doc """
|
||||
Phoenix.Component for a <time> element that renders the naivedatetime in the
|
||||
user's local timezone
|
||||
"""
|
||||
def date_range(assigns)
|
||||
|
||||
@spec cast_datetime(NaiveDateTime.t() | nil) :: String.t()
|
||||
defp cast_datetime(%NaiveDateTime{} = datetime) do
|
||||
datetime |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601(:extended)
|
||||
|
@ -0,0 +1,12 @@
|
||||
<div
|
||||
class="flex items-center mx-4 my-2 space-x-1"
|
||||
data-end-date={@end_date}
|
||||
data-start-date={@start_date}
|
||||
id={@id}
|
||||
phx-hook="DateRange"
|
||||
phx-update="ignore"
|
||||
>
|
||||
<input class="text-center w-31 input input-primary" name={"#{@name}_start"} />
|
||||
<span>—</span>
|
||||
<input class="text-center w-31 input input-primary" name={"#{@name}_end"} />
|
||||
</div>
|
Reference in New Issue
Block a user