Skip to content

Commit

Permalink
feat: pilotage archivage
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlbrjc committed Dec 17, 2024
1 parent 3b6e711 commit 26c33ab
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ function CreationBeneficiaireFranceTravailPage(): ReactElement {
})

setPortefeuille(
portefeuille.concat({ ...beneficiaireCree, estAArchiver: false })
portefeuille.concat({
...beneficiaireCree,
isActivated: false,
estAArchiver: false,
})
)
setAlerte(AlerteParam.creationBeneficiaire, beneficiaireCree.id)
router.push('/mes-jeunes')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ function CreationBeneficiaireMiloPage() {
)

setPortefeuille(
portefeuille.concat({ ...beneficiaireCree, estAArchiver: false })
portefeuille.concat({
...beneficiaireCree,
isActivated: false,
estAArchiver: false,
})
)
setAlerte(AlerteParam.creationBeneficiaire, beneficiaireCree.id)
router.push('/mes-jeunes')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ongletProps: {
},
ARCHIVAGE: {
queryParam: 'archivage',
trackingLabel: 'Archivage bénéficiaire',
trackingLabel: 'Archivage bénéficiaires',
},
}

Expand Down Expand Up @@ -192,6 +192,7 @@ function PilotagePage({
<span className='text-base-bold'> À qualifier</span>
</dd>
</div>

{conseiller.agence?.id && (
<>
<div>
Expand Down Expand Up @@ -232,17 +233,16 @@ 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>
)}

<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 @@ -274,17 +274,15 @@ 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}
/>
)}
<Tab
label='Archivage des comptes'
count={nbBeneficiairesAArchiver}
selected={currentTab === 'ARCHIVAGE'}
controls='liste-beneficiaires-a-archiver'
onSelectTab={() => switchTab('ARCHIVAGE')}
iconName={IconName.Delete}
important={true}
/>
</TabList>

