utopia-ui/src/Components/Templates/DateUserInfo.tsx
Ulf Gebhardt 5c18ed2abd
fix types - components/templates (#172)
Fix more types - specifically in components/templates. This is done by
removing eslint-ignores and fixing them.
2025-03-03 19:58:04 +00:00

32 lines
1.1 KiB
TypeScript

import { useState } from 'react'
import { timeAgo } from '#utils/TimeAgo'
import type { Item } from '#types/Item'
export const DateUserInfo = ({ item }: { item: Item }) => {
const [infoExpanded, setInfoExpanded] = useState<boolean>(false)
return (
<div
className='tw-flex -tw-mb-1 tw-flex-row tw-mr-2 -tw-mt-2'
onClick={(e) => e.stopPropagation()}
>
{infoExpanded ? (
<p
className={'tw-italic tw-min-h-[21px] !tw-my-0 tw-text-gray-500'}
onClick={() => setInfoExpanded(false)}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
>{`${item.date_updated && item.date_updated !== item.date_created ? 'updated' : 'posted'} ${item.user_created?.first_name ? `by ${item.user_created.first_name}` : ''} ${item.date_updated ? timeAgo(item.date_updated) : timeAgo(item.date_created!)}`}</p>
) : (
<p
className='!tw-my-0 tw-min-h-[21px] tw-font-bold tw-cursor-pointer tw-text-gray-500'
onClick={() => setInfoExpanded(true)}
>
</p>
)}
<div className='tw-grow '></div>
</div>
)
}