mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Use common date format function for last login date in table and detailview
This commit is contained in:
@@ -2,6 +2,11 @@ import { MRT_ColumnDef } from 'material-react-table'
|
||||
import { Reference } from './backendTypes'
|
||||
import { Cell } from './components/commonComponents'
|
||||
|
||||
export const formatLastLoginDate = (date: Date) => {
|
||||
const dateFormat = new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric' })
|
||||
return dateFormat.format(new Date(date))
|
||||
}
|
||||
|
||||
export const referenceTableColumns: MRT_ColumnDef<Reference>[] = [
|
||||
{
|
||||
id: 'id',
|
||||
|
||||
@@ -3,6 +3,7 @@ import { type MRT_ColumnDef } from 'material-react-table'
|
||||
import { useGetAllPersonsQuery } from '../../redux/personReducer'
|
||||
import { PersonDetailsType } from '@/backendTypes'
|
||||
import { TableView } from '../TableView/TableView'
|
||||
import { formatLastLoginDate } from '@/common'
|
||||
|
||||
export const PersonTable = ({ selectorFn }: { selectorFn?: (id: PersonDetailsType) => void }) => {
|
||||
const personQuery = useGetAllPersonsQuery()
|
||||
@@ -44,7 +45,8 @@ export const PersonTable = ({ selectorFn }: { selectorFn?: (id: PersonDetailsTyp
|
||||
header: 'User name',
|
||||
},
|
||||
{
|
||||
accessorKey: 'user.last_login',
|
||||
accessorFn: (person: PersonDetailsType) =>
|
||||
person.user?.last_login ? formatLastLoginDate(person.user?.last_login) : 'None',
|
||||
header: 'Last login',
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user