Skip to content

Commit

Permalink
fix: affichage d'un fil d'ariane sur la page du diag FT (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel authored Jul 12, 2023
1 parent fb8f84c commit 62956b6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/elm/Pages/Carnet/Diagnostic/PoleEmploi/Page.elm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ toObjectif objectif =

view : Model -> Html Msg
view model =
Html.section [ Attr.class "fr-container flex flex-col gap-8" ]
Html.section [ Attr.class "flex flex-col gap-8" ]
[ Html.h1 [] [ Html.text "Diagnostic France Travail" ]
, case
model
Expand Down
59 changes: 52 additions & 7 deletions app/src/routes/(auth)/carnet/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,71 @@
<script lang="ts">
import { homeForRole } from '$lib/routes';
import type { MenuItem } from '$lib/types';
import { accountData } from '$lib/stores';
import { NPSRating } from '$lib/ui/NPSRating';
import Footer from '$lib/ui/base/Footer.svelte';
import Header from '$lib/ui/base/Header.svelte';
import { operationStore, query } from '@urql/svelte';
import Breadcrumbs from '$lib/ui/base/Breadcrumbs.svelte';
import LoaderIndicator from '$lib/ui/utils/LoaderIndicator.svelte';
import { GetNotebookBreadcrumbDocument, RoleEnum } from '$lib/graphql/_gen/typed-document-nodes';
import { homeForRole, type Segment } from '$lib/routes';
import { connectedUser } from '$lib/stores';
import { displayFullName } from '$lib/ui/format';
import { page } from '$app/stores';
const menuItems: MenuItem[] = [
{
id: 'accueil',
path: homeForRole($accountData.type),
label: 'Accueil',
},
];
const getNotebookBreadcrumb = operationStore(GetNotebookBreadcrumbDocument, {
notebookId: $page.data.notebookId,
});
query(getNotebookBreadcrumb);
$: beneficiary = $getNotebookBreadcrumb.data?.notebook.beneficiary;
$: structureId = beneficiary?.structures[0].structureId;
$: breadcrumbs = getBreadcrumbForRole($connectedUser.role, $page.data.notebookId, structureId);
function getNotebookUrlForRole(role: string, notebookId: string, structureId?: string): string {
switch (role) {
case RoleEnum.Professional:
return `${homeForRole(role)}/carnet/${notebookId}`;
case RoleEnum.AdminStructure:
return `${homeForRole(role)}/${structureId}/carnets/${notebookId}`;
case RoleEnum.Manager:
return `${homeForRole(role)}/carnets/${notebookId}`;
case RoleEnum.OrientationManager:
return `${homeForRole(role)}/carnets/edition/${notebookId}`;
default:
return '';
}
}
function getBreadcrumbForRole(role: string, notebookId: string, structureId?: string): Segment[] {
return [
{
name: 'notebook',
path: getNotebookUrlForRole(role, notebookId, structureId),
label: `Carnet de ${displayFullName(beneficiary)}`,
},
{ name: 'diagnostic', label: 'Diagnostic France Travail' },
];
}
</script>

<Header {menuItems} />

<div class="fr-container fr-py-6w fr-px-1w">
<div class="flex flex-col gap-8">
<slot />
<LoaderIndicator result={$getNotebookBreadcrumb}>
<div class="fr-container fr-pb-6w fr-px-2w">
<Breadcrumbs segments={breadcrumbs} />
<div class="flex flex-col gap-8">
<slot />
</div>
<NPSRating />
</div>
<NPSRating />
</div>

</LoaderIndicator>
<Footer />
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { Elm as DiagnosticPE } from '$elm/Pages/Carnet/Diagnostic/PoleEmploi/Main.elm';
import ElmWrapper from '$lib/utils/ElmWrapper.svelte';
import type { PageData } from './$types';
Expand All @@ -15,6 +16,4 @@
};
</script>

<div>
<ElmWrapper setup={elmSetup} />
</div>
<ElmWrapper setup={elmSetup} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
query GetNotebookBreadcrumb($notebookId: uuid!) {
notebook: notebook_by_pk(id: $notebookId) {
beneficiary {
firstname
lastname
structures(where: { status: { _eq: "current" } }, limit: 1) {
structureId
}
}
}
}

0 comments on commit 62956b6

Please sign in to comment.