Skip to content

Commit

Permalink
declare mock messages separately
Browse files Browse the repository at this point in the history
Co-authored-by: Demian Parkhomenko <[email protected]>
  • Loading branch information
firehawk89 and DemianParkhomenko authored Sep 24, 2023
1 parent d4e8038 commit cfac283
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/app/page.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
'use client'

import { useEffect, useState } from 'react'
import Message from '@/components/message'

export default function Home() {
const [timeStamp, setTimeStamp] = useState(0)

useEffect(() => {
setTimeStamp(Date.now())
}, [])
const now = Date.now()
const MOCK_MESSAGES = [
{ sentAt: now - 1000 * 60 * 30, content: `...` },
{ sentAt: now - 1000 * 60 * 20, content: `I\'m not empty` },
{ sentAt: now - 1000 * 60 * 10, content: `Hello, i\'m a message! 😎` },
{
sentAt: now,
content:
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Id, porro',
},
]

export default function Home() {
return (
<main className="flex flex-col gap-3 p-3">
<Message sentAt={timeStamp}>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quae
architecto quis iure ex id voluptatum reprehenderit quod cum laboriosam.
Dicta temporibus quis sed assumenda tempore perferendis voluptas magnam
minima dignissimos! Dignissimos porro ea incidunt quae blanditiis,
exercitationem deserunt beatae omnis temporibus officiis, consequatur
nulla accusamus commodi officia minus, ullam unde optio nisi similique
ab maiores? Perferendis aliquid minus laudantium error.
</Message>
<Message sentAt={timeStamp}>Hello, i'm a message! 😎</Message>
<Message sentAt={timeStamp}>I'm not empty</Message>
<Message sentAt={timeStamp}>...</Message>
{MOCK_MESSAGES.map(({ sentAt, content }, i) => (
<Message key={i} sentAt={sentAt}>
{content}
</Message>
))}
</main>
)
}

0 comments on commit cfac283

Please sign in to comment.