11import { DataGrid , SortModel , usePagination } from '@openfun/cunningham-react' ;
2- import { DateTime , DateTimeFormatOptions } from 'luxon' ;
32import React , { useEffect , useState } from 'react' ;
43import { useTranslation } from 'react-i18next' ;
54import { createGlobalStyle } from 'styled-components' ;
@@ -14,6 +13,7 @@ import {
1413 useDocs ,
1514 useTransRole ,
1615} from '@/features/docs/doc-management' ;
16+ import { useDate } from '@/hook/' ;
1717
1818import { PAGE_SIZE } from '../conf' ;
1919
@@ -47,18 +47,11 @@ function formatSortModel(sortModel: SortModelItem): DocsOrdering | undefined {
4747 }
4848}
4949
50- const format : DateTimeFormatOptions = {
51- month : '2-digit' ,
52- day : '2-digit' ,
53- year : 'numeric' ,
54- hour : '2-digit' ,
55- minute : '2-digit' ,
56- } ;
57-
5850export const DocsGrid = ( ) => {
5951 const { colorsTokens } = useCunninghamTheme ( ) ;
6052 const transRole = useTransRole ( ) ;
61- const { t, i18n } = useTranslation ( ) ;
53+ const { t } = useTranslation ( ) ;
54+ const { formatDate } = useDate ( ) ;
6255 const pagination = usePagination ( {
6356 pageSize : PAGE_SIZE ,
6457 } ) ;
@@ -121,7 +114,7 @@ export const DocsGrid = () => {
121114 $padding = "xtiny"
122115 $radius = "3px"
123116 >
124- { row . is_public ? 'Public' : '' }
117+ { row . is_public ? t ( 'Public' ) : '' }
125118 </ Text >
126119 ) }
127120 </ StyledLink >
@@ -145,13 +138,9 @@ export const DocsGrid = () => {
145138 headerName : t ( 'Created at' ) ,
146139 field : 'created_at' ,
147140 renderCell : ( { row } ) => {
148- const created_at = DateTime . fromISO ( row . created_at )
149- . setLocale ( i18n . language )
150- . toLocaleString ( format ) ;
151-
152141 return (
153142 < StyledLink href = { `/docs/${ row . id } ` } >
154- < Text $weight = "bold" > { created_at } </ Text >
143+ < Text $weight = "bold" > { formatDate ( row . created_at ) } </ Text >
155144 </ StyledLink >
156145 ) ;
157146 } ,
@@ -160,13 +149,9 @@ export const DocsGrid = () => {
160149 headerName : t ( 'Updated at' ) ,
161150 field : 'updated_at' ,
162151 renderCell : ( { row } ) => {
163- const updated_at = DateTime . fromISO ( row . updated_at )
164- . setLocale ( i18n . language )
165- . toLocaleString ( format ) ;
166-
167152 return (
168153 < StyledLink href = { `/docs/${ row . id } ` } >
169- < Text $weight = "bold" > { updated_at } </ Text >
154+ < Text $weight = "bold" > { formatDate ( row . updated_at ) } </ Text >
170155 </ StyledLink >
171156 ) ;
172157 } ,
0 commit comments