{"action":"created","comment":{"url":"https://api.github.com/repos/sars/appetini-front/pulls/comments/75083270","id":75083270,"diff_hunk":"@@ -1,57 +1,74 @@\n import React, {Component, PropTypes} from 'react';\n-import Card, { CardContent } from 'components/Card/Card';\n+import Card from 'components/Card/Card';\n import Dishes from 'components/Dishes/Dishes';\n import ImagesPreview from 'components/ImagesPreview/ImagesPreview';\n import PortionManipulate from 'components/PortionManipulator/PortionManipulator';\n import styles from './styles.scss';\n+import sumBy from 'lodash/sumBy';\n+import find from 'lodash/find';\n+import { connect } from 'react-redux';\n+import OrderTable from 'components/OrderTable/OrderTable';\n \n+@connect(state => ({\n+  teamOrderPreferences: state.teamOrderPreferences\n+}))\n export default class TeamLunch extends Component {\n   static propTypes = {\n     lunch: PropTypes.object.isRequired,\n+    teamOrderPreferences: PropTypes.object.isRequired,\n     onChangeAmount: PropTypes.func.isRequired,\n+    isOwner: PropTypes.bool,\n     amount: PropTypes.number.isRequired\n   };\n \n-  changeAmountHandle = (amountDelta) => {\n-    const { lunch, onChangeAmount } = this.props;\n-    onChangeAmount(lunch, amountDelta);\n+  changeAmountHandle = (amountDelta, token, name) => {\n+    const { lunch, onChangeAmount, teamOrderPreferences } = this.props;\n+    const buyerId = token || teamOrderPreferences.user.token;\n+    const buyerName = name || teamOrderPreferences.user.name;\n+    const currentOrderItem = find(lunch.order_item_info, {buyer_id: buyerId});\n+    const oldAmount = currentOrderItem ? currentOrderItem.amount : 0;\n+    const currentOrderItemAmount = sumBy(lunch.order_item_info, 'amount') - oldAmount + amountDelta;\n+    onChangeAmount(lunch, amountDelta, currentOrderItemAmount, buyerId, buyerName);\n   }\n \n   render() {\n-    const { lunch, amount } = this.props;\n+    const { lunch, amount, isOwner } = this.props;\n+    const { token } = this.props.teamOrderPreferences.user;\n+    const OrderItemAmountSum = sumBy(lunch.order_item_info, 'amount');\n+    const availableCount = lunch.order_item_info ? undefined : lunch.available_count;\n+\n     return (\n       <Card className={styles.container}>\n         <div className={styles.imagePreviewWrapper}>\n           <ImagesPreview images={lunch.photos} currentImageId={0}/>\n         </div>\n         <div className={styles.infoCard}>\n-          <Dishes dishes={lunch.dishes}/>\n+          <div className={styles.priceSection}>\n+            <h3>Стоимость обеда:</h3>\n+            <span className={styles.price}>{Number(lunch.price)}<span className={styles.currency}> грн</span></span>\n+          </div>\n+          <div className={styles.dishesWrapper}>\n+            <Dishes dishes={lunch.dishes}/>\n+          </div>\n           { lunch.description &&\n             <div className={styles.descriptionWrapper}>\n-              <CardContent className={styles.cardContent}>\n-                <h3>Описание обеда:</h3>\n-                <span className={styles.description}>\n-                  {lunch.description}\n-                </span>\n-              </CardContent>\n+              <h3>Описание обеда:</h3>\n+              <span className={styles.description}>\n+                {lunch.description}\n+              </span>\n             </div>\n           }\n         </div>\n         <div className={styles.amountCard}>\n-            <CardContent className={styles.cardContent}>\n-              <h3 className={styles.portionAmountHeader}>Добавьте порции</h3>\n-              <PortionManipulate availableCount={lunch.available_count} amount={amount} onChangeAmount={::this.changeAmountHandle} />\n-              {lunch.order_item_info && lunch.order_item_info.map((item, idx) => {\n-                if (item.buyer_id) {\n-                  return (\n-                    <div className={styles.buyer} key={idx}>{`${item.buyer_name} - ${item.amount}`}</div>\n-                  );\n-                }\n-              })}\n-              <div className={styles.priceSection}>\n-                <span className={styles.price}>{Number(lunch.price)}</span>грн\n-              </div>\n-            </CardContent>\n+          <h3 className={styles.textHeader}>Мой заказ</h3>\n+          <PortionManipulate availableCount={availableCount} amount={amount} onChangeAmount={this.changeAmountHandle} />\n+          {(OrderItemAmountSum > amount) &&\n+          <OrderTable orderItems={lunch.order_item_info} buyerId={token} isOwner={isOwner} onChangeAmount={this.changeAmountHandle}/>}","path":"src/components/TeamLunch/TeamLunch.js","position":92,"original_position":92,"commit_id":"818e72176621867b989ecbc3e4a5c2f2e7eec206","original_commit_id":"818e72176621867b989ecbc3e4a5c2f2e7eec206","user":{"login":"sars","id":226194,"avatar_url":"https://avatars.githubusercontent.com/u/226194?v=3","gravatar_id":"","url":"https://api.github.com/users/sars","html_url":"https://github.com/sars","followers_url":"https://api.github.com/users/sars/followers","following_url":"https://api.github.com/users/sars/following{/other_user}","gists_url":"https://api.github.com/users/sars/gists{/gist_id}","starred_url":"https://api.github.com/users/sars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sars/subscriptions","organizations_url":"https://api.github.com/users/sars/orgs","repos_url":"https://api.github.com/users/sars/repos","events_url":"https://api.github.com/users/sars/events{/privacy}","received_events_url":"https://api.github.com/users/sars/received_events","type":"User","site_admin":false},"body":"tab","created_at":"2016-08-17T08:40:57Z","updated_at":"2016-08-17T08:40:57Z","html_url":"https://github.com/sars/appetini-front/pull/98#discussion_r75083270","pull_request_url":"https://api.github.com/repos/sars/appetini-front/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/sars/appetini-front/pulls/comments/75083270"},"html":{"href":"https://github.com/sars/appetini-front/pull/98#discussion_r75083270"},"pull_request":{"href":"https://api.github.com/repos/sars/appetini-front/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/sars/appetini-front/pulls/98","id":81288890,"html_url":"https://github.com/sars/appetini-front/pull/98","diff_url":"https://github.com/sars/appetini-front/pull/98.diff","patch_url":"https://github.com/sars/appetini-front/pull/98.patch","issue_url":"https://api.github.com/repos/sars/appetini-front/issues/98","number":98,"state":"open","locked":false,"title":"share link add portions fix","user":{"login":"7gonchaar7","id":16901624,"avatar_url":"https://avatars.githubusercontent.com/u/16901624?v=3","gravatar_id":"","url":"https://api.github.com/users/7gonchaar7","html_url":"https://github.com/7gonchaar7","followers_url":"https://api.github.com/users/7gonchaar7/followers","following_url":"https://api.github.com/users/7gonchaar7/following{/other_user}","gists_url":"https://api.github.com/users/7gonchaar7/gists{/gist_id}","starred_url":"https://api.github.com/users/7gonchaar7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/7gonchaar7/subscriptions","organizations_url":"https://api.github.com/users/7gonchaar7/orgs","repos_url":"https://api.github.com/users/7gonchaar7/repos","events_url":"https://api.github.com/users/7gonchaar7/events{/privacy}","received_events_url":"https://api.github.com/users/7gonchaar7/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-15T09:27:02Z","updated_at":"2016-08-17T08:40:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"362dc8e613df59408526db1b497e48952e86f52a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sars/appetini-front/pulls/98/commits","review_comments_url":"https://api.github.com/repos/sars/appetini-front/pulls/98/comments","review_comment_url":"https://api.github.com/repos/sars/appetini-front/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sars/appetini-front/issues/98/comments","statuses_url":"https://api.github.com/repos/sars/appetini-front/statuses/818e72176621867b989ecbc3e4a5c2f2e7eec206","head":{"label":"sars:share_link_order","ref":"share_link_order","sha":"818e72176621867b989ecbc3e4a5c2f2e7eec206","user":{"login":"sars","id":226194,"avatar_url":"https://avatars.githubusercontent.com/u/226194?v=3","gravatar_id":"","url":"https://api.github.com/users/sars","html_url":"https://github.com/sars","followers_url":"https://api.github.com/users/sars/followers","following_url":"https://api.github.com/users/sars/following{/other_user}","gists_url":"https://api.github.com/users/sars/gists{/gist_id}","starred_url":"https://api.github.com/users/sars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sars/subscriptions","organizations_url":"https://api.github.com/users/sars/orgs","repos_url":"https://api.github.com/users/sars/repos","events_url":"https://api.github.com/users/sars/events{/privacy}","received_events_url":"https://api.github.com/users/sars/received_events","type":"User","site_admin":false},"repo":{"id":49889071,"name":"appetini-front","full_name":"sars/appetini-front","owner":{"login":"sars","id":226194,"avatar_url":"https://avatars.githubusercontent.com/u/226194?v=3","gravatar_id":"","url":"https://api.github.com/users/sars","html_url":"https://github.com/sars","followers_url":"https://api.github.com/users/sars/followers","following_url":"https://api.github.com/users/sars/following{/other_user}","gists_url":"https://api.github.com/users/sars/gists{/gist_id}","starred_url":"https://api.github.com/users/sars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sars/subscriptions","organizations_url":"https://api.github.com/users/sars/orgs","repos_url":"https://api.github.com/users/sars/repos","events_url":"https://api.github.com/users/sars/events{/privacy}","received_events_url":"https://api.github.com/users/sars/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sars/appetini-front","description":"","fork":false,"url":"https://api.github.com/repos/sars/appetini-front","forks_url":"https://api.github.com/repos/sars/appetini-front/forks","keys_url":"https://api.github.com/repos/sars/appetini-front/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sars/appetini-front/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sars/appetini-front/teams","hooks_url":"https://api.github.com/repos/sars/appetini-front/hooks","issue_events_url":"https://api.github.com/repos/sars/appetini-front/issues/events{/number}","events_url":"https://api.github.com/repos/sars/appetini-front/events","assignees_url":"https://api.github.com/repos/sars/appetini-front/assignees{/user}","branches_url":"https://api.github.com/repos/sars/appetini-front/branches{/branch}","tags_url":"https://api.github.com/repos/sars/appetini-front/tags","blobs_url":"https://api.github.com/repos/sars/appetini-front/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sars/appetini-front/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sars/appetini-front/git/refs{/sha}","trees_url":"https://api.github.com/repos/sars/appetini-front/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sars/appetini-front/statuses/{sha}","languages_url":"https://api.github.com/repos/sars/appetini-front/languages","stargazers_url":"https://api.github.com/repos/sars/appetini-front/stargazers","contributors_url":"https://api.github.com/repos/sars/appetini-front/contributors","subscribers_url":"https://api.github.com/repos/sars/appetini-front/subscribers","subscription_url":"https://api.github.com/repos/sars/appetini-front/subscription","commits_url":"https://api.github.com/repos/sars/appetini-front/commits{/sha}","git_commits_url":"https://api.github.com/repos/sars/appetini-front/git/commits{/sha}","comments_url":"https://api.github.com/repos/sars/appetini-front/comments{/number}","issue_comment_url":"https://api.github.com/repos/sars/appetini-front/issues/comments{/number}","contents_url":"https://api.github.com/repos/sars/appetini-front/contents/{+path}","compare_url":"https://api.github.com/repos/sars/appetini-front/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sars/appetini-front/merges","archive_url":"https://api.github.com/repos/sars/appetini-front/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sars/appetini-front/downloads","issues_url":"https://api.github.com/repos/sars/appetini-front/issues{/number}","pulls_url":"https://api.github.com/repos/sars/appetini-front/pulls{/number}","milestones_url":"https://api.github.com/repos/sars/appetini-front/milestones{/number}","notifications_url":"https://api.github.com/repos/sars/appetini-front/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sars/appetini-front/labels{/name}","releases_url":"https://api.github.com/repos/sars/appetini-front/releases{/id}","deployments_url":"https://api.github.com/repos/sars/appetini-front/deployments","created_at":"2016-01-18T16:26:28Z","updated_at":"2016-07-12T06:33:45Z","pushed_at":"2016-08-17T08:36:56Z","git_url":"git://github.com/sars/appetini-front.git","ssh_url":"git@github.com:sars/appetini-front.git","clone_url":"https://github.com/sars/appetini-front.git","svn_url":"https://github.com/sars/appetini-front","homepage":null,"size":6435,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":5,"default_branch":"master"}},"base":{"label":"sars:master","ref":"master","sha":"929ac879056b767d6cc80ccf15b1546a4941b968","user":{"login":"sars","id":226194,"avatar_url":"https://avatars.githubusercontent.com/u/226194?v=3","gravatar_id":"","url":"https://api.github.com/users/sars","html_url":"https://github.com/sars","followers_url":"https://api.github.com/users/sars/followers","following_url":"https://api.github.com/users/sars/following{/other_user}","gists_url":"https://api.github.com/users/sars/gists{/gist_id}","starred_url":"https://api.github.com/users/sars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sars/subscriptions","organizations_url":"https://api.github.com/users/sars/orgs","repos_url":"https://api.github.com/users/sars/repos","events_url":"https://api.github.com/users/sars/events{/privacy}","received_events_url":"https://api.github.com/users/sars/received_events","type":"User","site_admin":false},"repo":{"id":49889071,"name":"appetini-front","full_name":"sars/appetini-front","owner":{"login":"sars","id":226194,"avatar_url":"https://avatars.githubusercontent.com/u/226194?v=3","gravatar_id":"","url":"https://api.github.com/users/sars","html_url":"https://github.com/sars","followers_url":"https://api.github.com/users/sars/followers","following_url":"https://api.github.com/users/sars/following{/other_user}","gists_url":"https://api.github.com/users/sars/gists{/gist_id}","starred_url":"https://api.github.com/users/sars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sars/subscriptions","organizations_url":"https://api.github.com/users/sars/orgs","repos_url":"https://api.github.com/users/sars/repos","events_url":"https://api.github.com/users/sars/events{/privacy}","received_events_url":"https://api.github.com/users/sars/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sars/appetini-front","description":"","fork":false,"url":"https://api.github.com/repos/sars/appetini-front","forks_url":"https://api.github.com/repos/sars/appetini-front/forks","keys_url":"https://api.github.com/repos/sars/appetini-front/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sars/appetini-front/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sars/appetini-front/teams","hooks_url":"https://api.github.com/repos/sars/appetini-front/hooks","issue_events_url":"https://api.github.com/repos/sars/appetini-front/issues/events{/number}","events_url":"https://api.github.com/repos/sars/appetini-front/events","assignees_url":"https://api.github.com/repos/sars/appetini-front/assignees{/user}","branches_url":"https://api.github.com/repos/sars/appetini-front/branches{/branch}","tags_url":"https://api.github.com/repos/sars/appetini-front/tags","blobs_url":"https://api.github.com/repos/sars/appetini-front/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sars/appetini-front/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sars/appetini-front/git/refs{/sha}","trees_url":"https://api.github.com/repos/sars/appetini-front/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sars/appetini-front/statuses/{sha}","languages_url":"https://api.github.com/repos/sars/appetini-front/languages","stargazers_url":"https://api.github.com/repos/sars/appetini-front/stargazers","contributors_url":"https://api.github.com/repos/sars/appetini-front/contributors","subscribers_url":"https://api.github.com/repos/sars/appetini-front/subscribers","subscription_url":"https://api.github.com/repos/sars/appetini-front/subscription","commits_url":"https://api.github.com/repos/sars/appetini-front/commits{/sha}","git_commits_url":"https://api.github.com/repos/sars/appetini-front/git/commits{/sha}","comments_url":"https://api.github.com/repos/sars/appetini-front/comments{/number}","issue_comment_url":"https://api.github.com/repos/sars/appetini-front/issues/comments{/number}","contents_url":"https://api.github.com/repos/sars/appetini-front/contents/{+path}","compare_url":"https://api.github.com/repos/sars/appetini-front/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sars/appetini-front/merges","archive_url":"https://api.github.com/repos/sars/appetini-front/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sars/appetini-front/downloads","issues_url":"https://api.github.com/repos/sars/appetini-front/issues{/number}","pulls_url":"https://api.github.com/repos/sars/appetini-front/pulls{/number}","milestones_url":"https://api.github.com/repos/sars/appetini-front/milestones{/number}","notifications_url":"https://api.github.com/repos/sars/appetini-front/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sars/appetini-front/labels{/name}","releases_url":"https://api.github.com/repos/sars/appetini-front/releases{/id}","deployments_url":"https://api.github.com/repos/sars/appetini-front/deployments","created_at":"2016-01-18T16:26:28Z","updated_at":"2016-07-12T06:33:45Z","pushed_at":"2016-08-17T08:36:56Z","git_url":"git://github.com/sars/appetini-front.git","ssh_url":"git@github.com:sars/appetini-front.git","clone_url":"https://github.com/sars/appetini-front.git","svn_url":"https://github.com/sars/appetini-front","homepage":null,"size":6435,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":7,"forks":3,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sars/appetini-front/pulls/98"},"html":{"href":"https://github.com/sars/appetini-front/pull/98"},"issue":{"href":"https://api.github.com/repos/sars/appetini-front/issues/98"},"comments":{"href":"https://api.github.com/repos/sars/appetini-front/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/sars/appetini-front/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/sars/appetini-front/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sars/appetini-front/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/sars/appetini-front/statuses/818e72176621867b989ecbc3e4a5c2f2e7eec206"}}}}
{"actor":{"display_login":"sars"}}