From 7b062dd850df16c29aec4496882fc8e751ad5bac Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Sat, 28 Dec 2024 22:21:41 +0100
Subject: [PATCH] workaround prop immutable

---
 07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue b/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue
index d2bf6a1..c10fcf8 100644
--- a/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue
+++ b/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue
@@ -1,8 +1,12 @@
 <template>
     <li>
-        <h2>{{ name }}</h2>
+        <h2>{{ name }} {{ friendIsFavorite === "1" ? '(Favorite)' : '' }}</h2>
         <button @click="toggleDetails">
             {{ detailsAreVisible ? 'Hide' : 'Show' }} Details
+        </button>
+
+        <button @click="toggleFavorite">
+            Toggle favorite
         </button>
         <ul v-if="detailsAreVisible">
             <li><strong>Phone:</strong> {{ phoneNumber }}</li>
@@ -17,6 +21,7 @@
         'name',
         'phoneNumber',
         'emailAddress',
+        'isFavorite'
     ],
     data() {
         return {
@@ -26,13 +31,21 @@
                 name: "Manuel Lorenz",
                 phone: "01234 5678 991",
                 email: "manuel@localhost.com",
-            }
+            },
+            friendIsFavorite: this.isFavorite,
         }
     },
     methods: {
         toggleDetails() {
             this.detailsAreVisible = !this.detailsAreVisible;
         },
+        toggleFavorite() {
+            if (this.friendIsFavorite === '1') {
+                this.friendIsFavorite = '0';
+            } else {
+                this.friendIsFavorite = '1';
+            }
+        },
     },
 };
 </script>
\ No newline at end of file

--
Gitblit v1.8.0