import React, { useEffect, useState } from 'react'
import "./index.less"
import { Typography } from 'antd';
import _service from "@netuno/service-client";

function Feed(){
    const [publications, setPublications] = useState([])

    useEffect(() => {
        _service({
            url: "api/publications",
            success: (resopnse) => {
                setPublications(resopnse.json)
                console.log(resopnse.json)
            }
        })
    }, [])
    return(
        <>
            {publications.map(publication => {
                return(
                    <div className="publication">
                        <header>
                            <Typography.Title level={4}>{publication.community}</Typography.Title>
                            <Typography.Text>{publication.moment}</Typography.Text>
                        </header>
                        <Typography.Text>{publication.message}</Typography.Text>
                    </div>
                )
            })}
        </>
    )
}

export default Feed