Skip to main content

max / makenotwork

5.1 KB · 104 lines History Blame Raw
1 {%- import "partials/_ui.html" as ui -%}
2 <div id="promo-codes-list">
3 {% if promo_codes.is_empty() %}
4 {% call ui::empty_state("", "No promo codes yet. Create one above to offer discounts, free access, or trial periods to your fans.") %}{% endcall %}
5 {% else %}
6 <table class="data-table well">
7 <thead>
8 <tr>
9 <th>Code</th>
10 <th>Type</th>
11 <th>Uses</th>
12 <th>Scope</th>
13 <th>Schedule</th>
14 <th></th>
15 </tr>
16 </thead>
17 <tbody>
18 {% for code in promo_codes %}
19 <tr{% if code.is_expired %} class="promo-codes-row--expired"{% else if code.is_not_yet_active %} class="promo-codes-row--pending"{% endif %}>
20 <td>
21 <span class="key-code" title="Click to copy" data-copy="{{ code.code }}" data-action="copyText">{{ crate::quasi::literal::html(code.code.as_str())|safe }}</span>
22 </td>
23 <td>{{ code.description }}</td>
24 <td>
25 {% if code.use_count > 0 %}
26 <button class="btn-link btn-sm" type="button"
27 data-action="showPromoRedemptions"
28 data-arg="{{ code.id }}"
29 data-arg2="{{ code.code }}"
30 title="Show who redeemed this code">
31 {{ code.use_count }}{% if let Some(max) = code.max_uses %} / {{ max }}{% else %} / &infin;{% endif %}
32 </button>
33 {% else %}
34 {{ code.use_count }}{% if let Some(max) = code.max_uses %} / {{ max }}{% else %} / &infin;{% endif %}
35 {% endif %}
36 </td>
37 <td>
38 {% if let Some(title) = code.item_title %}
39 {{ title }}
40 {% else if let Some(title) = code.project_title %}
41 {{ title }}
42 {% else %}
43 All items
44 {% endif %}
45 </td>
46 <td class="promo-codes-schedule">
47 {% if let Some(start) = code.starts_at %}
48 <div{% if code.is_not_yet_active %} class="promo-codes-schedule-pending"{% endif %}>
49 {% if code.is_not_yet_active %}Starts{% else %}Started{% endif %} {{ start }}
50 </div>
51 {% endif %}
52 {% if let Some(exp) = code.expires_at %}
53 <div{% if code.is_expired %} class="promo-codes-schedule-expired"{% endif %}>
54 {% if code.is_expired %}Expired{% else %}Expires{% endif %} {{ exp }}
55 </div>
56 {% endif %}
57 {% if code.starts_at.is_none() && code.expires_at.is_none() %}
58 <span class="promo-codes-schedule-none">No schedule</span>
59 {% endif %}
60 </td>
61 <td class="promo-codes-actions">
62 <button class="btn-secondary small promo-codes-edit-btn"
63 data-action="togglePromoEditRow">Edit</button>
64 {{ crate::quasi::promo_code_acts::html(code.id)|safe }}
65 </td>
66 </tr>
67 <tr class="hidden promo-codes-edit-row">
68 <td colspan="6" class="promo-codes-edit-cell">
69 <form class="promo-codes-edit-form"
70 hx-put="/api/promo-codes/{{ code.id }}"
71 hx-target="#promo-codes-list"
72 hx-swap="outerHTML">
73 <div>
74 <label class="promo-codes-edit-label">Max uses</label>
75 <input type="number" name="max_uses" min="1" placeholder="Unlimited"
76 value="{{ code.max_uses_raw }}"
77 class="promo-codes-edit-input input--sm w-100">
78 </div>
79 <div>
80 <label class="promo-codes-edit-label">Starts</label>
81 <input type="date" name="starts_at"
82 value="{{ code.starts_at_raw.as_deref().unwrap_or_default() }}"
83 class="promo-codes-edit-input input--sm">
84 </div>
85 <div>
86 <label class="promo-codes-edit-label">Expires</label>
87 <input type="date" name="expires_at"
88 value="{{ code.expires_at_raw.as_deref().unwrap_or_default() }}"
89 class="promo-codes-edit-input input--sm">
90 </div>
91 <button class="btn-secondary small promo-codes-edit-save" type="submit">Save</button>
92 </form>
93 </td>
94 </tr>
95 {% endfor %}
96 </tbody>
97 </table>
98
99 <div class="promo-codes-bulk-row">
100 {{ crate::quasi::promo_code_acts::expired_html()|safe }}
101 </div>
102 {% endif %}
103 </div>
104