Feat: Create Customer Post API
This commit is contained in:
		@@ -10,13 +10,18 @@
 | 
				
			|||||||
            v-model="customer.name"
 | 
					            v-model="customer.name"
 | 
				
			||||||
            label="Nombre"
 | 
					            label="Nombre"
 | 
				
			||||||
            :rules="[rules.required]"
 | 
					            :rules="[rules.required]"
 | 
				
			||||||
            required
 | 
					 | 
				
			||||||
          ></v-text-field>
 | 
					          ></v-text-field>
 | 
				
			||||||
          <v-text-field
 | 
					          <v-text-field
 | 
				
			||||||
            v-model="customer.email"
 | 
					              v-model="customer.address"
 | 
				
			||||||
            label="Correo Electrónico"
 | 
					              label="Direccion"
 | 
				
			||||||
            :rules="[rules.required, rules.email]"
 | 
					              :rules="[rules.required]"
 | 
				
			||||||
            required
 | 
					              required
 | 
				
			||||||
 | 
					          ></v-text-field>
 | 
				
			||||||
 | 
					          <v-text-field
 | 
				
			||||||
 | 
					              v-model="customer.email"
 | 
				
			||||||
 | 
					              label="Correo Electrónico"
 | 
				
			||||||
 | 
					              :rules="[rules.required, rules.email]"
 | 
				
			||||||
 | 
					              required
 | 
				
			||||||
          ></v-text-field>
 | 
					          ></v-text-field>
 | 
				
			||||||
          <v-text-field
 | 
					          <v-text-field
 | 
				
			||||||
            v-model="customer.phone"
 | 
					            v-model="customer.phone"
 | 
				
			||||||
@@ -63,11 +68,27 @@
 | 
				
			|||||||
             this.showModal = false;
 | 
					             this.showModal = false;
 | 
				
			||||||
             this.resetForm();
 | 
					             this.resetForm();
 | 
				
			||||||
         },
 | 
					         },
 | 
				
			||||||
         submitForm() {
 | 
					         async submitForm() {
 | 
				
			||||||
             if (this.$refs.form.validate()) {
 | 
					             if (this.$refs.form.validate()) {
 | 
				
			||||||
                 // Aquí puedes manejar el envío del formulario
 | 
					                 try {
 | 
				
			||||||
                 console.log('Cliente guardado:', this.customer);
 | 
					                     console.log(this.customer)
 | 
				
			||||||
                 this.closeModal();
 | 
					                     const response = await fetch('/don_confiao/api/customers/', {
 | 
				
			||||||
 | 
					                         method: 'POST',
 | 
				
			||||||
 | 
					                         headers: {
 | 
				
			||||||
 | 
					                             'Content-Type': 'application/json',
 | 
				
			||||||
 | 
					                         },
 | 
				
			||||||
 | 
					                         body: JSON.stringify(this.customer),
 | 
				
			||||||
 | 
					                     });
 | 
				
			||||||
 | 
					                     if (response.ok) {
 | 
				
			||||||
 | 
					                         const data = await response.json();
 | 
				
			||||||
 | 
					                         console.log('Cliente Guardado:', data);
 | 
				
			||||||
 | 
					                         this.closeModal();
 | 
				
			||||||
 | 
					                     } else {
 | 
				
			||||||
 | 
					                         console.error('Error al Crear el Cliente:', response.statusText);
 | 
				
			||||||
 | 
					                     }
 | 
				
			||||||
 | 
					                 } catch (error) {
 | 
				
			||||||
 | 
					                     console.error('Error de red:', error);
 | 
				
			||||||
 | 
					                 }
 | 
				
			||||||
             }
 | 
					             }
 | 
				
			||||||
         },
 | 
					         },
 | 
				
			||||||
         resetForm() {
 | 
					         resetForm() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user