Skip to content

Commit

Permalink
[Reportings] Résolution du bug de tri du tableau par statut (#727)
Browse files Browse the repository at this point in the history
- Relatif à #689
  • Loading branch information
claire2212 authored Aug 4, 2023
2 parents e11b33c + 50f179d commit beec902
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 1 addition & 13 deletions frontend/src/api/reportingsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ const getStartDateFilter = startedAfterDateTime =>
startedAfterDateTime && `startedAfterDateTime=${encodeURIComponent(startedAfterDateTime)}`
const getEndDateFilter = startedBeforeDateTime =>
startedBeforeDateTime && `startedBeforeDateTime=${encodeURIComponent(startedBeforeDateTime)}`
const getReportingSourceFilter = reportingSource =>
reportingSource && `reportingSource=${encodeURIComponent(reportingSource)}`
const getReportingStatusFilter = reportingStatus =>
reportingStatus && reportingStatus?.length > 0 && `reportingStatus=${encodeURIComponent(reportingStatus)}`
const getReportingTypesFilter = reportingTypes =>
reportingTypes && reportingTypes?.length > 0 && `reportingTypes=${encodeURIComponent(reportingTypes)}`
const getSeaFrontsFilter = seaFronts =>
seaFronts && seaFronts?.length > 0 && `seaFronts=${encodeURIComponent(seaFronts)}`

const ReportingAdapter = createEntityAdapter<ReportingDetailed>()
const initialState = ReportingAdapter.getInitialState()
Expand Down Expand Up @@ -59,11 +51,7 @@ export const reportingsAPI = createApi({
[
'reportings?',
getStartDateFilter(filter?.startedAfterDateTime),
getEndDateFilter(filter?.startedBeforeDateTime),
getReportingSourceFilter(filter?.reportingSource),
getReportingStatusFilter(filter?.reportingStatus),
getReportingTypesFilter(filter?.reportingTypes),
getSeaFrontsFilter(filter?.seaFronts)
getEndDateFilter(filter?.startedBeforeDateTime)
]
.filter(v => v)
.join('&'),
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/features/Reportings/ReportingsList/Columns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { CellValidityTime } from '../CellValidityTime'
import { getDateCell } from '../getDateCell'
import { getReportType } from '../getReportType'

import type { Row } from '@tanstack/react-table'

export const Columns = [
{
accessorFn: row => row.reportingId,
Expand Down Expand Up @@ -73,8 +75,18 @@ export const Columns = [
cell: ({ row }) => <CellStatus row={row} />,
enableSorting: true,
header: () => 'Statut',
id: 'status',
size: 110
id: 'isArchived',
size: 110,
sortingFn: (rowA: Row<any>, rowB: Row<any>, columnId: string) => {
if (rowA.original[columnId] > rowB.original[columnId]) {
return -1
}
if (rowB.original[columnId] > rowA.original[columnId]) {
return 1
}

return 1
}
},
{
accessorFn: row => row.geom,
Expand Down

0 comments on commit beec902

Please sign in to comment.