This commit is contained in:
count-null 2025-03-08 21:26:58 -05:00
parent 642546040a
commit 4eb1d59230
25 changed files with 816 additions and 152 deletions

View file

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

View file

@ -0,0 +1,9 @@
{% include 'lib/alert.twig' %}
<form action="/admin/products/edit/{{ product.id }}" method="post" class="flex flex-col gap-2">
{% include 'lib/forms/product.twig' with {
product: session.last_post ?? product
} %}
{% include 'lib/buttons/submit.twig' with {
label: 'Save Product'
} %}
</form>

View file

@ -2,61 +2,75 @@
{% include 'lib/alert.twig' %}
<h3 class="text-2xl font-semibold">
Categories
Products
</h3>
<a href="/admin/categories/add">
<a href="/admin/products/add">
{% include 'lib/buttons/primary.twig' with {
label: 'Create a Category'
} %}
label: 'Create a Product'
} %}
</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) %}
<thead>
<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>
<th class="py-2">
Product ID
</th>
<th class="py-2">
Title
</th>
<th class="py-2">
Description
</th>
<th class="py-2">
Stock Quantity
</th>
<th class="py-2">
Price (Sats)
</th>
<th class="py-2">
Price (Cents)
</th>
<th class="py-2">
Action
</th>
</tr>
{% if category.children is defined and category.children is not empty %}
{% for child in category.children %}
{{ _self.renderCategory(child, depth + 1) }}
</thead>
<tbody>
{% if products %}
{% for product in products %}
<tr>
<td class="border px-4 py-2">
{{ product.id }}
</td>
<td class="border px-4 py-2">
{{ product.title }}
</td>
<td class="border px-4 py-2">
{{ product.description }}
</td>
<td class="border px-4 py-2">
{{ product.stock_qty }}
</td>
<td class="border px-4 py-2">
{{ product.price_sats }}
</td>
<td class="border px-4 py-2">
{{ product.price_cents }}
</td>
<td class="border px-4 py-2">
<a href="/admin/products/edit/{{ product.id }}">
Edit
</a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td class="border px-4 py-2" colspan="7">
No products found.
</td>
</tr>
{% 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>
</tbody>
</table>
</section>