aboutsummaryrefslogtreecommitdiff
path: root/src/components/Guestbook.jsx
blob: a04990a1781f50c324eaba9ce846081de3f65574 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import withMessages from './FetchMessages';
import GuestbookForm from "./GuestbookForm.jsx";
import { formatDate } from "../util";
import sanitizeHtml from "sanitize-html";

const Guestbook = ({ message, page, totalPages, handleNext, handlePrevious }) => (
    <div>
        <div className="grid">
            {message.map((g) => (
                <article className="card">
                    <h1>Message from: {g.name}</h1>
                    <small>{formatDate(g.created_at)}</small>
                    <div dangerouslySetInnerHTML={{ __html: sanitizeHtml(g.message) }} />
                    {g.website && <a href={g.website} target="_blank">My Website</a>}
                </article>
            ))}
        </div>
        {page > 1 && <button className="button margin" onClick={handlePrevious}>Previous</button>}
        {page < totalPages && <button className="button margin" onClick={handleNext}>Next</button>}
    </div>
);

export default withMessages(Guestbook, '/guestbook', GuestbookForm);