This commit is contained in:
count-null 2025-03-06 17:23:18 -05:00
parent 1ed14b5549
commit 642546040a
13 changed files with 406 additions and 20 deletions

View file

@ -0,0 +1,9 @@
<section class="flex flex-col gap-4">
{% include 'lib/alert.twig' %}
<form action="/admin/categories/add" method="POST" class="flex flex-col gap-4">
{% include 'lib/forms/category.twig' %}
{% include 'lib/buttons/submit.twig' with {
label: 'Add Category'
} %}
</form>
</section>

View file

@ -0,0 +1,12 @@
{% include 'lib/alert.twig' %}
<form action="/admin/categories/edit/{{ category.id }}" method="post" class="flex flex-col gap-2">
{% include 'lib/forms/category.twig' with {
value: category.value,
label: category.label,
parent_id: category.parent_id
} %}
{% include 'lib/buttons/submit.twig' with {
label: 'Save Category'
} %}
</form>

View file

@ -0,0 +1,70 @@
<section class="flex flex-col gap-4">
{% include 'lib/alert.twig' %}
<h3 class="text-2xl font-semibold">
Categories
</h3>
<a href="/admin/categories/add">
{% include 'lib/buttons/primary.twig' with {
label: 'Create a Category'
} %}
</a>
<table class="min-w-full">
<tr>
<th class="py-2">
Category ID
</th>
<th class="py-2">
Title
</th>
<th class="py-2">
Slug
</th>
<th class="py-2">
Action
</th>
</tr>
</thead>
<tbody>
{% macro renderCategory(category, depth) %}
<tr>
<td class="border px-4 py-2">
{{ category.id }}
</td>
<td class="border px-4 py-2">
{% if depth > 0 %}
{% for i in 1..depth %}
-
{% endfor %}
{% endif %}
{{ category.label }}
</td>
<td class="border px-4 py-2">
{{ category.value }}
</td>
<td class="border px-4 py-2">
<a href="/admin/categories/edit/{{ category.id }}">
Edit
</a>
</td>
</tr>
{% if category.children is defined and category.children is not empty %}
{% for child in category.children %}
{{ _self.renderCategory(child, depth + 1) }}
{% endfor %}
{% endif %}
{% endmacro %}
{% if categories %}
{% for category in categories %}
{{ _self.renderCategory(category, 0) }}
{% endfor %}
{% else %}
<tr>
<td class="border px-4 py-2" colspan="4">
No categories yet.
</td>
</tr>
{% endif %}
</tbody>
</table></section>

View file

@ -5,6 +5,12 @@
<a href="/admin/users">
Users
</a>
<a href="/admin/products">
Products
</a>
<a href="/admin/categories">
Categories
</a>
<a href="/admin/orders">
Orders
</a>

View file

@ -0,0 +1,62 @@
<section class="flex flex-col gap-4">
{% include 'lib/alert.twig' %}
<h3 class="text-2xl font-semibold">
Categories
</h3>
<a href="/admin/categories/add">
{% include 'lib/buttons/primary.twig' with {
label: 'Create a Category'
} %}
</a>
<table class="min-w-full">
<tr>
<th class="py-2">
Category ID
</th>
<th class="py-2">
Title
</th>
<th class="py-2">
Slug
</th>
</tr>
</thead>
<tbody>
{% macro renderCategory(category, depth) %}
<tr>
<td class="border px-4 py-2">
{{ category.id }}
</td>
<td class="border px-4 py-2">
{% if depth > 0 %}
{% for i in 1..depth %}
-
{% endfor %}
{% endif %}
{{ category.label }}
</td>
<td class="border px-4 py-2">
{{ category.value }}
</td>
</tr>
{% if category.children is defined and category.children is not empty %}
{% for child in category.children %}
{{ _self.renderCategory(child, depth + 1) }}
{% endfor %}
{% endif %}
{% endmacro %}
{% if categories is not empty %}
{% for category in categories %}
{{ _self.renderCategory(category, 0) }}
{% endfor %}
{% else %}
<tr>
<td class="border px-4 py-2" colspan="3">
No categories yet.
</td>
</tr>
{% endif %}
</tbody>
</table></section>

View file

@ -13,8 +13,8 @@
name: 'currency',
label: 'Currency',
options: [
{ 'value': 'sats', 'text': 'Sats' },
{ 'value': 'cents', 'text': 'Cents' }
{ 'value': 'sats', 'label': 'Sats' },
{ 'value': 'cents', 'label': 'Cents' }
],
required: true
} %}