-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: affichage d'un fil d'ariane sur la page du diag FT (#1882)
- Loading branch information
Lionel
authored
Jul 12, 2023
1 parent
fb8f84c
commit 62956b6
Showing
4 changed files
with
66 additions
and
11 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
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 /> |
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
11 changes: 11 additions & 0 deletions
11
app/src/routes/(auth)/carnet/[notebook]/diagnostic-france-travail/getNotebookBreadCrumb.gql
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 @@ | ||
query GetNotebookBreadcrumb($notebookId: uuid!) { | ||
notebook: notebook_by_pk(id: $notebookId) { | ||
beneficiary { | ||
firstname | ||
lastname | ||
structures(where: { status: { _eq: "current" } }, limit: 1) { | ||
structureId | ||
} | ||
} | ||
} | ||
} |