brewlog/templates/add.html
Jon Seager 4a54834424
refactor(ui): extract reusable tab bar component
- Create shared tab_bar.html partial with desktop + mobile layouts
- Add CSS component classes (.tab, .tab-active, .tab-mobile variants)
- Replace divergent implementations in data.html and add.html
- Rename DataTab to Tab for shared use across templates
- Improve readability: darker inactive text, more spacing, hover states
2026-02-05 17:23:50 +00:00

579 lines
29 KiB
HTML

{% extends "base.html" %} {% import "partials/icons.html" as icons %} {% import "partials/scan_input.html" as scan %} {% import "partials/location_search.html" as location %} {% block title %}Brewlog · Add{% endblock %}
{% block head %}
<script>
{% call location::location_search_js() %}
</script>
{% endblock %}
{% block content %}
<!-- Scan Bag (Quick Add) -->
<section
data-signals:_extracting="false"
data-signals:_extract-error="''"
data-signals:_scan-extracted="false"
data-signals:_scan-submitting="false"
data-signals:_scan-error="''"
data-signals:_roaster-name="''"
data-signals:_roaster-country="''"
data-signals:_roaster-city="''"
data-signals:_roaster-homepage="''"
data-signals:_roast-name="''"
data-signals:_origin="''"
data-signals:_region="''"
data-signals:_producer="''"
data-signals:_process="''"
data-signals:_tasting-notes="''"
data-signals:_open-bag="true"
data-signals:_bag-amount="250"
>
<!-- Input: photo or text -->
<div data-show="!$_scanExtracted" class="rounded-lg border bg-surface p-5">
<form id="scan-extract-form"
data-on:submit="$_extracting = true; $_extractError = ''; $_roasterName = ''; $_roasterCountry = ''; $_roasterCity = ''; $_roasterHomepage = ''; $_roastName = ''; $_origin = ''; $_region = ''; $_producer = ''; $_process = ''; $_tastingNotes = ''; @post('/api/v1/extract-bag-scan', {contentType: 'form'})"
data-on:datastar-fetch="if (!$_extracting) return; if (evt.detail.type === 'finished') { $_extracting = false; $_scanExtracted = true; document.getElementById('scan-extract-form').reset() } else if (evt.detail.type === 'error') { $_extracting = false; $_extractError = 'Extraction failed. Please try again.' }"
>
{% call scan::scan_input("scan-extract-form", "scan-image", "$_extracting", "$_extractError", "Describe the coffee bag…", "Waiting for response…") %}
</form>
</div>
<!-- Scan result form -->
<div data-show="$_scanExtracted" style="display: none">
<form
class="rounded-lg border bg-surface p-5 flex flex-col gap-6"
data-on:submit="$_scanSubmitting = true; $_scanError = ''; @post('/api/v1/scan', {contentType: 'form'})"
data-on:datastar-fetch="if (!$_scanSubmitting) return; if (evt.detail.type === 'finished') { $_scanSubmitting = false; window.location.href = '/data?type=bags' } else if (evt.detail.type === 'error') { $_scanSubmitting = false; $_scanError = 'Save failed. Please try again.' }"
>
<div>
<h3 class="text-base font-semibold text-stone-800">Roaster</h3>
<p class="mt-1 text-sm text-stone-600">If this roaster already exists, it will be matched automatically.</p>
<div class="mt-4 grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Name *</span>
<input type="text" name="roaster_name" required class="input-field" placeholder="Example Coffee Roasters" data-bind:_roaster-name />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Country *</span>
<input type="text" name="roaster_country" required class="input-field" placeholder="United States" data-bind:_roaster-country />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">City</span>
<input type="text" name="roaster_city" class="input-field" placeholder="Portland" data-bind:_roaster-city />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Homepage</span>
<input type="url" name="roaster_homepage" class="input-field" placeholder="https://example.coffee" data-bind:_roaster-homepage />
</label>
</div>
</div>
<div>
<h3 class="text-base font-semibold text-stone-800">Roast</h3>
<p class="mt-1 text-sm text-stone-600">Details about this specific coffee.</p>
<div class="mt-4 grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Roast Name *</span>
<input type="text" name="roast_name" required class="input-field" placeholder="Ethiopia Yirgacheffe" data-bind:_roast-name />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Origin *</span>
<input type="text" name="origin" required class="input-field" placeholder="Ethiopia" data-bind:_origin />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Region *</span>
<input type="text" name="region" required class="input-field" placeholder="Guji" data-bind:_region />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Producer *</span>
<input type="text" name="producer" required class="input-field" placeholder="Chelbesa Cooperative" data-bind:_producer />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Process *</span>
<input type="text" name="process" required class="input-field" placeholder="Washed" data-bind:_process />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Tasting Notes * (comma separated)</span>
<textarea name="tasting_notes" rows="2" required class="input-field" placeholder="Blueberry, Jasmine" data-bind:_tasting-notes></textarea>
</label>
</div>
</div>
<div>
<label class="inline-flex items-center gap-2 text-sm cursor-pointer">
<input type="checkbox" name="open_bag" value="true" class="accent-orange-700" data-bind:_open-bag />
<span class="font-semibold text-stone-800">Open a bag of this coffee</span>
</label>
<div data-show="$_openBag" class="mt-3 grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Amount (grams)</span>
<input type="number" name="bag_amount" min="1" step="any" class="input-field" placeholder="250" data-bind:_bag-amount />
</label>
</div>
</div>
<p data-show="$_scanError" data-text="$_scanError" style="display:none" class="text-sm text-red-600"></p>
<div data-show="$_scanSubmitting" style="display:none" class="flex items-center gap-3 text-sm text-stone-800">
{% call icons::spinner("h-5 w-5") %}
Saving&hellip;
</div>
<div data-show="!$_scanSubmitting" class="flex items-center justify-end gap-2">
<button
type="button"
data-on:click="$_scanExtracted = false"
class="rounded-md border px-4 py-2 text-sm font-semibold text-stone-700 transition hover:border-accent hover:text-stone-800"
>
Cancel
</button>
<button
type="submit"
class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover"
>
Save Roaster &amp; Roast
</button>
</div>
</form>
</div>
</section>
<!-- Manual Add -->
<section
data-signals:_add-submitting="false"
data-signals:_add-roaster-name="''"
data-signals:_add-roaster-country="''"
data-signals:_add-roaster-city="''"
data-signals:_add-roaster-homepage="''"
data-signals:_add-roast-name="''"
data-signals:_add-origin="''"
data-signals:_add-region="''"
data-signals:_add-producer="''"
data-signals:_add-process="''"
data-signals:_add-tasting-notes="''"
data-signals:_brew-temp="{{ defaults.water_temp }}"
data-signals:_brew-grind="{{ defaults.grind_setting }}"
data-signals:_brew-volume="{{ defaults.water_volume }}"
data-signals:_brew-weight="{{ defaults.coffee_weight }}"
data-signals:_cafe-id="''"
data-signals:_cafe-name="''"
data-signals:_cafe-city="''"
data-signals:_cafe-country="''"
data-signals:_cafe-lat="''"
data-signals:_cafe-lng="''"
data-signals:_cafe-website="''"
data-signals:_cafe-search="''"
data-signals:_cafe-error="''"
data-signals:_city-name="''"
data-signals:_locating="false"
data-signals:_location-found="false"
data-signals:_user-lat="0"
data-signals:_user-lng="0"
data-signals:_reviewing-cafe="false"
>
<h2 class="text-lg font-semibold text-stone-800 mb-3">Manual Add</h2>
<!-- Entity type selector -->
<div class="rounded-lg border bg-surface mb-4">
{% include "partials/tab_bar.html" %}
</div>
<!-- ========== ROASTER FORM ========== -->
<div data-show="$_addType === 'roaster'" style="display:none" class="rounded-lg border bg-surface p-5">
<div>
<h3 class="text-lg font-semibold text-stone-800">New Roaster</h3>
<p class="mt-1 text-sm text-stone-600">Provide the core details and Brewlog will keep track of everything for you.</p>
</div>
<form method="post" action="/api/v1/roasters" class="mt-4 flex flex-col gap-4">
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Name *</span>
<input type="text" name="name" required class="input-field" placeholder="Example Coffee Roasters" data-bind:_add-roaster-name />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Country *</span>
<input type="text" name="country" required class="input-field" placeholder="United States" data-bind:_add-roaster-country />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">City</span>
<input type="text" name="city" class="input-field" placeholder="Portland" data-bind:_add-roaster-city />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Homepage</span>
<input type="url" name="homepage" class="input-field" placeholder="https://example.coffee" data-bind:_add-roaster-homepage />
</label>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Save Roaster
</button>
</div>
</form>
</div>
<!-- ========== ROAST FORM ========== -->
<div data-show="$_addType === 'roast'" style="display:none" class="rounded-lg border bg-surface p-5">
{% if roaster_options.is_empty() %}
<div class="text-sm text-stone-600">
<h3 class="text-lg font-semibold text-stone-800">Add a roaster first</h3>
<p class="mt-2">Roasts need a roaster. Add a roaster above to enable this form.</p>
</div>
{% else %}
<div>
<h3 class="text-lg font-semibold text-stone-800">New Roast</h3>
<p class="mt-1 text-sm text-stone-600">Select a roaster and fill in the details.</p>
</div>
<form method="post" action="/api/v1/roasts" class="mt-4 flex flex-col gap-4">
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Roaster *</span>
<searchable-select name="roaster_id" placeholder="Type to search roasters&hellip;">
{% for roaster in roaster_options %}
<button type="button" value="{{ roaster.id }}" data-display="{{ roaster.name }}"
class="w-full px-3 py-2 text-left text-sm hover:bg-surface-alt transition">
<span class="font-medium text-stone-800">{{ roaster.name }}</span>
</button>
{% endfor %}
</searchable-select>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Roast Name *</span>
<input type="text" name="name" required class="input-field" placeholder="Ethiopia Yirgacheffe" data-bind:_add-roast-name />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Origin *</span>
<input type="text" name="origin" required class="input-field" placeholder="Ethiopia" data-bind:_add-origin />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Region *</span>
<input type="text" name="region" required class="input-field" placeholder="Guji" data-bind:_add-region />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Producer *</span>
<input type="text" name="producer" required class="input-field" placeholder="Chelbesa Cooperative" data-bind:_add-producer />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Process *</span>
<input type="text" name="process" required class="input-field" placeholder="Washed" data-bind:_add-process />
</label>
<label class="sm:col-span-2 flex flex-col gap-1 text-sm">
<span class="text-stone-700">Tasting Notes * (comma or newline separated)</span>
<textarea name="tasting_notes" rows="2" required class="input-field" placeholder="Blueberry, Jasmine" data-bind:_add-tasting-notes></textarea>
</label>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Save Roast
</button>
</div>
</form>
{% endif %}
</div>
<!-- ========== BAG FORM ========== -->
<div data-show="$_addType === 'bag'" style="display:none" class="rounded-lg border bg-surface p-5">
{% if roast_options.is_empty() %}
<div class="text-sm text-stone-600">
<h3 class="text-lg font-semibold text-stone-800">Add a roast first</h3>
<p class="mt-2">Bags need a roast. Add a roaster and roast to enable this form.</p>
</div>
{% else %}
<div>
<h3 class="text-lg font-semibold text-stone-800">New Bag</h3>
<p class="mt-1 text-sm text-stone-600">Select a roast and enter the details.</p>
</div>
<form method="post" action="/api/v1/bags" class="mt-4 flex flex-col gap-4">
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Roast *</span>
<searchable-select name="roast_id" placeholder="Type to search roasts&hellip;">
{% for roast in roast_options %}
<button type="button" value="{{ roast.id }}" data-display="{{ roast.label }}"
class="w-full px-3 py-2 text-left text-sm hover:bg-surface-alt transition">
<span class="font-medium text-stone-800">{{ roast.name }}</span>
<span class="ml-2 text-xs text-stone-500">{{ roast.roaster_name }}</span>
</button>
{% endfor %}
</searchable-select>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Roast Date</span>
<input type="date" name="roast_date" class="input-field" />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Amount (g) *</span>
<input type="number" name="amount" step="0.1" required class="input-field" placeholder="250" />
</label>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Save Bag
</button>
</div>
</form>
{% endif %}
</div>
<!-- ========== BREW FORM ========== -->
<div data-show="$_addType === 'brew'" style="display:none" class="rounded-lg border bg-surface p-5">
{% if bag_options.is_empty() %}
<div class="text-sm text-stone-600">
<h3 class="text-lg font-semibold text-stone-800">Open a bag first</h3>
<p class="mt-2">Brews need an open bag of coffee. Add a bag to enable this form.</p>
</div>
{% else if grinder_options.is_empty() || brewer_options.is_empty() %}
<div class="text-sm text-stone-600">
<h3 class="text-lg font-semibold text-stone-800">Add your gear first</h3>
<p class="mt-2">Brews need a grinder and brewer. Add your gear to enable this form.</p>
</div>
{% else %}
<div>
<h3 class="text-lg font-semibold text-stone-800">New Brew</h3>
<p class="mt-1 text-sm text-stone-600">Log a cup of coffee.</p>
</div>
<form method="post" action="/api/v1/brews" class="mt-4 flex flex-col gap-6 overflow-hidden">
<!-- Coffee -->
<div>
<h4 class="text-xs font-semibold text-stone-500 uppercase tracking-wide mb-3">Coffee</h4>
<div class="grid gap-4 sm:grid-cols-2">
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Bag *</span>
<searchable-select name="bag_id" placeholder="Type to search bags&hellip;">
{% for bag in bag_options %}
<button type="button" value="{{ bag.id }}" data-display="{{ bag.roast_name }}"
class="w-full px-3 py-2 text-left text-sm hover:bg-surface-alt transition">
<span class="font-medium text-stone-800">{{ bag.roast_name }}</span>
<span class="ml-2 text-xs text-stone-500">{{ bag.roaster_name }} &middot; {{ bag.remaining }}</span>
</button>
{% endfor %}
</searchable-select>
</div>
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Weight (g) *</span>
<div class="flex items-center gap-2">
<button type="button" class="btn-adjust" data-on:click="$_brewWeight = Math.max(1, $_brewWeight - 0.5)">-</button>
<input type="number" name="coffee_weight" step="any" min="1" required class="input-field flex-1 text-center" data-attr:value="$_brewWeight" data-on:input="$_brewWeight = this.valueAsNumber" />
<button type="button" class="btn-adjust" data-on:click="$_brewWeight = $_brewWeight + 0.5">+</button>
</div>
</div>
</div>
</div>
<!-- Grinder -->
<div>
<h4 class="text-xs font-semibold text-stone-500 uppercase tracking-wide mb-3">Grinder</h4>
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Grinder *</span>
<select name="grinder_id" required class="input-field">
{% for grinder in grinder_options %}
<option value="{{ grinder.id }}"{% if grinder.id == defaults.grinder_id %} selected{% endif %}>{{ grinder.label }}</option>
{% endfor %}
</select>
</label>
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Grind Setting *</span>
<div class="flex items-center gap-2">
<button type="button" class="btn-adjust" data-on:click="$_brewGrind = Math.max(0, $_brewGrind - 0.5)">-</button>
<input type="number" name="grind_setting" step="any" min="0" required class="input-field flex-1 text-center" data-attr:value="$_brewGrind" data-on:input="$_brewGrind = this.valueAsNumber" />
<button type="button" class="btn-adjust" data-on:click="$_brewGrind = $_brewGrind + 0.5">+</button>
</div>
</div>
</div>
</div>
<!-- Brewer -->
<div>
<h4 class="text-xs font-semibold text-stone-500 uppercase tracking-wide mb-3">Brewer</h4>
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Brewer *</span>
<select name="brewer_id" required class="input-field">
{% for brewer in brewer_options %}
<option value="{{ brewer.id }}"{% if brewer.id == defaults.brewer_id %} selected{% endif %}>{{ brewer.label }}</option>
{% endfor %}
</select>
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Filter Paper</span>
<select name="filter_paper_id" class="input-field">
<option value="">None</option>
{% for fp in filter_paper_options %}
<option value="{{ fp.id }}"{% if fp.id == defaults.filter_paper_id %} selected{% endif %}>{{ fp.label }}</option>
{% endfor %}
</select>
</label>
</div>
</div>
<!-- Water -->
<div>
<h4 class="text-xs font-semibold text-stone-500 uppercase tracking-wide mb-3">Water</h4>
<div class="grid gap-4 sm:grid-cols-2">
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Volume (ml) *</span>
<div class="flex items-center gap-2">
<button type="button" class="btn-adjust" data-on:click="$_brewVolume = Math.max(10, $_brewVolume - 10)">-</button>
<input type="number" name="water_volume" step="any" min="10" required class="input-field flex-1 text-center" data-attr:value="$_brewVolume" data-on:input="$_brewVolume = this.valueAsNumber" />
<button type="button" class="btn-adjust" data-on:click="$_brewVolume = $_brewVolume + 10">+</button>
</div>
</div>
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Temp (&deg;C) *</span>
<div class="flex items-center gap-2">
<button type="button" class="btn-adjust" data-on:click="$_brewTemp = Math.max(0, $_brewTemp - 0.5)">-</button>
<input type="number" name="water_temp" step="any" min="0" max="100" required class="input-field flex-1 text-center" data-attr:value="$_brewTemp" data-on:input="$_brewTemp = this.valueAsNumber" />
<button type="button" class="btn-adjust" data-on:click="$_brewTemp = Math.min(100, $_brewTemp + 0.5)">+</button>
</div>
</div>
</div>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Log Brew
</button>
</div>
</form>
{% endif %}
</div>
<!-- ========== GEAR FORM ========== -->
<div data-show="$_addType === 'gear'" style="display:none" class="rounded-lg border bg-surface p-5">
<div>
<h3 class="text-lg font-semibold text-stone-800">New Gear</h3>
<p class="mt-1 text-sm text-stone-600">Add brewing equipment to your collection.</p>
</div>
<form method="post" action="/api/v1/gear" class="mt-4 flex flex-col gap-4">
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Category *</span>
<select name="category" required class="input-field">
<option value="">Select a category</option>
<option value="grinder">Grinder</option>
<option value="brewer">Brewer</option>
<option value="filter_paper">Filter Paper</option>
</select>
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Make *</span>
<input type="text" name="make" required class="input-field" placeholder="Baratza" />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Model *</span>
<input type="text" name="model" required class="input-field" placeholder="Encore" />
</label>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Save Gear
</button>
</div>
</form>
</div>
<!-- ========== CAFE FORM ========== -->
<div data-show="$_addType === 'cafe'" style="display:none" class="rounded-lg border bg-surface p-5">
<div>
<h3 class="text-lg font-semibold text-stone-800">New Cafe</h3>
<p class="mt-1 text-sm text-stone-600">Search for a nearby cafe or enter details manually.</p>
</div>
<!-- Location search -->
<div class="mt-4 border-b pb-4" data-show="!$_reviewingCafe">
{% call location::location_search("$_cafeError") %}
<p data-show="$_cafeError" data-text="$_cafeError" style="display:none" class="mt-2 text-sm text-red-600"></p>
</div>
<!-- Selected cafe indicator -->
<div class="mt-4 border-b pb-4 flex items-center justify-between" data-show="$_reviewingCafe" style="display:none">
<div class="flex items-center gap-2">
{% call icons::location("h-4 w-4 text-accent shrink-0") %}
<span class="text-sm font-medium text-stone-800" data-text="$_cafeName"></span>
<span class="text-xs text-stone-500" data-show="$_cafeCity" data-text="$_cafeCity" style="display:none"></span>
</div>
<button type="button"
class="text-xs text-stone-500 hover:text-stone-700"
data-on:click="$_reviewingCafe = false; $_cafeName = ''; $_cafeCity = ''; $_cafeCountry = ''; $_cafeLat = ''; $_cafeLng = ''; $_cafeWebsite = ''"
>Back</button>
</div>
<form id="cafe-form" method="post" action="/api/v1/cafes" class="mt-4 flex flex-col gap-4">
<div class="grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Name *</span>
<input type="text" name="name" required class="input-field" placeholder="Blue Bottle Coffee" data-bind:_cafe-name />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">City *</span>
<input type="text" name="city" required class="input-field" placeholder="San Francisco" data-bind:_cafe-city />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Country *</span>
<input type="text" name="country" required class="input-field" placeholder="United States" data-bind:_cafe-country />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Website</span>
<input type="url" name="website" class="input-field" placeholder="https://bluebottlecoffee.com" data-bind:_cafe-website />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Latitude *</span>
<input type="number" name="latitude" step="any" required class="input-field" placeholder="37.7749" data-bind:_cafe-lat />
</label>
<label class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Longitude *</span>
<input type="number" name="longitude" step="any" required class="input-field" placeholder="-122.4194" data-bind:_cafe-lng />
</label>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Save Cafe
</button>
</div>
</form>
</div>
<!-- ========== CUP FORM ========== -->
<div data-show="$_addType === 'cup'" style="display:none" class="rounded-lg border bg-surface p-5">
{% if roast_options.is_empty() || cafe_options.is_empty() %}
<div class="text-sm text-stone-600">
<h3 class="text-lg font-semibold text-stone-800">Add a roast and cafe first</h3>
<p class="mt-2">Cups need both a roast and a cafe. Add them above to enable this form.</p>
</div>
{% else %}
<div>
<h3 class="text-lg font-semibold text-stone-800">New Cup</h3>
<p class="mt-1 text-sm text-stone-600">Record a coffee you had at a cafe.</p>
</div>
<form method="post" action="/api/v1/cups" class="mt-4 flex flex-col gap-4">
<div class="grid gap-4 sm:grid-cols-2">
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Coffee *</span>
<searchable-select name="roast_id" placeholder="Type to search roasts&hellip;">
{% for roast in roast_options %}
<button type="button" value="{{ roast.id }}" data-display="{{ roast.name }}"
class="w-full px-3 py-2 text-left text-sm hover:bg-surface-alt transition">
<span class="font-medium text-stone-800">{{ roast.name }}</span>
<span class="ml-2 text-xs text-stone-500">{{ roast.roaster_name }}</span>
</button>
{% endfor %}
</searchable-select>
</div>
<div class="flex flex-col gap-1 text-sm">
<span class="text-stone-700">Cafe *</span>
<searchable-select name="cafe_id" placeholder="Type to search cafes&hellip;">
{% for cafe in cafe_options %}
<button type="button" value="{{ cafe.id }}" data-display="{{ cafe.name }}"
class="w-full px-3 py-2 text-left text-sm hover:bg-surface-alt transition">
<span class="font-medium text-stone-800">{{ cafe.name }}</span>
<span class="ml-2 text-xs text-stone-500">{{ cafe.city }}</span>
</button>
{% endfor %}
</searchable-select>
</div>
</div>
<div class="flex items-center justify-end">
<button type="submit" class="rounded-md bg-accent px-4 py-2 text-sm font-semibold text-accent-text transition hover:bg-accent-hover">
Save Cup
</button>
</div>
</form>
{% endif %}
</div>
</section>
{% endblock %}