From 8d5c15d3c82120040c6a9f30241b2bf53d8cd95a Mon Sep 17 00:00:00 2001 From: Ina <inamar@stud.ntnu.no> Date: Tue, 30 Apr 2024 13:32:49 +0200 Subject: [PATCH] fix: update InteractiveSpare modal --- src/views/EditProfileView.vue | 6 ++++++ src/views/HomeView.vue | 3 +-- src/views/ProfileView.vue | 22 +++++++++++++++++++++- src/views/ViewChallengeView.vue | 9 ++++++++- src/views/ViewGoalView.vue | 21 ++++++++++++++++++++- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/views/EditProfileView.vue b/src/views/EditProfileView.vue index 82da354..1434fd1 100644 --- a/src/views/EditProfileView.vue +++ b/src/views/EditProfileView.vue @@ -27,6 +27,7 @@ const profile = ref<Profile>({ const updatePassword = ref<boolean>(false) const confirmPassword = ref<string>('') const errorMessage = ref<string>('') +const isModalOpen = ref(false) const nameRegex = /^[æÆøØåÅa-zA-Z,.'-][æÆøØåÅa-zA-Z ,.'-]{1,29}$/ const emailRegex = @@ -51,6 +52,10 @@ const isSavingAccountValid = computed(() => accountNumberRegex.test(profile.value.savingAccount.accNumber?.toString() || '') ) +const openInteractiveSpare = () => { + isModalOpen.value = true // Open the modalReset the flag since the speech will now be displayed +} + const isFormInvalid = computed( () => [ @@ -210,6 +215,7 @@ const saveChanges = async () => { :png-size="10" :speech="['Her kan du endre på profilen din!']" direction="left" + :isModalOpen="openInteractiveSpare" /> <CardTemplate> diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 0b466f6..fcdf62e 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -30,9 +30,8 @@ :speech="speech" :direction="'right'" :pngSize="15" - :is-modal-open="isModalOpen" + :isModalOpen="isModalOpen" class="opacity-0 h-0 w-0 md:opacity-100 md:h-auto md:w-auto" - v-if="isModalOpen" ></InteractiveSpare> <div class="fixed bottom-5 left-5"> <div @click="openHelp" class="hover:cursor-pointer"> diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index 436e522..6f7492c 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -12,6 +12,7 @@ import router from '@/router' const profile = ref<Profile>() const completedGoals = ref<Goal[]>([]) const completedChallenges = ref<Challenge[]>([]) +const isModalOpen = ref(false) onMounted(async () => { await authInterceptor('/profile') @@ -43,6 +44,11 @@ onMounted(async () => { const welcome = computed(() => { return [`Velkommen, ${profile.value?.firstName} ${profile.value?.lastName} !`] }) + +const openInteractiveSpare = () => { + isModalOpen.value = true +} + </script> <template> @@ -87,7 +93,21 @@ const welcome = computed(() => { </div> <div class="flex flex-col"> - <InteractiveSpare :png-size="10" :speech="welcome" direction="left" /> + <InteractiveSpare + :png-size="10" + :speech="welcome" + direction="left" + :isModalOpen="isModalOpen" + /> + <div class="flex items-center"> + <a @click="openInteractiveSpare" class="hover:bg-transparent z-20"> + <img + alt="Spare" + class="scale-x-[-1] md:h-5/6 md:w-5/6 w-2/3 h-2/3 cursor-pointer ml-14 md:ml-10" + src="@/assets/spare.png" + /> + </a> + </div> <div class="flex flex-row justify-between mx-4"> <p class="font-bold">Fullførte sparemål</p> <a class="hover:p-0 cursor-pointer" v-text="'Se alle'" /> diff --git a/src/views/ViewChallengeView.vue b/src/views/ViewChallengeView.vue index f7bf05e..71b2a67 100644 --- a/src/views/ViewChallengeView.vue +++ b/src/views/ViewChallengeView.vue @@ -29,6 +29,8 @@ const isCompleted = computed(() => challengeInstance.value.completedOn != null) const motivation = ref<string[]>([]) +const isModalOpen = ref(false) + const calculateSpeech = () => { if (completion.value === 0) { return motivation.value.push( @@ -140,7 +142,12 @@ const completeChallenge = () => { </button> </div> </div> - <InteractiveSpare :png-size="10" :speech="motivation" direction="left" /> + <InteractiveSpare + :png-size="10" + :speech="motivation" + direction="left" + :isModalOpen="isModalOpen" + /> </div> </template> diff --git a/src/views/ViewGoalView.vue b/src/views/ViewGoalView.vue index a2e9b17..e73e1c7 100644 --- a/src/views/ViewGoalView.vue +++ b/src/views/ViewGoalView.vue @@ -20,6 +20,11 @@ const completion = computed(() => (goalInstance.value.saved / goalInstance.value const isCompleted = computed(() => goalInstance.value.completedOn != null) const motivation = ref<string[]>([]) +const isModalOpen = ref(false) + +const openInteractiveSpare = () => { + isModalOpen.value = true +} const calculateSpeech = () => { if (completion.value === 0) { @@ -126,7 +131,21 @@ const completeGoal = () => { </button> </div> </div> - <InteractiveSpare :png-size="10" :speech="motivation" direction="left" /> + <div class="flex items-center"> + <a @click="openInteractiveSpare" class="hover:bg-transparent z-20"> + <img + alt="Spare" + class="scale-x-[-1] md:h-5/6 md:w-5/6 w-2/3 h-2/3 cursor-pointer ml-14 md:ml-10" + src="@/assets/spare.png" + /> + </a> + </div> + <InteractiveSpare + :png-size="10" + :speech="motivation" + direction="left" + :isModalOpen="isModalOpen" + /> </div> </template> -- GitLab