{currentTab === 'ACTIONS' && (
Expand Down Expand Up @@ -348,7 +346,7 @@ function PilotagePage({
</div>
)}

{currentTab === 'ARCHIVAGE' && aDesBeneficiairesAArchiver && (
{currentTab === 'ARCHIVAGE' && (
<div
role='tabpanel'
aria-labelledby='liste-beneficiaires-a-archiver--tab'
Expand Down
28 changes: 11 additions & 17 deletions components/pilotage/OngletBeneficiairesAArchiverPilotage.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import { BeneficiaireWithActivity } from '../../interfaces/beneficiaire'
import EmptyState from 'components/EmptyState'
import TableauBeneficiairesAArchiver from 'components/pilotage/TableauBeneficiairesAArchiver'
import { IllustrationName } from 'components/ui/IllustrationComponent'
import { BeneficiaireWithActivity } from 'interfaces/beneficiaire'

import TableauBeneficiairesAArchiver from './TableauBeneficiairesAArchiver'

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

interface OngletBeneficiairesAArchiverPilotageProps {
type 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 && (
<EmptyState
illustrationName={IllustrationName.People}
titre='Vous n’avez pas de bénéficiaires à archiver.'
/>
)}

{beneficiaires.length > 0 && (
Expand Down
23 changes: 10 additions & 13 deletions components/pilotage/TableauBeneficiairesAArchiver.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { DateTime } from 'luxon'

import {
BeneficiaireWithActivity,
getNomBeneficiaireComplet,
} from '../../interfaces/beneficiaire'
import { TagDate } from '../ui/Indicateurs/Tag'

import { TagDate } from 'components/ui/Indicateurs/Tag'
import Table from 'components/ui/Table/Table'
import TD from 'components/ui/Table/TD'
import { TH } from 'components/ui/Table/TH'
import TR from 'components/ui/Table/TR'
import {
BeneficiaireWithActivity,
getNomBeneficiaireComplet,
} from 'interfaces/beneficiaire'
import { toLongMonthDate, toRelativeDateTime } from 'utils/date'

interface TableauBeneficiairesAArchiverProps {
type TableauBeneficiairesAArchiverProps = {
beneficiaires: BeneficiaireWithActivity[]
}

Expand All @@ -38,10 +37,7 @@ export default function TableauBeneficiairesAArchiver({
<tbody>
{beneficiaires.map((beneficiaire: BeneficiaireWithActivity) => (
<TR key={beneficiaire.id}>
<TD
isBold
className='h-full !p-2 !rounded-tl-base !rounded-bl-none layout_m:!rounded-l-base'
>
<TD isBold>
<div>{getNomBeneficiaireComplet(beneficiaire)}</div>
</TD>

Expand Down Expand Up @@ -72,7 +68,7 @@ export default function TableauBeneficiairesAArchiver({
</TD>

<TD>
{beneficiaire.lastActivity && (
{beneficiaire.isActivated && (
<>
<span
className='text-xs-regular text-grey_800'
Expand All @@ -85,7 +81,8 @@ export default function TableauBeneficiairesAArchiver({
</span>
</>
)}
{!beneficiaire.lastActivity && (

{!beneficiaire.isActivated && (
<span className='text-s-regular text-warning'>
Compte non activé
</span>
Expand Down
8 changes: 6 additions & 2 deletions components/ui/Navigation/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface TabProps {
controls: string
selected: boolean
onSelectTab: () => void
important?: boolean
count?: number
iconName?: IconName
ariaLabel?: string
Expand All @@ -20,7 +21,10 @@ export default function Tab({
count,
iconName,
ariaLabel,
important,
}: TabProps) {
const accentuer = important && count && count > 0

return (
<li role='presentation'>
<button
Expand Down Expand Up @@ -54,8 +58,8 @@ export default function Tab({
<span className='sr-only'> </span>
<Badge
count={count}
textColor='primary'
bgColor='primary_lighten'
textColor={accentuer ? 'white' : 'primary'}
bgColor={accentuer ? 'warning' : 'primary_lighten'}
style='ml-4'
size={6}
/>
Expand Down
5 changes: 3 additions & 2 deletions fixtures/beneficiaire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const unBeneficiaireWithActivity = (
): BeneficiaireWithActivity => {
const defaults: BeneficiaireWithActivity = {
...uneBaseBeneficiaire(),
isActivated: true,
lastActivity: '2021-12-07T17:30:07.756Z',
estAArchiver: false,
}
return { ...defaults, ...overrides }
Expand Down Expand Up @@ -114,8 +116,7 @@ export const unItemBeneficiaire = (
overrides: Partial<BeneficiaireFromListe> = {}
): BeneficiaireFromListe => {
const defaults: BeneficiaireFromListe = {
...unBeneficiaireWithActivity({ lastActivity: '2021-12-07T17:30:07.756Z' }),
isActivated: true,
...unBeneficiaireWithActivity(),
isReaffectationTemporaire: false,
situationCourante: CategorieSituation.SANS_SITUATION,
}
Expand Down
5 changes: 3 additions & 2 deletions interfaces/beneficiaire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export type BaseBeneficiaire = {

export type BeneficiaireWithActivity = BaseBeneficiaire & {
estAArchiver: boolean
isActivated: boolean
lastActivity?: string
dateFinCEJ?: string
}

export type BeneficiaireFromListe = BeneficiaireWithActivity & {
isActivated: boolean
isReaffectationTemporaire: boolean
conseillerPrecedent?: {
nom: string
Expand Down Expand Up @@ -240,8 +240,9 @@ export function extractBeneficiaireWithActivity(
): BeneficiaireWithActivity {
return {
...extractBaseBeneficiaire(beneficiaire),
estAArchiver: beneficiaire.estAArchiver,
isActivated: beneficiaire.isActivated,
lastActivity: beneficiaire.lastActivity,
dateFinCEJ: beneficiaire.dateFinCEJ,
estAArchiver: beneficiaire.estAArchiver,
}
}
3 changes: 1 addition & 2 deletions tests/pages/CreationBeneficiaireFranceTravailPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useRouter } from 'next/navigation'
import CreationBeneficiaireFranceTravailPage from 'app/(connected)/(with-sidebar)/(with-chat)/mes-jeunes/creation-jeune/CreationBeneficiaireFranceTravailPage'
import {
desItemsBeneficiaires,
unBeneficiaireWithActivity,
uneBaseBeneficiaire,
} from 'fixtures/beneficiaire'
import {
Expand Down Expand Up @@ -172,7 +171,7 @@ describe('CreationBeneficiaireFranceTravailPage client side', () => {

expect(portefeuilleSetter).toHaveBeenCalledWith([
...portefeuille,
unBeneficiaireWithActivity(),
{ ...uneBaseBeneficiaire(), isActivated: false, estAArchiver: false },
])
expect(alerteSetter).toHaveBeenCalledWith(
'creationBeneficiaire',
Expand Down
3 changes: 1 addition & 2 deletions tests/pages/CreationBeneficiaireMiloPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useRouter } from 'next/navigation'
import CreationBeneficiaireMiloPage from 'app/(connected)/(with-sidebar)/(with-chat)/mes-jeunes/creation-jeune/CreationBeneficiaireMiloPage'
import {
desItemsBeneficiaires,
unBeneficiaireWithActivity,
uneBaseBeneficiaire,
} from 'fixtures/beneficiaire'
import { unDossierMilo } from 'fixtures/milo'
Expand Down Expand Up @@ -143,7 +142,7 @@ describe('CreationBeneficiaireMiloPage client side', () => {

expect(setPortefeuille).toHaveBeenCalledWith([
...portefeuille,
unBeneficiaireWithActivity(),
{ ...uneBaseBeneficiaire(), isActivated: false, estAArchiver: false },
])
expect(setAlerte).toHaveBeenCalledWith(
'creationBeneficiaire',
Expand Down
Loading

0 comments on commit 26c33ab

Please sign in to comment.