Skip to content
Snippets Groups Projects
Commit 101db904 authored by Ina Martini's avatar Ina Martini
Browse files

feat: when first logged in a new speech array should be displayed

parent 47768834
No related branches found
No related tags found
3 merge requests!66Final merge,!42Refactor interactiveSpare to modal,!4Pipeline fix
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref, toRefs } from 'vue' import { onMounted, ref } from 'vue'
import InteractiveSpare from '@/components/InteractiveSpare.vue' import InteractiveSpare from '@/components/InteractiveSpare.vue'
import ButtonAddGoalOrChallenge from '@/components/ButtonAddGoalOrChallenge.vue' import ButtonAddGoalOrChallenge from '@/components/ButtonAddGoalOrChallenge.vue'
import type { Challenge } from '@/types/challenge' import type { Challenge } from '@/types/challenge'
...@@ -50,6 +50,7 @@ import type { Goal } from '@/types/goal' ...@@ -50,6 +50,7 @@ import type { Goal } from '@/types/goal'
import { useGoalStore } from '@/stores/goalStore' import { useGoalStore } from '@/stores/goalStore'
import { useChallengeStore } from '@/stores/challengeStore' import { useChallengeStore } from '@/stores/challengeStore'
import SavingsPath from '@/components/SavingsPath.vue' import SavingsPath from '@/components/SavingsPath.vue'
import router from "@/router";
const goalStore = useGoalStore() const goalStore = useGoalStore()
const challengeStore = useChallengeStore() const challengeStore = useChallengeStore()
...@@ -63,34 +64,40 @@ const goals = ref<Goal[]>([]) ...@@ -63,34 +64,40 @@ const goals = ref<Goal[]>([])
const goal = ref<Goal | null | undefined>(null) const goal = ref<Goal | null | undefined>(null)
onMounted(async () => { onMounted(async () => {
await goalStore.getUserGoals() await goalStore.getUserGoals()
await challengeStore.getUserChallenges() await challengeStore.getUserChallenges()
challenges.value = challengeStore.challenges challenges.value = challengeStore.challenges
goals.value = goalStore.goals goals.value = goalStore.goals
goal.value = goals.value[0] goal.value = goals.value[0]
firstLoggedInSpeech()
}) })
const updateSpeech = (newSpeech: string[]) => { const updateSpeech = (newSpeech: string[]) => {
speech.value = newSpeech; speech.value = newSpeech;
console.log('New speech available:', speech.value)
newSpeechAvailable.value = true; newSpeechAvailable.value = true;
} }
updateSpeech([ // Check if the user is logging in for the first time, and display the first login speech
'Hei, jeg er Spare!', const firstLoggedInSpeech = () => {
'Jeg skal hjelpe deg med å spare penger.', const isFirstLogin = router.currentRoute.value.query.firstLogin === 'true';
'Du får varsel når jeg har noe å si!' if (isFirstLogin) {
]) updateSpeech([
'Hei, jeg er Spare!',
'Jeg skal hjelpe deg med å spare penger.',
'Du får varsel når jeg har noe å si!'
]);
// reset the query parameter
router.replace({name: 'home', query: {firstLogin: 'false'}});
openInteractiveSpare()
}
}
const openInteractiveSpare = () => { const openInteractiveSpare = () => {
console.log('Opening interactive spare available', newSpeechAvailable.value)
// Check if there's new speech available before opening the modal. // Check if there's new speech available before opening the modal.
if (newSpeechAvailable.value) { if (newSpeechAvailable.value) {
isModalOpen.value = true // Open the modal isModalOpen.value = true // Open the modal
newSpeechAvailable.value = false // Reset the flag since the speech will now be displayed newSpeechAvailable.value = false // Reset the flag since the speech will now be displayed
console.log('Opening interactive spare')
} else {
console.log('No new speech available')
} }
} }
const openHelp = () => { const openHelp = () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment