Skip to content
Snippets Groups Projects
Commit 0dcde370 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

Merge branch 'fix/US847-aggrid-date-sort' into 'dev'

Fix/us847 aggrid date sort

See merge request web-et-numerique/llle_project/backoffice-client!73
parents c7f2c002 80949863
Branches
No related tags found
6 merge requests!96Deploy OpenShift v2,!95MEP fix liens undefined,!91MEP: removed Meilisearch,!79Fix: nginx unprivileged image,!77Back-office SGE before canary release,!73Fix/us847 aggrid date sort
Pipeline #43431 passed
...@@ -17,6 +17,7 @@ import { ...@@ -17,6 +17,7 @@ import {
GridReadyEvent, GridReadyEvent,
RowNode, RowNode,
RowSelectedEvent, RowSelectedEvent,
ValueFormatterParams,
} from 'ag-grid-community' } from 'ag-grid-community'
import styles from './consents.module.scss' import styles from './consents.module.scss'
import './agGridOverrides.scss' import './agGridOverrides.scss'
...@@ -26,6 +27,7 @@ import { ConsentService } from '../../services/consent.service' ...@@ -26,6 +27,7 @@ import { ConsentService } from '../../services/consent.service'
import { UserContextProps, UserContext } from '../../hooks/userContext' import { UserContextProps, UserContext } from '../../hooks/userContext'
import { IConsent } from '../../models/consent.model' import { IConsent } from '../../models/consent.model'
import { getAxiosXSRFHeader } from '../../axios.config' import { getAxiosXSRFHeader } from '../../axios.config'
import { DateTime } from 'luxon'
const Consents: React.FC = () => { const Consents: React.FC = () => {
const [gridApi, setGridApi] = useState<GridApi | null>(null) const [gridApi, setGridApi] = useState<GridApi | null>(null)
...@@ -53,6 +55,11 @@ const Consents: React.FC = () => { ...@@ -53,6 +55,11 @@ const Consents: React.FC = () => {
}), }),
[] []
) )
const dateFormatter = (data: ValueFormatterParams): string => {
return (data.value as DateTime).toLocaleString()
}
const [columnDefs] = useState<(ColDef | ColGroupDef)[] | null>([ const [columnDefs] = useState<(ColDef | ColGroupDef)[] | null>([
{ {
field: 'ID', field: 'ID',
...@@ -98,6 +105,7 @@ const Consents: React.FC = () => { ...@@ -98,6 +105,7 @@ const Consents: React.FC = () => {
}, },
{ {
field: 'startDate', field: 'startDate',
valueFormatter: dateFormatter,
headerName: 'Début du consentement', headerName: 'Début du consentement',
initialWidth: 150, initialWidth: 150,
filter: true, filter: true,
...@@ -105,11 +113,13 @@ const Consents: React.FC = () => { ...@@ -105,11 +113,13 @@ const Consents: React.FC = () => {
}, },
{ {
field: 'endDate', field: 'endDate',
valueFormatter: dateFormatter,
headerName: 'Fin du consentement', headerName: 'Fin du consentement',
initialWidth: 150, initialWidth: 150,
filter: true, filter: true,
}, },
]) ])
const handleChangePage = useCallback( const handleChangePage = useCallback(
( (
_event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null, _event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null,
......
import { DateTime } from 'luxon'
export interface IConsent export interface IConsent
extends Omit<ConsentEntity, 'CreatedAt' | 'endDate' | 'inseeCode'> { extends Omit<ConsentEntity, 'CreatedAt' | 'endDate' | 'inseeCode'> {
startDate: string startDate: DateTime
endDate: string endDate: DateTime
} }
export interface ConsentEntity { export interface ConsentEntity {
......
...@@ -73,16 +73,12 @@ export class ConsentService { ...@@ -73,16 +73,12 @@ export class ConsentService {
* @param consentEntity * @param consentEntity
*/ */
public parseConsent = (consentEntity: ConsentEntity): IConsent => { public parseConsent = (consentEntity: ConsentEntity): IConsent => {
const startDate: string = DateTime.fromISO(consentEntity.CreatedAt, { const startDate: DateTime = DateTime.fromISO(consentEntity.CreatedAt, {
zone: 'utc', zone: 'utc',
}) }).setLocale('fr-FR')
.setLocale('fr-FR') const endDate: DateTime = DateTime.fromISO(consentEntity.endDate, {
.toLocaleString()
const endDate: string = DateTime.fromISO(consentEntity.endDate, {
zone: 'utc', zone: 'utc',
}) }).setLocale('fr-FR')
.setLocale('fr-FR')
.toLocaleString()
return { return {
ID: consentEntity.ID, ID: consentEntity.ID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment