From ff5308ea297afc7cfe89049f58842a2a3a9c94cf Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Mon, 30 Dec 2024 20:14:37 +0100
Subject: [PATCH] esercizio step 3

---
 07 - development setup/cmp-communication-assignment-problem/src/components/UserData.vue   |   27 +++++++++++++++++++++++++--
 07 - development setup/cmp-communication-assignment-problem/src/components/ActiveUser.vue |    4 ++--
 07 - development setup/cmp-communication-assignment-problem/src/App.vue                   |    8 +++++++-
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/07 - development setup/cmp-communication-assignment-problem/src/App.vue b/07 - development setup/cmp-communication-assignment-problem/src/App.vue
index 4bf0fd4..1960c3a 100644
--- a/07 - development setup/cmp-communication-assignment-problem/src/App.vue
+++ b/07 - development setup/cmp-communication-assignment-problem/src/App.vue
@@ -5,7 +5,7 @@
             Esercizio
         </header>
         <active-user :username="user.username" :age="user.age"></active-user>
-        <user-data></user-data>
+        <user-data @update-user="updateUser"></user-data>
     </section>
 </template>
 
@@ -18,6 +18,12 @@
                 age: "38",
             }
         }
+    },
+    methods:{
+        updateUser(user, age){
+            this.user.username = user;
+            this.user.age = age;
+        }
     }
 }
 </script>
diff --git a/07 - development setup/cmp-communication-assignment-problem/src/components/ActiveUser.vue b/07 - development setup/cmp-communication-assignment-problem/src/components/ActiveUser.vue
index 7872458..2ae9038 100644
--- a/07 - development setup/cmp-communication-assignment-problem/src/components/ActiveUser.vue
+++ b/07 - development setup/cmp-communication-assignment-problem/src/components/ActiveUser.vue
@@ -10,11 +10,11 @@
     props: {
         username: {
             title: String,
-            required: true
+            required: true,
         },
         age: {
             title: String,
-            required: true
+            required: true,
         },
     }
 }
diff --git a/07 - development setup/cmp-communication-assignment-problem/src/components/UserData.vue b/07 - development setup/cmp-communication-assignment-problem/src/components/UserData.vue
index 7f9d319..8d16db1 100644
--- a/07 - development setup/cmp-communication-assignment-problem/src/components/UserData.vue
+++ b/07 - development setup/cmp-communication-assignment-problem/src/components/UserData.vue
@@ -1,16 +1,39 @@
 <template>
+    <form @submit.prevent="submitData">
     <div>
         <label>Utente: </label>
-        <input type="text">
+        <input type="text" v-model="username">
     </div>
     <div>
         <label>Eta: </label>
-        <input type="text">
+        <input type="text" v-model="age">
     </div>
+    <div>
+        <button>Update</button>
+    </div>
+</form>
 </template>
 
 <script>
 export default {
+    data(){
+        return {
+            username: "",
+            age: "",
+        }
+    },
+    emits: ['update-user'],
+    methods:{
+        submitData() {
 
+            if(this.username !== "" && this.age !== ""){
+
+            this.$emit('update-user', this.username, this.age);
+            } else {
+                alert("insert data")
+            } 
+
+        }
+    }
 }
 </script>
\ No newline at end of file

--
Gitblit v1.8.0