mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-21 09:23:12 +00:00
31 lines
548 B
TypeScript
31 lines
548 B
TypeScript
export interface Message {
|
|
text: string;
|
|
timestamp: Date;
|
|
}
|
|
|
|
export interface Props {
|
|
messages: Message[];
|
|
}
|
|
|
|
export function Messages(props: Props) {
|
|
const messages = props.messages.map((msg) => {
|
|
return (
|
|
<li>
|
|
{formatDisplayDate(msg.timestamp)} {msg.text}
|
|
</li>
|
|
);
|
|
});
|
|
|
|
return <ul>{messages}</ul>;
|
|
}
|
|
|
|
function formatDisplayDate(timestamp: Date): string {
|
|
return timestamp.toLocaleString([], {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: false,
|
|
});
|
|
}
|