Skip to main content

max / makenotwork

4.0 KB · 105 lines History Blame Raw
1 {%- import "partials/_ui.html" as ui -%}
2 <div class="tab-docs"><a href="/docs/analytics">Docs: Analytics &rarr;</a> <a href="/dashboard/export" class="analytics-export-link">Export data &rarr;</a></div>
3
4 <div class="analytics-range-bar">
5 <h2 class="analytics-range-heading">{% 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/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/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/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/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("Once you publish items and make sales, revenue data will appear here.") %}
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 {% if project_comparisons.len() > 1 %}
57 <div class="chart-container analytics-section--comparison">
58 <h2 class="subsection-title">Project Comparison</h2>
59 <div class="analytics-table-wrap">
60 <table class="data-table analytics-table">
61 <thead>
62 <tr>
63 <th>Project</th>
64 <th>Revenue</th>
65 <th>Sales</th>
66 <th>Views</th>
67 <th>Conversion</th>
68 </tr>
69 </thead>
70 <tbody>
71 {% for p in project_comparisons %}
72 <tr>
73 <td>{{ p.title }}</td>
74 <td>
75 <div class="analytics-revenue-cell">
76 <div class="analytics-revenue-bar" style="width: {{ p.revenue_pct }}%;"></div>
77 {{ p.revenue }}
78 </div>
79 </td>
80 <td>{{ p.sales }}</td>
81 <td>{{ p.views }}</td>
82 <td>{{ p.conversion }}</td>
83 </tr>
84 {% endfor %}
85 </tbody>
86 </table>
87 </div>
88 </div>
89 {% endif %}
90
91 <div class="analytics-grid">
92 <div class="card-muted">
93 <h3>Top Projects by Revenue</h3>
94 {% if top_projects.is_empty() %}
95 {% call ui::empty_state_compact("No revenue data yet. Sales across your projects will appear here.") %}
96 {% else %}
97 <ul class="analytics-list">
98 {% for project in top_projects %}
99 <li><span>{{ project.title }}</span><span>{{ project.revenue }}</span></li>
100 {% endfor %}
101 </ul>
102 {% endif %}
103 </div>
104 </div>
105