update user location in local store on save to update button on overview

This commit is contained in:
einhornimmond 2025-04-14 17:54:27 +02:00
parent a3f984b613
commit aa9e8468d5

View File

@ -33,8 +33,10 @@ import UserLocationMap from '@/components/UserSettings/UserLocationMap'
import { BButton, BModal } from 'bootstrap-vue-next'
import { userLocationQuery } from '@/graphql/queries'
import CONFIG from '@/config'
import { useStore } from 'vuex'
const { t } = useI18n()
const store = useStore()
const { mutate: updateUserInfo } = useMutation(updateUserInfos)
const { onResult, onError } = useQuery(userLocationQuery, {}, { fetchPolicy: 'network-only' })
const { toastSuccess, toastError } = useAppToast()
@ -73,14 +75,11 @@ const saveUserLocation = async () => {
try {
const loc = { longitude: capturedLocation.value.lng, latitude: capturedLocation.value.lat }
await updateUserInfo({
gmsLocation: {
longitude: capturedLocation.value.lng,
latitude: capturedLocation.value.lat,
},
})
await updateUserInfo({ gmsLocation: loc })
toastSuccess(t('settings.GMS.location.updateSuccess'))
userLocation.value = capturedLocation.value
// update in local storage to update button on overview
store.commit('userLocation', loc)
isModalOpen.value = false
} catch (error) {
toastError(error.message)