Skip to content

Commit

Permalink
feat: ajout archivage dans portefeuille
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzem committed Dec 12, 2024
1 parent 35469d8 commit 922e163
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import dynamic from 'next/dynamic'
import { useRouter } from 'next/navigation'
import React, { useEffect, useState } from 'react'

import { BaseBeneficiaire } from '../../../../../interfaces/beneficiaire'

import IconComponent, { IconName } from 'components/ui/IconComponent'
import Tab from 'components/ui/Navigation/Tab'
import TabList from 'components/ui/Navigation/TabList'
Expand All @@ -29,11 +31,18 @@ const OngletAnimationsCollectivesPilotage = dynamic(
const OngletSessionsImiloPilotage = dynamic(
() => import('components/pilotage/OngletSessionsImiloPilotage')
)
const OngletBeneficiairesAArchiverPilotage = dynamic(
() => import('components/pilotage/OngletBeneficiairesAArchiverPilotage')
)
const EncartAgenceRequise = dynamic(
() => import('components/EncartAgenceRequise')
)

export type Onglet = 'ACTIONS' | 'ANIMATIONS_COLLECTIVES' | 'SESSIONS_IMILO'
export type Onglet =
| 'ACTIONS'
| 'ANIMATIONS_COLLECTIVES'
| 'SESSIONS_IMILO'
| 'ARCHIVAGE'

const ongletProps: {
[key in Onglet]: { queryParam: string; trackingLabel: string }
Expand All @@ -47,6 +56,10 @@ const ongletProps: {
queryParam: 'sessionsImilo',
trackingLabel: 'Sessions i-milo',
},
ARCHIVAGE: {
queryParam: 'archivage',
trackingLabel: 'Archivage bénéficiaire',
},
}

type PilotageProps = {
Expand Down Expand Up @@ -87,6 +100,12 @@ function PilotagePage({
| undefined
>(animationsCollectives)

const beneficiairesAArchiver = portefeuille.filter(
(beneficiaire) => beneficiaire.estAArchiver
)
const nbBeneficiairesAArchiver = beneficiairesAArchiver.length
const aDesBeneficiairesAArchiver = nbBeneficiairesAArchiver > 0

const pageTracking = 'Pilotage'
const [trackingLabel, setTrackingLabel] = useState<string>(
pageTracking + ' - Consultation ' + ongletProps[currentTab].trackingLabel
Expand Down Expand Up @@ -215,6 +234,17 @@ function PilotagePage({
)}
</>
)}
{aDesBeneficiairesAArchiver && (
<div>
<dt className='text-base-bold'>Bénéficiaires</dt>
<dd
className={`mt-2 rounded-base px-3 py-2 ${aDesBeneficiairesAArchiver ? 'bg-warning_lighten text-warning' : 'bg-primary_lighten text-primary_darken'}`}
>
<div className='text-xl-bold'>{nbBeneficiairesAArchiver}</div>
<span className='text-base-bold'> À archiver</span>
</dd>
</div>
)}
</dl>
</div>

Expand Down Expand Up @@ -246,6 +276,17 @@ function PilotagePage({
iconName={IconName.EventFill}
/>
)}
{aDesBeneficiairesAArchiver && (
<Tab
label='Archivage'
ariaLabel='Archivage des bénéficiaires'
count={nbBeneficiairesAArchiver}
selected={currentTab === 'ARCHIVAGE'}
controls='liste-beneficiaires-a-archiver'
onSelectTab={() => switchTab('ARCHIVAGE')}
iconName={IconName.EventFill}
/>
)}
</TabList>

{currentTab === 'ACTIONS' && (
Expand Down Expand Up @@ -308,6 +349,20 @@ function PilotagePage({
{sessions && <OngletSessionsImiloPilotage sessions={sessions} />}
</div>
)}

{currentTab === 'ARCHIVAGE' && aDesBeneficiairesAArchiver && (
<div
role='tabpanel'
aria-labelledby='liste-beneficiaires-a-archiver--tab'
tabIndex={0}
id='liste-beneficiaires-a-archiver'
className='mt-8 pb-8 border-b border-primary_lighten'
>
<OngletBeneficiairesAArchiverPilotage
beneficiaires={beneficiairesAArchiver}
/>
</div>
)}
</>
)
}
Expand Down
3 changes: 3 additions & 0 deletions app/(connected)/(with-sidebar)/(with-chat)/pilotage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export default async function Pilotage({
case 'sessionsImilo':
onglet = 'SESSIONS_IMILO'
break
case 'archivage':
onglet = 'ARCHIVAGE'
break
}

return (
Expand Down
33 changes: 33 additions & 0 deletions components/pilotage/OngletBeneficiairesAArchiverPilotage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { BeneficiaireWithActivity } from '../../interfaces/beneficiaire'

import TableauBeneficiairesAArchiver from './TableauBeneficiairesAArchiver'

import EmptyStateImage from 'assets/images/illustration-event-grey.svg'

interface OngletBeneficiairesAArchiverPilotageProps {
beneficiaires: BeneficiaireWithActivity[]
}
export default function OngletBeneficiairesAArchiverPilotage({
beneficiaires,
}: OngletBeneficiairesAArchiverPilotageProps) {
return (
<>
{Boolean(beneficiaires && beneficiaires.length === 0) && (
<div className='flex flex-col justify-center items-center'>
<EmptyStateImage
focusable={false}
aria-hidden={true}
className='w-[360px] h-[200px]'
/>
<p className='mt-4 text-base-medium w-2/3 text-center'>
Vous n’avez pas de bénéficiaires à archiver.
</p>
</div>
)}

{beneficiaires.length > 0 && (
<TableauBeneficiairesAArchiver beneficiaires={beneficiaires} />
)}
</>
)
}
58 changes: 58 additions & 0 deletions components/pilotage/TableauBeneficiairesAArchiver.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
BaseBeneficiaire,
BeneficiaireFromListe,
} from '../../interfaces/beneficiaire'

import { Badge } from 'components/ui/Indicateurs/Badge'
import Table from 'components/ui/Table/Table'
import TD from 'components/ui/Table/TD'
import TDLink from 'components/ui/Table/TDLink'
import { TH } from 'components/ui/Table/TH'
import TR from 'components/ui/Table/TR'
import { toLongMonthDate } from 'utils/date'

interface TableauBeneficiairesAArchiverProps {
beneficiaires: BeneficiaireFromListe[]
}

export default function TableauBeneficiairesAArchiver({
beneficiaires,
}: TableauBeneficiairesAArchiverProps) {
return (
<>
{beneficiaires.length > 0 && (
<Table caption={{ text: 'Liste des bénéficiaires à archiver' }}>
<thead>
<TR isHeader={true}>
<TH>Date</TH>
<TH>Titre de l’animation collective</TH>
<TH>Participants</TH>
<TH>Voir le détail</TH>
</TR>
</thead>

<tbody>
{beneficiaires.map((benef: BaseBeneficiaire) => (
<TR key={benef.id}>
<TD>{toLongMonthDate(benef.date)}</TD>
<TD isBold>{benef.titre}</TD>
<TD>
<Badge
count={benef.nombreInscrits}
textColor='accent_1'
bgColor='accent_1_lighten'
size={6}
/>
</TD>
<TDLink
href={`/mes-jeunes/edition-rdv?idRdv=${benef.id}`}
labelPrefix='Archiver le jeune'
/>
</TR>
))}
</tbody>
</Table>
)}
</>
)
}

0 comments on commit 922e163

Please sign in to comment.