@props(['action', 'method' => 'POST', 'subscription' => null])

<form action="{{ $action }}" method="POST" class="max-w-lg space-y-4 mt-6">
    @csrf
    @if($method !== 'POST')
        @method($method)
    @endif

    <div>
        <label class="block font-medium">Source URL (ICS or CalDAV)</label>
        <input name="source"
               type="url"
               value="{{ old('source', $subscription->source ?? '') }}"
               required class="input w-full">
    </div>

    <div>
        <label class="block font-medium">Display name</label>
        <input name="displayname"
               value="{{ old('displayname', $subscription->displayname ?? '') }}"
               class="input w-full">
    </div>

    <div class="flex space-x-4">
        <div class="flex-1">
            <label class="block font-medium">Colour</label>
            <input name="calendarcolor"
                   type="color"
                   value="{{ old('calendarcolor', $subscription->calendarcolor ?? '#888888') }}"
                   class="input w-20 h-9 p-0">
        </div>
        <div class="flex-1">
            <label class="block font-medium">
                Refresh&nbsp;rate <span class="text-xs text-gray-500">(ISO-8601)</span>
            </label>
            <input name="refreshrate"
                   placeholder="P1D"
                   value="{{ old('refreshrate', $subscription->refreshrate ?? '') }}"
                   class="input w-full">
        </div>
    </div>

    <button class="button button--primary">Save</button>
</form>
