Skip to content

Commit

Permalink
sort mandateGroupType
Browse files Browse the repository at this point in the history
  • Loading branch information
folland87 committed Mar 17, 2023
1 parent 77d6f17 commit b9d62d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
30 changes: 17 additions & 13 deletions src/components/blocs/relations/components/relations-gouvernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { deleteError, saveError, saveSuccess, deleteSuccess } from '../../../../
import { exportToCsv, hasExport } from '../utils/exports';
import { spreadByStatus } from '../utils/status';

const GROUP_ORDER = ['Direction', 'Vice-présidence', 'Référents thématique', 'Autres fonctions'];

function getByMandateTypeGroups(data) {
if (!data?.length) return {};
const counts = data?.reduce((a, b) => {
Expand Down Expand Up @@ -94,19 +96,21 @@ export default function RelationsGouvernance({ blocName, tag, resourceType, rela
/>
)) : []);
const byTypeRelations = Object.entries(mandateTypeGroups).map(([name, { count, list }]) => ({ name, count, list: renderlist(list) }));
return byTypeRelations.map((group) => (
<>
<Row className="flex--nowrap fr-mt-3w">
<div className="flex--grow">
<Row className="flex flex--start">
<Title as="h6" look="h6">{group.name}</Title>
<Badge className="fr-ml-1v" type="info" text={group.count} />
</Row>
</div>
</Row>
<ExpendableListCards max={60} list={group.list} nCol="12 md-6" />
</>
));
return byTypeRelations
.sort((a, b) => GROUP_ORDER.indexOf(a.name) - GROUP_ORDER.indexOf(b.name))
.map((group) => (
<>
<Row className="flex--nowrap fr-mt-3w">
<div className="flex--grow">
<Row className="flex flex--start">
<Title as="h6" look="h6">{group.name}</Title>
<Badge className="fr-ml-1v" type="info" text={group.count} />
</Row>
</div>
</Row>
<ExpendableListCards max={60} list={group.list} nCol="12 md-6" />
</>
));
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/structures/[id]/gouvernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function StructureGouvernancePage() {
return (
<RelationsGouvernance
tag={GOUVERNANCE}
blocName="Gouvernance"
blocName="Gouvernance, administration et référents"
resourceType="structures"
relatedObjectTypes={['persons']}
Form={MandateForm}
Expand Down

0 comments on commit b9d62d3

Please sign in to comment.