import { Button, Text, Icon, Icons, ModalTrigger, Modal } from 'react-basics'; import { formatDistance } from 'date-fns'; import Link from 'next/link'; import useUser from 'hooks/useUser'; import UserDeleteForm from './UserDeleteForm'; import { ROLES } from 'lib/constants'; import useMessages from 'hooks/useMessages'; import SettingsTable from 'components/common/SettingsTable'; import useLocale from 'hooks/useLocale'; export function UsersTable({ data = [], onDelete }) { const { formatMessage, labels } = useMessages(); const { user } = useUser(); const { dateLocale } = useLocale(); const columns = [ { name: 'username', label: formatMessage(labels.username) }, { name: 'role', label: formatMessage(labels.role) }, { name: 'created', label: formatMessage(labels.created) }, { name: 'action', label: ' ' }, ]; const cellRender = (row, data, key) => { if (key === 'created') { return formatDistance(new Date(row.createdAt), new Date(), { addSuffix: true, locale: dateLocale, }); } if (key === 'role') { return formatMessage( labels[Object.keys(ROLES).find(key => ROLES[key] === row.role)] || labels.unknown, ); } return data[key]; }; return ( {(row, keys, rowIndex) => { return ( <> {close => ( )} ); }} ); } export default UsersTable;