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

fix(consents): agGrid date sort

parent c7f2c002
No related branches found
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
......@@ -17,6 +17,7 @@ import {
GridReadyEvent,
RowNode,
RowSelectedEvent,
ValueFormatterParams,
} from 'ag-grid-community'
import styles from './consents.module.scss'
import './agGridOverrides.scss'
......@@ -26,6 +27,7 @@ import { ConsentService } from '../../services/consent.service'
import { UserContextProps, UserContext } from '../../hooks/userContext'
import { IConsent } from '../../models/consent.model'
import { getAxiosXSRFHeader } from '../../axios.config'
import { DateTime } from 'luxon'
const Consents: React.FC = () => {
const [gridApi, setGridApi] = useState<GridApi | null>(null)
......@@ -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>([
{
field: 'ID',
......@@ -98,6 +105,7 @@ const Consents: React.FC = () => {
},
{
field: 'startDate',
valueFormatter: dateFormatter,
headerName: 'Début du consentement',
initialWidth: 150,
filter: true,
......@@ -105,11 +113,13 @@ const Consents: React.FC = () => {
},
{
field: 'endDate',
valueFormatter: dateFormatter,
headerName: 'Fin du consentement',
initialWidth: 150,
filter: true,
},
])
const handleChangePage = useCallback(
(
_event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null,
......
import { DateTime } from 'luxon'
export interface IConsent
extends Omit<ConsentEntity, 'CreatedAt' | 'endDate' | 'inseeCode'> {
startDate: string
endDate: string
startDate: DateTime
endDate: DateTime
}
export interface ConsentEntity {
......
......@@ -73,16 +73,12 @@ export class ConsentService {
* @param consentEntity
*/
public parseConsent = (consentEntity: ConsentEntity): IConsent => {
const startDate: string = DateTime.fromISO(consentEntity.CreatedAt, {
const startDate: DateTime = DateTime.fromISO(consentEntity.CreatedAt, {
zone: 'utc',
})
.setLocale('fr-FR')
.toLocaleString()
const endDate: string = DateTime.fromISO(consentEntity.endDate, {
}).setLocale('fr-FR')
const endDate: DateTime = DateTime.fromISO(consentEntity.endDate, {
zone: 'utc',
})
.setLocale('fr-FR')
.toLocaleString()
}).setLocale('fr-FR')
return {
ID: consentEntity.ID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment