Skip to content

Commit e76f4e7

Browse files
committed
fix(funding): Set data sort on budget desc by default
1 parent 2aae381 commit e76f4e7

3 files changed

Lines changed: 9 additions & 22 deletions

File tree

client/src/boards/financements-par-aap/pages/structures/components/projects-data/datatable.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,16 @@ export default function DataTable({ aggregations, columns, dataTable, filters, n
1212

1313
const getSortableIcon = (column) => {
1414
if (column.isSortable) {
15-
const id = column?.sortableField ?? column.id;
16-
if ((id === sorting?.id) && (sorting?.order === 'asc')) return (
17-
<button
18-
className="button-action border p-1 rounded"
19-
onClick={() => handleSort(column)}
20-
>
21-
<i className="ri-sort-asc" />
22-
</button>
23-
)
24-
if ((id === sorting?.id) && (sorting?.order === 'desc')) return (
25-
<button
26-
className="button-action border p-1 rounded"
27-
onClick={() => handleSort(column)}
28-
>
29-
<i className="ri-sort-desc" />
30-
</button>
31-
)
32-
else return (
15+
const id = column?.sortableField ?? column.id
16+
let icon = <i className="ri-arrow-up-down-fill" />
17+
if ((id === sorting?.id) && (sorting?.order === 'asc')) icon = <i className="ri-sort-asc" />
18+
if ((id === sorting?.id) && (sorting?.order === 'desc')) icon = <i className="ri-sort-desc" />
19+
return (
3320
<button
3421
className="button-action border p-1 rounded"
3522
onClick={() => handleSort(column)}
3623
>
37-
<i className="ri-subtract-line" />
24+
{icon}
3825
</button>
3926
)
4027
}

client/src/boards/financements-par-aap/pages/structures/components/projects-data/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button, Col, Row, Text, Title } from "@dataesr/dsfr-plus";
22
import { useQuery } from "@tanstack/react-query";
3-
import { useMemo, useState } from "react";
3+
import { useEffect, useMemo, useState } from "react";
44
import { useSearchParams } from "react-router-dom";
55

66
import DefaultSkeleton from "../../../../../../components/charts-skeletons/default.tsx";
@@ -49,7 +49,7 @@ export default function ProjectsData() {
4949

5050
const [filters, setFilters] = useState<Filter[]>([])
5151
const [pagination, setPagination] = useState({ from: 0, size: 10 })
52-
const [sorting, setSorting] = useState<Sort>();
52+
const [sorting, setSorting] = useState<Sort>({ id: 'project_budgetFinanced', order: 'desc' });
5353

5454
const body = {
5555
...getEsQuery({ structures: [structure], yearMax, yearMin }),

client/src/boards/financements-par-aap/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const getEsQuery = ({ regions, structures, yearMax = years[years.length - 1], ye
4646
{ range: { project_year: { gte: yearMin, lte: yearMax } } },
4747
{ term: { participant_isFrench: true } },
4848
{ term: { participant_status: "active" } },
49-
{ term: { "participant_kind.keyword": "Secteur public" } },
5049
{ terms: { "project_type.keyword": funders } },
5150
{ bool: { must_not: { terms: { "participant_typologie_1.keyword": typologiesExcluded } } } },
5251
],
@@ -58,6 +57,7 @@ const getEsQuery = ({ regions, structures, yearMax = years[years.length - 1], ye
5857
query.query.bool.filter.push({ term: { participant_is_main_parent: 1 } });
5958
query.query.bool.filter.push({ term: { participant_type: "institution" } });
6059
query.query.bool.filter.push({ terms: { "participant_id.keyword": structuresNotNull } });
60+
query.query.bool.filter.push({ term: { "participant_kind.keyword": "Secteur public" } });
6161
};
6262
const regionsNotNull = regions?.filter((region) => region !== null);
6363
if (regionsNotNull?.length ?? 0 > 0) {

0 commit comments

Comments
 (0)