Skip to content

Commit e03cdcb

Browse files
committed
refactor: remove result-hash and previous-route properties and use route back() function instead
Refactored various components to eliminate the need for `result-hash` and `previous-route` properties. This simplification included updating navigation logic to use `router.back()` and streamlining the breadcrumb and button components.
1 parent 8401a05 commit e03cdcb

File tree

5 files changed

+11
-44
lines changed

5 files changed

+11
-44
lines changed

apps/web/src/components/element/TeeDsfrBreadcrumb.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { RouteName } from '@/types/routeType'
1111
import { type RouteLocationAsRelativeGeneric } from 'vue-router'
1212
interface Props {
1313
links?: DsfrBreadcrumbProps['links']
14-
resultHash?: string
1514
}
1615
const props = defineProps<Props>()
1716
const navigationStore = useNavigationStore()
@@ -41,7 +40,6 @@ const getBaseRouteName = () => {
4140
4241
const routeToBaseList: RouteLocationAsRelativeGeneric = {
4342
name: getBaseRouteName(),
44-
hash: props.resultHash,
4543
query: isCatalogDetail ? undefined : navigationStore.query
4644
}
4745

apps/web/src/components/program/detail/ProgramHeader.vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<template>
2-
<TeeDsfrBreadcrumb
3-
:links="links"
4-
:result-hash="`#${programId}`"
5-
/>
2+
<TeeDsfrBreadcrumb :links="links" />
63
<TeeEligibilityCriteriaBar
74
v-if="!isCatalogDetail"
85
:bg-color="Color.greenLightnessed"
96
:bg-bar-color="Color.greenLighted"
10-
:previous-route="getRouteToPreviousPage()"
117
message="Cette aide correspond à vos critères d’éligibilité"
128
message-icon="fr-icon-checkbox-circle-fill"
139
/>
@@ -80,16 +76,8 @@ const links = computed<DsfrBreadcrumbProps['links']>(() => {
8076
return [...links, { text: props.program?.titre || '' }]
8177
})
8278
83-
const getRouteToPreviousPage = () => {
84-
if (navigationStore.isByRouteName(RouteName.ProgramFromProjectDetail)) {
85-
return routeToProject
86-
}
87-
88-
return routeToResults
89-
}
90-
91-
const goToPrograms = async () => {
92-
await router.push(getRouteToPreviousPage())
79+
const goToPrograms = () => {
80+
router.back()
9381
}
9482
onBeforeMount(() => {
9583
project.value = projectStore.currentProject

apps/web/src/components/program/eligibilityCriteria/TeeEligibilityCriteriaBar.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
<div class="fr-container fr-grid-row fr-grid-row--center fr-grid-row--middle fr-py-md-1w">
88
<div class="fr-col-md-2 fr-col-lg-2 fr-col-xl-2 fr-col-hidden fr-col-unhidden-md">
99
<div class="fr-col-12">
10-
<TeeButtonLink
11-
:to="previousRoute"
10+
<TeeDsfrButton
11+
:label="`Retour`"
1212
icon="fr-icon-arrow-left-line"
13+
class="fr-btn fr-btn--tertiary-no-outline fr-btn-bg"
1314
size="lg"
15+
@click="router.back()"
1416
>
15-
Retour
16-
</TeeButtonLink>
17+
</TeeDsfrButton>
1718
</div>
1819
</div>
1920
<div class="fr-px-md-2v fr-my-auto fr-col-hidden fr-col-unhidden-md fr-col-md-10 fr-col-lg-10 fr-col-xl-10 fr-px-0 fr-text-left">
@@ -44,12 +45,10 @@ import { useNavigationStore } from '@/stores/navigation'
4445
import { Color, RouteName } from '@/types'
4546
import StickyWithOffset from '@/utils/stickyWithOffset'
4647
import TrackStructure from '@/utils/track/trackStructure'
47-
import type { RouteLocationRaw } from 'vue-router'
4848
4949
interface Props {
5050
bgColor?: Color
5151
bgBarColor?: Color
52-
previousRoute: RouteLocationRaw
5352
message?: string
5453
messageIcon?: string
5554
}
@@ -58,6 +57,7 @@ const props = defineProps<Props>()
5857
const eligibilityCriteria = ref<HTMLElement>()
5958
const stickyWithOffset = ref<StickyWithOffset | null>(null)
6059
const criteria = TrackStructure.getEligibilityCriteria()
60+
const router = useRouter()
6161
6262
function isProgramDetailPage() {
6363
return useNavigationStore().isByRouteName([RouteName.CatalogProgramDetail, RouteName.QuestionnaireResultDetail])

apps/web/src/components/project/details/ProjectHeader.vue

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
<template>
2-
<TeeDsfrBreadcrumb
3-
:links="links"
4-
:result-hash="`#${project.slug}`"
5-
/>
2+
<TeeDsfrBreadcrumb :links="links" />
63
<TeeEligibilityCriteriaBar
74
:bg-color="Color.blueLightnessed"
85
:bg-bar-color="Color.blueLighted"
9-
:previous-route="routeToProjects"
106
/>
117
<div class="fr-mb-4v background-project-title">
128
<img
@@ -29,22 +25,14 @@
2925
</template>
3026
<script setup lang="ts">
3127
import { Color, Project } from '@/types'
32-
import { RouteName } from '@/types/routeType'
33-
import { useNavigationStore } from '@/stores/navigation'
3428
import type { DsfrBreadcrumbProps } from '@gouvminint/vue-dsfr'
3529
3630
interface Props {
3731
project: Project
3832
themeColor?: Color
3933
}
4034
const props = defineProps<Props>()
41-
const navigationStore = useNavigationStore()
4235
43-
const routeToProjects = {
44-
name: RouteName.QuestionnaireResult,
45-
hash: '#' + props.project.slug,
46-
query: navigationStore.query
47-
}
4836
const links = ref<DsfrBreadcrumbProps['links']>([{ text: props.project.title }])
4937
</script>
5038

apps/web/src/router/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ export const router = createRouter({
88
history: createWebHistory(process.env.BASE_URL),
99
scrollBehavior(to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded, savedPosition) {
1010
if (savedPosition) {
11-
return savedPosition
12-
}
13-
if (to.hash) {
14-
return new Promise((resolve) => {
15-
setTimeout(() => {
16-
resolve({ el: to.hash, behavior: 'instant' })
17-
}, 0)
18-
})
11+
return Promise.resolve(savedPosition)
1912
}
2013
return { top: 0 }
2114
},

0 commit comments

Comments
 (0)