Skip to content

Commit

Permalink
Merge pull request #173 from ddjnw1yu/invalid-route-query-type
Browse files Browse the repository at this point in the history
Fix issue when invalid route query used in map page
  • Loading branch information
alan-wu authored Aug 6, 2024
2 parents 3df7bcc + ae5b8f1 commit ce6b4d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/apps/maps/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const restoreStateWithUUID = async (route, $axios, sparcApi) => {
return [uuid, state, successMessage, failMessage]
}
const openViewWithQuery = async (route, $axios, sparcApi, algoliaIndex, discover_api, $pennsieveApiClient) => {
const openViewWithQuery = async (router, route, $axios, sparcApi, algoliaIndex, discover_api, $pennsieveApiClient) => {
//Open the map with specific view defined by the query.
//First get the bucket and facets information if available
let s3Bucket = undefined
Expand Down Expand Up @@ -300,6 +300,9 @@ const openViewWithQuery = async (route, $axios, sparcApi, algoliaIndex, discover
return await processEntry(route)
} else if (route.query.type === 'wholebody') {
startingMap = "WholeBody"
} else {
router.replace({ ...router.currentRoute, query: { type: 'ac' } })
failMessage = 'Invalid parameters were detected. Default parameters will now be used.'
}
return [startingMap, organ_name, currentEntry, successMessage, failMessage, facets]
Expand All @@ -310,6 +313,7 @@ export default {
async setup() {
const config = useRuntimeConfig()
const { $algoliaClient, $axios, $pennsieveApiClient } = useNuxtApp()
const router = useRouter()
const route = useRoute()
let startingMap = "AC"
let organ_name = undefined
Expand Down Expand Up @@ -347,7 +351,7 @@ export default {
successMessage,
failMessage,
facets
] = await openViewWithQuery(route, $axios, options.sparcApi, algoliaIndex,
] = await openViewWithQuery(router, route, $axios, options.sparcApi, algoliaIndex,
config.public.discover_api_host, $pennsieveApiClient)
}
Expand Down

0 comments on commit ce6b4d1

Please sign in to comment.