Skip to content

Instantly share code, notes, and snippets.

@Hajto
Created December 31, 2017 13:55
Show Gist options
  • Save Hajto/d30fc82b73853d6af9ec9ac93e899e11 to your computer and use it in GitHub Desktop.
Save Hajto/d30fc82b73853d6af9ec9ac93e899e11 to your computer and use it in GitHub Desktop.
import React from 'react'
import { Segment, Header, Comment } from 'semantic-ui-react';
import _ from 'lodash/fp'
const ownerDetails = (owner) => (owner.details.name + " " + owner.details.surname)
const capitalize = (role) => role.substr(0, 1).toUpperCase() + role.substr(1)
const commentsView = (comments) => (
<Comment.Group>
{
_.map((comment) => (
<Comment key={comment.id}>
<Comment.Content>
<Comment.Author as='a'>{ ownerDetails(comment.user) }</Comment.Author>
<Comment.Metadata>
, { capitalize(comment.user.role) }
</Comment.Metadata>
<Comment.Text>{ comment.text }</Comment.Text>
</Comment.Content>
</Comment>
), comments)
}
</Comment.Group>
)
export const Order = ({order}) => (
<div>
<Segment>
<Header as="h3"> Owner </Header>
<p> {ownerDetails(order.distributor)} </p>
<Header as="h3"> Price </Header>
<p> {order.price} </p>
</Segment>
<Segment>
{ commentsView(order.messages) }
</Segment>
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment