defmodule MicrowavepropWeb.SubmitLive.CsvUploadComponent do @moduledoc false use MicrowavepropWeb, :html @doc false @spec csv_upload_form(map()) :: Phoenix.LiveView.Rendered.t() def csv_upload_form(assigns) do ~H"""

Upload a CSV file with multiple contacts. Columns:

station1, station2, grid1, grid2, band, mode, qso_timestamp, notes
  • Timestamps in most formats accepted (e.g. 2024-06-15T14:30:00Z, 6/15/2024 2:30 PM, 2024-06-15 14:30). All times assumed UTC.
  • Grid squares should be as detailed as possible (8 characters preferred, e.g. EM12kp37)
  • Band in MHz (e.g. 10000, 24000)
  • Mode is optional — omit the mode column entirely (6 columns total) or leave its value blank.
  • Notes is optional — free-form operator commentary up to 2000 characters. Leave the cell blank to store NULL.

<.icon name="hero-arrow-down-tray" class="w-4 h-4" /> Download sample CSV

{entry.client_name} {entry.progress}%
{error_to_string(err)}
{error_to_string(err)}
<%= if @current_user do %> <% end %>
""" end defp error_to_string(:too_large), do: "File is too large" defp error_to_string(:too_many_files), do: "Only one file allowed" defp error_to_string(:not_accepted), do: "File type not accepted" defp error_to_string(other), do: to_string(other) # An upload entry is actively streaming when its progress is partway # between 0 and 100. With `auto_upload: false` entries sit at # `progress: 0` after the user picks a file and only start streaming # when the form is submitted, so gating the progress bar and percent # text on the 0 < progress < 100 window keeps them hidden until the # upload is actually in flight. defp uploading?(%{progress: progress}), do: progress > 0 and progress < 100 defp uploading?(_), do: false end