Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refacto le bouton de retour & ajout de documentation #4673

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/components/buttons/back-button.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<!-- Documentation: https://github.com/betagouv/aides-jeunes/wiki/Composant-back%E2%80%90button.vue -->
<template>
<button
<component
:is="asLink ? 'router-link' : 'button'"
class="fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-arrow-left-line"
:class="size && size === 'small' ? 'fr-btn--sm' : ''"
type="button"
@click.prevent="goBack"
:class="{ 'fr-btn--sm': size === 'small' }"
:type="asLink ? undefined : 'button'"
:to="asLink ? to : undefined"
@click="asLink ? undefined : goBack()"
>
<slot>Précédent</slot>
</button>
</component>
</template>

<script setup lang="ts">
Expand All @@ -25,6 +28,14 @@ const props = defineProps({
type: String,
default: null,
},
asLink: {
type: Boolean,
default: false,
},
to: {
type: String,
default: "/",
},
})
const route = useRoute()
const router = useRouter()
Expand Down
15 changes: 6 additions & 9 deletions src/views/aide.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<template>
<article>
<h1 class="fr-mt-7w fr-mx-2w">Détail de l'aide</h1>
<p>
<router-link
to="/aides"
class="fr-btn fr-btn--tertiary-no-outline fr-btn--sm fr-btn--icon-left fr-icon-arrow-left-line"
>Retour à la liste des aides</router-link
>
</p>
<article class="fr-article">
<h1>Détail de l'aide</h1>
<BackButton to="/aides" size="small" as-link class="fr-mb-2w">
Retour à la liste des aides
</BackButton>
<DroitsDetails
:droit="benefit"
:droits="[benefit]"
Expand All @@ -24,6 +20,7 @@ import { useRoute } from "vue-router"
import { getBenefit } from "@/lib/benefits.js"
import DroitsDetails from "@/components/droits-details.vue"
import DroitsContributions from "@/components/droits-contributions.vue"
import BackButton from "@/components/buttons/back-button.vue"

const route = useRoute()
const benefitId = route.params.benefitId as string
Expand Down
10 changes: 10 additions & 0 deletions src/views/liste-aides.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<template>
<article class="fr-article">
<h1>Toutes les aides</h1>
<BackButton
size="small"
data-testid="benefits-liste-back-button"
class="fr-mb-2w"
as-link
to="/"
>
Retour à l'accueil
</BackButton>
<p>Total: {{ benefitsCount }} aides</p>
<div class="fr-form-group">
<div class="fr-container fr-px-0">
Expand Down Expand Up @@ -83,6 +92,7 @@ import institutionsBenefits from "generator:institutions"
import CommuneMethods from "@/lib/commune.js"
import { Commune } from "@lib/types/commune.d.js"
import { capitalize } from "@lib/utils.js"
import BackButton from "@/components/buttons/back-button.vue"

const zipCode = ref("")
const selectedCommune = ref<Commune | null>()
Expand Down
Loading