{% extends "admin/base.html" %}

{% block title %}{{ t(key="upload-song-title", lang=lang | default(value='sk')) }}{% endblock title %}
{% block crumb %}audio/upload{% endblock crumb %}

{% block content %}
<header class="term-cmd">
  <div>
    <h1 class="term-title">{{ t(key="upload-song-title", lang=lang | default(value='sk')) }}</h1>
    {% if album %}
    <p class="term-sub">{{ t(key="upload-into-album-help", lang=lang | default(value='sk')) }} "{{ album.title }}".</p>
    {% else %}
    <p class="term-sub">{{ t(key="upload-single-help", lang=lang | default(value='sk')) }}</p>
    {% endif %}
  </div>
  <div class="term-cmd-actions">
    {% if album %}
    <a href="/admin/audio/albums/{{ album.id }}/tracks" class="btn btn-outline btn-sm">{{ t(key="cancel", lang=lang | default(value='sk')) }}</a>
    {% else %}
    <a href="/admin/audio/tracks" class="btn btn-outline btn-sm">{{ t(key="cancel", lang=lang | default(value='sk')) }}</a>
    {% endif %}
  </div>
</header>

<div class="card">
  <div class="term-head">
    <span class="term-head-name">{% if album %}~/audio/{{ album.slug }}/upload{% else %}~/audio/songs/upload{% endif %}</span>
  </div>
  <div class="card-body">
    {% if album %}
    <form method="post" action="/admin/audio/albums/{{ album.id }}/tracks/upload-file" enctype="multipart/form-data" class="space-y-2">
    {% else %}
    <form method="post" action="/admin/audio/tracks/upload-file" enctype="multipart/form-data" class="space-y-2">
    {% endif %}
      <div class="form-control">
        <label class="label"><span class="label-text t-green">1. {{ t(key="audio-file", lang=lang | default(value='sk')) }}</span></label>
        <input type="file" name="file" accept="audio/mpeg,audio/wav,audio/ogg,audio/flac,audio/aac,audio/mp4,audio/webm" required class="file-input file-input-bordered w-full">
        <p class="term-help">{{ t(key="audio-file-help", lang=lang | default(value='sk')) }}</p>
      </div>

      <div class="form-control">
        <label class="label"><span class="label-text t-green">2. {{ t(key="title", lang=lang | default(value='sk')) }}</span></label>
        <input type="text" name="title" class="input input-bordered w-full">
        <p class="term-help">{{ t(key="title-help", lang=lang | default(value='sk')) }}</p>
      </div>

      {% if album %}
      <div class="form-control">
        <label class="label"><span class="label-text t-green">3. {{ t(key="track-number", lang=lang | default(value='sk')) }}</span></label>
        <input type="number" name="track_number" min="1" class="input input-bordered w-full" placeholder="1">
        <p class="term-help">{{ t(key="track-number-help", lang=lang | default(value='sk')) }}</p>
      </div>
      {% endif %}

      <label class="label cursor-pointer justify-start gap-2">
        <input type="checkbox" name="featured" class="checkbox checkbox-sm">
        <span class="label-text">{{ t(key="featured-help", lang=lang | default(value='sk')) }}</span>
      </label>

      <label class="label cursor-pointer justify-start gap-2">
        <input type="checkbox" name="published" class="checkbox checkbox-sm">
        <span class="label-text">{{ t(key="publish-song-now", lang=lang | default(value='sk')) }}</span>
      </label>

      <div class="flex flex-wrap gap-2 pt-2">
        <button type="submit" class="btn btn-primary btn-sm">{{ t(key="upload-song", lang=lang | default(value='sk')) }}</button>
        {% if album %}
        <a href="/admin/audio/albums/{{ album.id }}/tracks" class="btn btn-ghost btn-sm">{{ t(key="cancel", lang=lang | default(value='sk')) }}</a>
        {% else %}
        <a href="/admin/audio/tracks" class="btn btn-ghost btn-sm">{{ t(key="cancel", lang=lang | default(value='sk')) }}</a>
        {% endif %}
      </div>
    </form>
  </div>
</div>
{% endblock content %}
