-
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.
tech: refactor done, besoin de fix tests/tsc
- Loading branch information
1 parent
aa90a73
commit 34b40e3
Showing
11 changed files
with
104 additions
and
71 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ActionsPresenter, ActionViewModel } from '@/domaines/actions/ports/actions.presenter'; | ||
import { Action } from '@/domaines/actions/ports/actions.repository'; | ||
import { RouteActionsName } from '@/router/actions/routes'; | ||
import marked from '@/shell/actionMarkdownToHtml'; | ||
import { buildUrl } from '@/shell/buildUrl'; | ||
import { gererPluriel } from '@/shell/pluriel'; | ||
|
||
export class ActionsPresenterImpl implements ActionsPresenter { | ||
constructor(private readonly viewModel: (viewModel: ActionViewModel[]) => void) {} | ||
|
||
async presente(actions: Action[]): Promise<void> { | ||
const vm: ActionViewModel[] = await Promise.all( | ||
actions.map(async action => { | ||
const nombreDePersonnes = gererPluriel( | ||
action.nombreDePersonnes, | ||
`<span class="text--bold">${action.nombreDePersonnes}</span> défi réalisé`, | ||
`<span class="text--bold">${action.nombreDePersonnes}</span> défis réalisés`, | ||
); | ||
|
||
const aidesDisponibles = | ||
action.nombreAidesDisponibles === 0 | ||
? undefined | ||
: gererPluriel( | ||
action.nombreAidesDisponibles, | ||
`<span class="text--bold">${action.nombreAidesDisponibles}</span> aide disponible`, | ||
`<span class="text--bold">${action.nombreAidesDisponibles}</span> aides disponibles`, | ||
); | ||
|
||
return { | ||
code: action.code, | ||
titre: await marked.parseInline(action.titre), | ||
dejaVue: action.dejaVue, | ||
url: { | ||
name: RouteActionsName.ACTION_INDIVIDUELLE, | ||
params: { id: action.code, titre: buildUrl(action.titre), type: action.type }, | ||
}, | ||
nombreDePersonnes, | ||
aidesDisponibles, | ||
}; | ||
}), | ||
); | ||
|
||
this.viewModel(vm); | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
src/domaines/actions/adapters/actionsDansUneThematique.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Action } from '@/domaines/actions/ports/actions.repository'; | ||
|
||
export interface ActionViewModel { | ||
code: string; | ||
titre: string; | ||
nombreDePersonnes?: string; | ||
dejaVue: boolean; | ||
aidesDisponibles?: string; | ||
url: { name: string; params: { id: string; titre: string; type: string } }; | ||
} | ||
|
||
export interface ActionsPresenter { | ||
presente(actions: Action[]): void; | ||
} |
5 changes: 2 additions & 3 deletions
5
src/domaines/actions/ports/actionsDansUneThematiquePresenter.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { ActionsPresenter } from '@/domaines/actions/ports/actions.presenter'; | ||
import { ActionsRepository } from '@/domaines/actions/ports/actions.repository'; | ||
import { CatalogueActionsPresenter } from '@/domaines/actions/ports/catalogueActions.presenter'; | ||
|
||
export class RecupererCatalogueActionsUsecase { | ||
constructor(private readonly actionsRepository: ActionsRepository) {} | ||
|
||
async execute(idUtilisateur: string, presenter: CatalogueActionsPresenter): Promise<void> { | ||
async execute( | ||
idUtilisateur: string, | ||
catalogueActionsPresenter: CatalogueActionsPresenter, | ||
actionsPresenter: ActionsPresenter, | ||
): Promise<void> { | ||
const catalogueActions = await this.actionsRepository.chargerCatalogueActions(idUtilisateur); | ||
presenter.presente(catalogueActions); | ||
catalogueActionsPresenter.presente(catalogueActions); | ||
actionsPresenter.presente(catalogueActions.actions); | ||
} | ||
} |