drop some types in

This commit is contained in:
Thomas Ruoff
2021-02-14 22:47:44 +01:00
parent 81db4b5d0e
commit 85a7b54a13
13 changed files with 116 additions and 45 deletions

View File

@@ -1,18 +1,30 @@
import React from 'react'
import { ILatest } from '../interfaces/ILatest'
import Button from './Button'
export default function (props) {
const latest = props.latest || []
export default function LatestList({
latest,
onSelect,
onRemove,
}: {
latest: ILatest[]
onSelect: (l: ILatest) => void
onRemove: (l: ILatest) => void
}) {
if (!latest || !latest.length) {
return null
}
const latestElements = latest.map((item) => {
const created = new Date(item.created)
const subject = item.subject
const hrefId = `#item-${item.id}`
return (
<li key={item.id}>
<a href={hrefId} onClick={() => props.onSelect(item)}>
{created.toLocaleString()}
<a href={hrefId} onClick={() => onSelect(item)}>
<div>{subject}</div>
<div>{created.toLocaleDateString()}</div>
</a>
<span> </span>
<Button onClick={() => props.onRemove(item)}>Remove</Button>
<Button onClick={() => onRemove(item)}>Remove</Button>
</li>
)
})