{"action":"created","comment":{"url":"https://api.github.com/repos/sanyco86/tn_shop/pulls/comments/205854177","pull_request_review_id":141210360,"id":205854177,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTg1NDE3Nw==","diff_hunk":"@@ -1,8 +1,121 @@\n-import React, { Component } from 'react';\n-import CatalogPage from './containers/CatalogPage'\n+import React, {Component, Fragment} from 'react';\n+import axios from 'axios';\n+\n+import styles from './styles.css'\n+\n+import CartTotalContext from './CartTotalContext'\n+\n+import Cart     from './components/Cart';\n+import Products from './components/Products';\n \n export default class App extends Component {\n+  state = {\n+    products: [],\n+    cart: {\n+      entries:     [],\n+      totalAmount: 0,\n+      totalItems:  0\n+    },\n+    quantity: 1\n+  };\n+\n+  getProducts(){\n+    const url = 'products.json';\n+\n+    axios.get(url)\n+    .then(response => {\n+      this.setState({ products : response.data })\n+    })\n+  }\n+\n+  componentWillMount(){\n+    this.getProducts();\n+  }\n+\n+  handleAddToCart = (product) => {\n+    let entries    = this.state.cart.entries;\n+    let productID  = product.id;\n+    let productQty = product.quantity;\n+\n+    if(this.checkProduct(productID)){\n+      let index = entries.findIndex((x => x.id === productID));\n+\n+      entries[index].quantity = Number(entries[index].quantity) + Number(productQty);\n+    } else {\n+      entries.push(product);\n+    }\n+\n+    this.setState({ cart: {entries: entries} });\n+\n+    setTimeout(() => {\n+      this.setState({ quantity: 1 });\n+    }, 1000);\n+\n+    this.sumTotal();\n+  };\n+\n+  handleRemoveProduct = (id, e) => {\n+    let entries = this.state.cart.entries;\n+    let index = entries.findIndex((x => x.id === id));\n+    entries.splice(index, 1);\n+    this.setState({ cart: {entries: entries} });\n+    this.sumTotal();\n+    e.preventDefault();","path":"src/App.js","position":65,"original_position":65,"commit_id":"d78e62453a1f9bb8143d5c9b6246c942a9abb1f1","original_commit_id":"d78e62453a1f9bb8143d5c9b6246c942a9abb1f1","user":{"login":"index01d","id":236657,"node_id":"MDQ6VXNlcjIzNjY1Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/236657?v=4","gravatar_id":"","url":"https://api.github.com/users/index01d","html_url":"https://github.com/index01d","followers_url":"https://api.github.com/users/index01d/followers","following_url":"https://api.github.com/users/index01d/following{/other_user}","gists_url":"https://api.github.com/users/index01d/gists{/gist_id}","starred_url":"https://api.github.com/users/index01d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/index01d/subscriptions","organizations_url":"https://api.github.com/users/index01d/orgs","repos_url":"https://api.github.com/users/index01d/repos","events_url":"https://api.github.com/users/index01d/events{/privacy}","received_events_url":"https://api.github.com/users/index01d/received_events","type":"User","site_admin":false},"body":"здесь быть не должно","created_at":"2018-07-27T18:00:08Z","updated_at":"2018-07-27T18:14:03Z","html_url":"https://github.com/sanyco86/tn_shop/pull/3#discussion_r205854177","pull_request_url":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/sanyco86/tn_shop/pulls/comments/205854177"},"html":{"href":"https://github.com/sanyco86/tn_shop/pull/3#discussion_r205854177"},"pull_request":{"href":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3","id":203788388,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzNzg4Mzg4","html_url":"https://github.com/sanyco86/tn_shop/pull/3","diff_url":"https://github.com/sanyco86/tn_shop/pull/3.diff","patch_url":"https://github.com/sanyco86/tn_shop/pull/3.patch","issue_url":"https://api.github.com/repos/sanyco86/tn_shop/issues/3","number":3,"state":"open","locked":false,"title":"Lesson-03","user":{"login":"sanyco86","id":5435938,"node_id":"MDQ6VXNlcjU0MzU5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/5435938?v=4","gravatar_id":"","url":"https://api.github.com/users/sanyco86","html_url":"https://github.com/sanyco86","followers_url":"https://api.github.com/users/sanyco86/followers","following_url":"https://api.github.com/users/sanyco86/following{/other_user}","gists_url":"https://api.github.com/users/sanyco86/gists{/gist_id}","starred_url":"https://api.github.com/users/sanyco86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanyco86/subscriptions","organizations_url":"https://api.github.com/users/sanyco86/orgs","repos_url":"https://api.github.com/users/sanyco86/repos","events_url":"https://api.github.com/users/sanyco86/events{/privacy}","received_events_url":"https://api.github.com/users/sanyco86/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-25T10:15:23Z","updated_at":"2018-07-27T18:14:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddbb19196c0e00df7db885f0ac1398bf2ff669d8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3/commits","review_comments_url":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3/comments","review_comment_url":"https://api.github.com/repos/sanyco86/tn_shop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sanyco86/tn_shop/issues/3/comments","statuses_url":"https://api.github.com/repos/sanyco86/tn_shop/statuses/d78e62453a1f9bb8143d5c9b6246c942a9abb1f1","head":{"label":"sanyco86:lesson-03","ref":"lesson-03","sha":"d78e62453a1f9bb8143d5c9b6246c942a9abb1f1","user":{"login":"sanyco86","id":5435938,"node_id":"MDQ6VXNlcjU0MzU5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/5435938?v=4","gravatar_id":"","url":"https://api.github.com/users/sanyco86","html_url":"https://github.com/sanyco86","followers_url":"https://api.github.com/users/sanyco86/followers","following_url":"https://api.github.com/users/sanyco86/following{/other_user}","gists_url":"https://api.github.com/users/sanyco86/gists{/gist_id}","starred_url":"https://api.github.com/users/sanyco86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanyco86/subscriptions","organizations_url":"https://api.github.com/users/sanyco86/orgs","repos_url":"https://api.github.com/users/sanyco86/repos","events_url":"https://api.github.com/users/sanyco86/events{/privacy}","received_events_url":"https://api.github.com/users/sanyco86/received_events","type":"User","site_admin":false},"repo":{"id":140543360,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA1NDMzNjA=","name":"tn_shop","full_name":"sanyco86/tn_shop","owner":{"login":"sanyco86","id":5435938,"node_id":"MDQ6VXNlcjU0MzU5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/5435938?v=4","gravatar_id":"","url":"https://api.github.com/users/sanyco86","html_url":"https://github.com/sanyco86","followers_url":"https://api.github.com/users/sanyco86/followers","following_url":"https://api.github.com/users/sanyco86/following{/other_user}","gists_url":"https://api.github.com/users/sanyco86/gists{/gist_id}","starred_url":"https://api.github.com/users/sanyco86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanyco86/subscriptions","organizations_url":"https://api.github.com/users/sanyco86/orgs","repos_url":"https://api.github.com/users/sanyco86/repos","events_url":"https://api.github.com/users/sanyco86/events{/privacy}","received_events_url":"https://api.github.com/users/sanyco86/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sanyco86/tn_shop","description":null,"fork":false,"url":"https://api.github.com/repos/sanyco86/tn_shop","forks_url":"https://api.github.com/repos/sanyco86/tn_shop/forks","keys_url":"https://api.github.com/repos/sanyco86/tn_shop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sanyco86/tn_shop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sanyco86/tn_shop/teams","hooks_url":"https://api.github.com/repos/sanyco86/tn_shop/hooks","issue_events_url":"https://api.github.com/repos/sanyco86/tn_shop/issues/events{/number}","events_url":"https://api.github.com/repos/sanyco86/tn_shop/events","assignees_url":"https://api.github.com/repos/sanyco86/tn_shop/assignees{/user}","branches_url":"https://api.github.com/repos/sanyco86/tn_shop/branches{/branch}","tags_url":"https://api.github.com/repos/sanyco86/tn_shop/tags","blobs_url":"https://api.github.com/repos/sanyco86/tn_shop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sanyco86/tn_shop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sanyco86/tn_shop/git/refs{/sha}","trees_url":"https://api.github.com/repos/sanyco86/tn_shop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sanyco86/tn_shop/statuses/{sha}","languages_url":"https://api.github.com/repos/sanyco86/tn_shop/languages","stargazers_url":"https://api.github.com/repos/sanyco86/tn_shop/stargazers","contributors_url":"https://api.github.com/repos/sanyco86/tn_shop/contributors","subscribers_url":"https://api.github.com/repos/sanyco86/tn_shop/subscribers","subscription_url":"https://api.github.com/repos/sanyco86/tn_shop/subscription","commits_url":"https://api.github.com/repos/sanyco86/tn_shop/commits{/sha}","git_commits_url":"https://api.github.com/repos/sanyco86/tn_shop/git/commits{/sha}","comments_url":"https://api.github.com/repos/sanyco86/tn_shop/comments{/number}","issue_comment_url":"https://api.github.com/repos/sanyco86/tn_shop/issues/comments{/number}","contents_url":"https://api.github.com/repos/sanyco86/tn_shop/contents/{+path}","compare_url":"https://api.github.com/repos/sanyco86/tn_shop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sanyco86/tn_shop/merges","archive_url":"https://api.github.com/repos/sanyco86/tn_shop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sanyco86/tn_shop/downloads","issues_url":"https://api.github.com/repos/sanyco86/tn_shop/issues{/number}","pulls_url":"https://api.github.com/repos/sanyco86/tn_shop/pulls{/number}","milestones_url":"https://api.github.com/repos/sanyco86/tn_shop/milestones{/number}","notifications_url":"https://api.github.com/repos/sanyco86/tn_shop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sanyco86/tn_shop/labels{/name}","releases_url":"https://api.github.com/repos/sanyco86/tn_shop/releases{/id}","deployments_url":"https://api.github.com/repos/sanyco86/tn_shop/deployments","created_at":"2018-07-11T08:13:35Z","updated_at":"2018-07-19T08:10:30Z","pushed_at":"2018-07-27T17:11:57Z","git_url":"git://github.com/sanyco86/tn_shop.git","ssh_url":"git@github.com:sanyco86/tn_shop.git","clone_url":"https://github.com/sanyco86/tn_shop.git","svn_url":"https://github.com/sanyco86/tn_shop","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"sanyco86:master","ref":"master","sha":"4b9da252d853e513409892f3240ef96a7a9dd3a8","user":{"login":"sanyco86","id":5435938,"node_id":"MDQ6VXNlcjU0MzU5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/5435938?v=4","gravatar_id":"","url":"https://api.github.com/users/sanyco86","html_url":"https://github.com/sanyco86","followers_url":"https://api.github.com/users/sanyco86/followers","following_url":"https://api.github.com/users/sanyco86/following{/other_user}","gists_url":"https://api.github.com/users/sanyco86/gists{/gist_id}","starred_url":"https://api.github.com/users/sanyco86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanyco86/subscriptions","organizations_url":"https://api.github.com/users/sanyco86/orgs","repos_url":"https://api.github.com/users/sanyco86/repos","events_url":"https://api.github.com/users/sanyco86/events{/privacy}","received_events_url":"https://api.github.com/users/sanyco86/received_events","type":"User","site_admin":false},"repo":{"id":140543360,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA1NDMzNjA=","name":"tn_shop","full_name":"sanyco86/tn_shop","owner":{"login":"sanyco86","id":5435938,"node_id":"MDQ6VXNlcjU0MzU5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/5435938?v=4","gravatar_id":"","url":"https://api.github.com/users/sanyco86","html_url":"https://github.com/sanyco86","followers_url":"https://api.github.com/users/sanyco86/followers","following_url":"https://api.github.com/users/sanyco86/following{/other_user}","gists_url":"https://api.github.com/users/sanyco86/gists{/gist_id}","starred_url":"https://api.github.com/users/sanyco86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanyco86/subscriptions","organizations_url":"https://api.github.com/users/sanyco86/orgs","repos_url":"https://api.github.com/users/sanyco86/repos","events_url":"https://api.github.com/users/sanyco86/events{/privacy}","received_events_url":"https://api.github.com/users/sanyco86/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sanyco86/tn_shop","description":null,"fork":false,"url":"https://api.github.com/repos/sanyco86/tn_shop","forks_url":"https://api.github.com/repos/sanyco86/tn_shop/forks","keys_url":"https://api.github.com/repos/sanyco86/tn_shop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sanyco86/tn_shop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sanyco86/tn_shop/teams","hooks_url":"https://api.github.com/repos/sanyco86/tn_shop/hooks","issue_events_url":"https://api.github.com/repos/sanyco86/tn_shop/issues/events{/number}","events_url":"https://api.github.com/repos/sanyco86/tn_shop/events","assignees_url":"https://api.github.com/repos/sanyco86/tn_shop/assignees{/user}","branches_url":"https://api.github.com/repos/sanyco86/tn_shop/branches{/branch}","tags_url":"https://api.github.com/repos/sanyco86/tn_shop/tags","blobs_url":"https://api.github.com/repos/sanyco86/tn_shop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sanyco86/tn_shop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sanyco86/tn_shop/git/refs{/sha}","trees_url":"https://api.github.com/repos/sanyco86/tn_shop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sanyco86/tn_shop/statuses/{sha}","languages_url":"https://api.github.com/repos/sanyco86/tn_shop/languages","stargazers_url":"https://api.github.com/repos/sanyco86/tn_shop/stargazers","contributors_url":"https://api.github.com/repos/sanyco86/tn_shop/contributors","subscribers_url":"https://api.github.com/repos/sanyco86/tn_shop/subscribers","subscription_url":"https://api.github.com/repos/sanyco86/tn_shop/subscription","commits_url":"https://api.github.com/repos/sanyco86/tn_shop/commits{/sha}","git_commits_url":"https://api.github.com/repos/sanyco86/tn_shop/git/commits{/sha}","comments_url":"https://api.github.com/repos/sanyco86/tn_shop/comments{/number}","issue_comment_url":"https://api.github.com/repos/sanyco86/tn_shop/issues/comments{/number}","contents_url":"https://api.github.com/repos/sanyco86/tn_shop/contents/{+path}","compare_url":"https://api.github.com/repos/sanyco86/tn_shop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sanyco86/tn_shop/merges","archive_url":"https://api.github.com/repos/sanyco86/tn_shop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sanyco86/tn_shop/downloads","issues_url":"https://api.github.com/repos/sanyco86/tn_shop/issues{/number}","pulls_url":"https://api.github.com/repos/sanyco86/tn_shop/pulls{/number}","milestones_url":"https://api.github.com/repos/sanyco86/tn_shop/milestones{/number}","notifications_url":"https://api.github.com/repos/sanyco86/tn_shop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sanyco86/tn_shop/labels{/name}","releases_url":"https://api.github.com/repos/sanyco86/tn_shop/releases{/id}","deployments_url":"https://api.github.com/repos/sanyco86/tn_shop/deployments","created_at":"2018-07-11T08:13:35Z","updated_at":"2018-07-19T08:10:30Z","pushed_at":"2018-07-27T17:11:57Z","git_url":"git://github.com/sanyco86/tn_shop.git","ssh_url":"git@github.com:sanyco86/tn_shop.git","clone_url":"https://github.com/sanyco86/tn_shop.git","svn_url":"https://github.com/sanyco86/tn_shop","homepage":null,"size":12,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3"},"html":{"href":"https://github.com/sanyco86/tn_shop/pull/3"},"issue":{"href":"https://api.github.com/repos/sanyco86/tn_shop/issues/3"},"comments":{"href":"https://api.github.com/repos/sanyco86/tn_shop/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/sanyco86/tn_shop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sanyco86/tn_shop/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/sanyco86/tn_shop/statuses/d78e62453a1f9bb8143d5c9b6246c942a9abb1f1"}},"author_association":"OWNER"}}
{"actor":{"display_login":"index01d"}}