feat: button on/off products

This commit is contained in:
2024-12-29 20:02:51 -03:00
parent ac87c3a47d
commit 9cc0c72f10
17 changed files with 71 additions and 42 deletions

View File

@@ -19,16 +19,49 @@ Produtos
<body>
<div class="grid-container">
<div class="pico"><input class="pico" type="text"></div>
<button class="pico" id="openModal">Adicionar Novo Produto</button>
<div ><input type="text"></div>
<button id="openModal">Adicionar Novo Produto</button>
<table id="list-products">
<tr>
<th style="text-align: left;">Produto</th>
<th style="text-align: left;">Preço</th>
<th style="text-align: left;">Quantidade</th>
<th style="text-align: left;">Categoria</th>
<th style="text-align: left;">Ações</th>
</tr>
{% for product in products %}
<tr>
<td>{{product.name}}</td>
<td>R$ {{product.price}}</td>
<td>{{product.quantity}}</td>
<td>{{product.category.name}}</td>
<td>
<div class="grid-buttons">
<button>📝 Editar</button>
<form action="{% url 'onOffproduct' %}" method="post">
{% csrf_token %}
<input type="hidden" name="id-product" value="{{ product.id }}">
{% if product.active == True %}
<button style="background-color: red;">🚫 Desativar</button>
{% else %}
<button style="background-color: green;" >✅ Ativar</button>
{% endif %}
</form>
</div>
</td>
</tr>
<div class="card">
{{product.name}}
</div>
{% endfor %}
</table>
</div>
@@ -36,8 +69,11 @@ Produtos
<div class="modal" id="Modal-create-product">
<div class="modal-content">
<dialog id='Modal-create-product' >
<article>
<form action="{% url 'create_product' %}" id="productForm" method="post" >
{% csrf_token %}
<h2>Cadastro de Produto</h2>
@@ -55,8 +91,11 @@ Produtos
<button type="submit">Salvar</button>
<button type="button" onclick="closeModal()" style="background-color:red;">Fechar</button>
</form>
</div>
</div>
</article>
</dialog>
<script src="{% static 'products/js/products.js' %}"></script>