Feat: Actualizar listado de Clientes al crear uno nuevo

This commit is contained in:
sinergia 2024-11-02 10:28:15 -05:00
parent 95fab71898
commit 2ea8cc7fd8
2 changed files with 6 additions and 2 deletions

View File

@ -82,6 +82,7 @@
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
console.log('Cliente Guardado:', data); console.log('Cliente Guardado:', data);
this.$emit('customerCreated');
this.closeModal(); this.closeModal();
} else { } else {
console.error('Error al Crear el Cliente:', response.statusText); console.error('Error al Crear el Cliente:', response.statusText);
@ -98,7 +99,7 @@
phone: '' phone: ''
}; };
this.$refs.form.reset(); this.$refs.form.reset();
} },
} }
}; };
</script> </script>

View File

@ -16,7 +16,7 @@
class="mr-4" class="mr-4"
></v-autocomplete> ></v-autocomplete>
<v-btn color="primary" @click="openModal">Agregar Cliente</v-btn> <v-btn color="primary" @click="openModal">Agregar Cliente</v-btn>
<CreateCustomerModal ref="customerModal" /> <CreateCustomerModal ref="customerModal" @customerCreated="fetchClients"/>
</v-col> </v-col>
<v-col <v-col
lg="2" lg="2"
@ -256,6 +256,9 @@
return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'COP' }).format(price); return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'COP' }).format(price);
}, },
}, },
mounted() {
this.fetchClients(); // Llama a fetchClients al montar el componente
}
}; };
</script> </script>
<style> <style>