-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d23b78
commit 344e129
Showing
21 changed files
with
453 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/components/custom/Thematiques/CarteSyntheseThematique.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<section class="fr-col-12 fr-col-md-6 fr-col-lg-3"> | ||
<div class="shadow text--left fr-p-2w full-height flex flex-column flex-space-between background--white"> | ||
<div class="fr-mb-3v flex flex-column align-items--center flex-space-between full-height"> | ||
<div class="fr-mb-2w full-width"> | ||
<h3 class="fr-h4 fr-pb-2w fr-mb-2w fr-text--md" v-html="syntheseThematique.titreHTML" /> | ||
<ul> | ||
<li | ||
v-for="point in syntheseThematique.bulletPoints" | ||
:key="point" | ||
v-html="point" | ||
class="fr-mb-1v fr-mx-1v" | ||
/> | ||
</ul> | ||
</div> | ||
|
||
<router-link | ||
class="fr-btn" | ||
:to="{ name: RouteThematiquesName.THEMATIQUE_V2, params: { id: syntheseThematique.id } }" | ||
> | ||
Découvrir | ||
</router-link> | ||
</div> | ||
</div> | ||
</section> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { SyntheseThematiqueViewModel } from '@/domaines/thematiques/ports/syntheseThematique.presenter'; | ||
import { RouteThematiquesName } from '@/router/thematiques/routes'; | ||
defineProps<{ | ||
syntheseThematique: SyntheseThematiqueViewModel; | ||
}>(); | ||
</script> | ||
|
||
<style scoped> | ||
h3 { | ||
border-bottom: 1px solid #eaeaea; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div class="fr-pt-4w fr-pb-8w fr-pb-1w background-bleu-975-25"> | ||
<div class="fr-container"> | ||
<div class="text--center"> | ||
<h2 class="fr-h2 fr-mb-2w">Par où souhaitez-vous commencer ?</h2> | ||
<p v-if="syntheseThematiquesViewModel?.commune"> | ||
D’après nos calculs, à | ||
<span class="text--bold text--bleu text--italic">{{ syntheseThematiquesViewModel.commune }}</span | ||
>, voici ce que nous pouvons vous proposer : | ||
</p> | ||
</div> | ||
|
||
<div v-if="syntheseThematiquesViewModel" class="fr-grid-row fr-grid-row--gutters"> | ||
<CarteSyntheseThematique | ||
v-for="syntheseThematique in syntheseThematiquesViewModel.cartesThematiques" | ||
:key="syntheseThematique.id" | ||
:synthese-thematique="syntheseThematique" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { onMounted, ref } from 'vue'; | ||
import CarteSyntheseThematique from '@/components/custom/Thematiques/CarteSyntheseThematique.vue'; | ||
import { SyntheseThematiquesPresenterImpl } from '@/domaines/thematiques/adapters/syntheseThematiques.presenter.impl'; | ||
import { ThematiquesRepositoryAxios } from '@/domaines/thematiques/adapters/thematiques.repository.axios'; | ||
import { SyntheseThematiquesViewModel } from '@/domaines/thematiques/ports/syntheseThematique.presenter'; | ||
import { RecupererSyntheseThematiques } from '@/domaines/thematiques/recupererSyntheseThematiques.usecase'; | ||
import { utilisateurStore } from '@/store/utilisateur'; | ||
const syntheseThematiquesViewModel = ref<SyntheseThematiquesViewModel>(); | ||
const usecase = new RecupererSyntheseThematiques(new ThematiquesRepositoryAxios()); | ||
onMounted(async () => { | ||
await usecase.execute( | ||
utilisateurStore().utilisateur.id, | ||
new SyntheseThematiquesPresenterImpl(vm => (syntheseThematiquesViewModel.value = vm)), | ||
); | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.background-bleu-975-25 { | ||
background-color: var(--blue-france-975-75); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/domaines/thematiques/adapters/syntheseThematiques.presenter.impl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { ClefThematiqueAPI, MenuThematiques } from '@/domaines/thematiques/MenuThematiques'; | ||
import { | ||
SyntheseThematiquePresenter, | ||
SyntheseThematiquesViewModel, | ||
} from '@/domaines/thematiques/ports/syntheseThematique.presenter'; | ||
import { SyntheseThematiques } from '@/domaines/thematiques/ports/thematiques.repository'; | ||
import { gererPluriel } from '@/shell/pluriel'; | ||
|
||
type Bulletpoint = { nombre: number; phrase: { singulier: string; pluriel: string } }; | ||
|
||
export class SyntheseThematiquesPresenterImpl implements SyntheseThematiquePresenter { | ||
constructor(private readonly _syntheseThematiquesViewModel: (viewModel: SyntheseThematiquesViewModel) => void) {} | ||
|
||
async presente(synthese: SyntheseThematiques): Promise<void> { | ||
this._syntheseThematiquesViewModel({ | ||
commune: synthese.commune, | ||
cartesThematiques: synthese.listeThematiques.map(thematiqueData => { | ||
const thematique = MenuThematiques.getThematiqueData(thematiqueData.thematique as ClefThematiqueAPI); | ||
|
||
const points: Bulletpoint[] = [ | ||
this.creerPointSimulateurConditionnellement( | ||
thematique.clefTechniqueAPI as ClefThematiqueAPI, | ||
thematiqueData.nombreSimulateurs, | ||
), | ||
{ | ||
nombre: thematiqueData.nombreRecettes, | ||
phrase: { | ||
singulier: 'recette délicieuse, saine et de saison', | ||
pluriel: 'recettes délicieuses, saines et de saison', | ||
}, | ||
}, | ||
{ | ||
nombre: thematiqueData.nombreAides, | ||
phrase: { | ||
singulier: 'aide sur votre territoire', | ||
pluriel: 'aides sur votre territoire', | ||
}, | ||
}, | ||
{ | ||
nombre: thematiqueData.nombreActions, | ||
phrase: { | ||
singulier: "idée d'actions", | ||
pluriel: "idées d'actions", | ||
}, | ||
}, | ||
]; | ||
|
||
const bulletPoints: string[] = this.transformerEnHTML(points); | ||
const titreHTML = `<span aria-hidden="true">${thematique.emoji}</span>  ${thematique.labelDansLeMenu}`; | ||
|
||
return { | ||
id: thematique.url, | ||
titreHTML, | ||
bulletPoints, | ||
}; | ||
}), | ||
}); | ||
} | ||
|
||
private creerPointSimulateurConditionnellement(clefTechniqueAPI: ClefThematiqueAPI, nombreSimulateurs: number) { | ||
if (clefTechniqueAPI === ClefThematiqueAPI.logement) { | ||
return { | ||
nombre: nombreSimulateurs, | ||
phrase: { singulier: 'simulateur Mes Aides Rénov', pluriel: 'simulateurs Mes Aides Rénov' }, | ||
}; | ||
} else if (clefTechniqueAPI === ClefThematiqueAPI.transports) { | ||
return { | ||
nombre: nombreSimulateurs, | ||
phrase: { singulier: 'simulateur vélo et voiture', pluriel: 'simulateurs vélo et voiture' }, | ||
}; | ||
} else { | ||
return { | ||
nombre: nombreSimulateurs, | ||
phrase: { singulier: 'simulateur', pluriel: 'simulateurs' }, | ||
}; | ||
} | ||
} | ||
|
||
private transformerEnHTML(points: Bulletpoint[]): string[] { | ||
return points | ||
.filter(({ nombre }) => nombre !== 0 && nombre !== undefined) | ||
.map(({ nombre, phrase }): string => { | ||
return `<span class="text--bold">${nombre}</span> ${gererPluriel(nombre, phrase.singulier, phrase.pluriel)}`; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/domaines/thematiques/ports/syntheseThematique.presenter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SyntheseThematiques } from '@/domaines/thematiques/ports/thematiques.repository'; | ||
|
||
export interface SyntheseThematiqueViewModel { | ||
id: string; | ||
titreHTML: string; | ||
bulletPoints: string[]; | ||
} | ||
|
||
export interface SyntheseThematiquesViewModel { | ||
commune: string; | ||
cartesThematiques: SyntheseThematiqueViewModel[]; | ||
} | ||
|
||
export interface SyntheseThematiquePresenter { | ||
presente(synthese: SyntheseThematiques): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
import { ClefThematiqueAPI } from '@/domaines/thematiques/MenuThematiques'; | ||
export interface SyntheseThematiques { | ||
commune: string; | ||
listeThematiques: { | ||
thematique: string; | ||
nombreRecettes: number; | ||
nombreActions: number; | ||
nombreAides: number; | ||
nombreSimulateurs: number; | ||
}[]; | ||
} | ||
|
||
export interface ThematiquesRepository { | ||
terminerPersonnalisation(idUtilisateur: string, clefThematiqueApi: ClefThematiqueAPI): Promise<void>; | ||
resetPersonnalisation(idUtilisateur: string, clefThematiqueApi: ClefThematiqueAPI): Promise<void>; | ||
recupererSyntheseThematiques(utilisateurId: string): Promise<SyntheseThematiques>; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/domaines/thematiques/recupererSyntheseThematiques.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { SyntheseThematiquePresenter } from '@/domaines/thematiques/ports/syntheseThematique.presenter'; | ||
import { ThematiquesRepository } from '@/domaines/thematiques/ports/thematiques.repository'; | ||
|
||
export class RecupererSyntheseThematiques { | ||
constructor(private readonly repository: ThematiquesRepository) {} | ||
|
||
async execute(idUtilisateur: string, presenter: SyntheseThematiquePresenter) { | ||
const synthese = await this.repository.recupererSyntheseThematiques(idUtilisateur); | ||
await presenter.presente(synthese); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { RouteRecordRaw } from 'vue-router'; | ||
const PageParOuCommencer = () => import('@/components/pages/PageParOuCommencer.vue'); | ||
|
||
export enum RouteAccueilName { | ||
COMMENCER = 'agir_v2', | ||
} | ||
|
||
const accueilRoutes: RouteRecordRaw[] = [ | ||
{ | ||
path: `/v2/agir`, | ||
name: RouteAccueilName.COMMENCER, | ||
component: PageParOuCommencer, | ||
meta: { | ||
title: 'Thématique', | ||
}, | ||
}, | ||
]; | ||
|
||
export default accueilRoutes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.