Versión 1.3.0: Conexion completa del proyecto
This commit is contained in:
@@ -43,11 +43,15 @@
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
if (editingTenant) {
|
||||
await api.put(`/tenants/${editingTenant.id}`, formData);
|
||||
toast.success('Cliente actualizado');
|
||||
// Asegurarse de enviar el campo "status" correctamente
|
||||
const updatedData = { ...formData, status: formData.is_active ? 'active' : 'inactive' };
|
||||
await api.put(`/tenants/${editingTenant.id}`, updatedData);
|
||||
toast.success(`Cliente ${formData.is_active ? 'activado' : 'desactivado'} correctamente`);
|
||||
} else {
|
||||
await api.post('/tenants/', formData);
|
||||
toast.success('Cliente creado');
|
||||
// Asegurarse de enviar el campo "status" al crear un cliente
|
||||
const newData = { ...formData, status: formData.is_active ? 'active' : 'inactive' };
|
||||
await api.post('/tenants/', newData);
|
||||
toast.success('Cliente creado correctamente');
|
||||
}
|
||||
showModal = false;
|
||||
loadTenants();
|
||||
@@ -152,6 +156,11 @@
|
||||
<button type="button" on:click={() => showModal = false} class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:col-start-1 sm:text-sm">
|
||||
Cancelar
|
||||
</button>
|
||||
{#if editingTenant}
|
||||
<button type="button" on:click={async () => { await api.delete(`/tenants/${editingTenant.id}`); toast.success('Cliente eliminado'); showModal = false; loadTenants(); }} class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:col-start-1 sm:text-sm">
|
||||
Eliminar
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user