| 1 |
{%- import "partials/_ui.html" as ui -%} |
| 2 |
<div class="tab-docs"><a href="/docs/analytics">Docs: Analytics →</a> <a href="/dashboard/export" class="tab-docs-extra">Export data →</a></div> |
| 3 |
|
| 4 |
<div class="analytics-tab-header"> |
| 5 |
<h2 class="subsection-title">{% if active_range == "7d" %}Last 7 days{% else if active_range == "30d" %}Last 30 days{% else if active_range == "90d" %}Last 90 days{% else %}All time{% endif %}</h2> |
| 6 |
<div class="time-selector"> |
| 7 |
<button class="{% if active_range == "7d" %}is-selected{% endif %}" |
| 8 |
hx-get="/dashboard/project/{{ project_slug }}/tabs/analytics?range=7d" |
| 9 |
hx-target="#tab-content" |
| 10 |
hx-swap="innerHTML">7d</button> |
| 11 |
<button class="{% if active_range == "30d" %}is-selected{% endif %}" |
| 12 |
hx-get="/dashboard/project/{{ project_slug }}/tabs/analytics?range=30d" |
| 13 |
hx-target="#tab-content" |
| 14 |
hx-swap="innerHTML">30d</button> |
| 15 |
<button class="{% if active_range == "90d" %}is-selected{% endif %}" |
| 16 |
hx-get="/dashboard/project/{{ project_slug }}/tabs/analytics?range=90d" |
| 17 |
hx-target="#tab-content" |
| 18 |
hx-swap="innerHTML">90d</button> |
| 19 |
<button class="{% if active_range == "all" %}is-selected{% endif %}" |
| 20 |
hx-get="/dashboard/project/{{ project_slug }}/tabs/analytics?range=all" |
| 21 |
hx-target="#tab-content" |
| 22 |
hx-swap="innerHTML">All</button> |
| 23 |
</div> |
| 24 |
</div> |
| 25 |
|
| 26 |
<div class="stats-grid"> |
| 27 |
{% for stat in stats %} |
| 28 |
<div class="card-muted"> |
| 29 |
<div class="stat-label">{{ stat.label }}</div> |
| 30 |
<div class="stat-value">{{ stat.value }}</div> |
| 31 |
{% if let Some(change) = stat.change %} |
| 32 |
<div class="stat-change{% if stat.is_positive %} positive{% endif %}">{{ change }}</div> |
| 33 |
{% endif %} |
| 34 |
</div> |
| 35 |
{% endfor %} |
| 36 |
</div> |
| 37 |
|
| 38 |
<div class="chart-container"> |
| 39 |
<div class="chart-header"> |
| 40 |
<h2 class="subsection-title">Revenue Over Time</h2> |
| 41 |
</div> |
| 42 |
{% if bars.is_empty() %} |
| 43 |
{% call ui::empty_state_chart("No revenue data yet. Revenue will appear here after your first sale. Publish an item and share it to get started.") %} |
| 44 |
{% else %} |
| 45 |
<div class="chart-bars"> |
| 46 |
{% for bar in bars %} |
| 47 |
<div class="chart-bar-col" data-tooltip="{{ bar.value }} / {{ bar.count }} sale{% if bar.count != 1 %}s{% endif %}"> |
| 48 |
<div class="chart-bar" style="height: {{ bar.height_pct }}%;"></div> |
| 49 |
<div class="chart-bar-label">{{ bar.label }}</div> |
| 50 |
</div> |
| 51 |
{% endfor %} |
| 52 |
</div> |
| 53 |
{% endif %} |
| 54 |
</div> |
| 55 |
|
| 56 |
<div class="analytics-grid"> |
| 57 |
<div class="card-muted"> |
| 58 |
<h3>Top Performing Items</h3> |
| 59 |
{% if items.is_empty() %} |
| 60 |
<div class="analytics-empty-block"> |
| 61 |
<p>No sales data yet. Publish and promote your items to see analytics here.</p> |
| 62 |
</div> |
| 63 |
{% else %} |
| 64 |
<ul class="analytics-list"> |
| 65 |
{% for item in items %} |
| 66 |
<li><span>{{ item.title }}</span><span>{{ item.revenue }}</span></li> |
| 67 |
{% endfor %} |
| 68 |
</ul> |
| 69 |
{% endif %} |
| 70 |
</div> |
| 71 |
</div> |
| 72 |
|