{"action":"created","comment":{"url":"https://api.github.com/repos/andela/gondor-rc/pulls/comments/214347989","pull_request_review_id":151372373,"id":214347989,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDM0Nzk4OQ==","diff_hunk":"@@ -0,0 +1,115 @@\n+import React from \"react\";\n+import { Meteor } from \"meteor/meteor\";\n+import PropTypes from \"prop-types\";\n+import { Components, replaceComponent } from \"@reactioncommerce/reaction-components\";\n+import Modal from \"./Modal\";\n+\n+/**\n+ * @summary Displays the order breakdown for each Shop\n+ * @param {Object} props - React PropTypes\n+ * @property {String} shopName - The name of the shop\n+ * @property {Array} items - an array of individual items for this shop\n+ * @property {Function} handleDisplayMedia - A function for displaying product images\n+ * @property {boolean} isProfilePage - Checks if current page is profile page\n+ * @return {Node} React node containing the break down of the order by Shop\n+ */\n+\n+class CancelableCompletedShopOrder extends React.Component {\n+  constructor() {\n+    super();\n+    this.state = {\n+      showCancelModal: false\n+    };\n+\n+    this.toggleCancelModal = this.toggleCancelModal.bind(this);\n+    this.cancelOrder = this.cancelOrder.bind(this);\n+  }\n+\n+  toggleCancelModal(event) {\n+    event.preventDefault();\n+    this.setState({\n+      showCancelModal: !this.state.showCancelModal\n+    });","path":"imports/plugins/custom/order-cancelation/client/components/cancelableCompletedShopOrder.js","position":32,"original_position":32,"commit_id":"6771b17282068acfd4ca111715227414bc18efd7","original_commit_id":"6771b17282068acfd4ca111715227414bc18efd7","user":{"login":"otseobande","id":17123317,"node_id":"MDQ6VXNlcjE3MTIzMzE3","avatar_url":"https://avatars3.githubusercontent.com/u/17123317?v=4","gravatar_id":"","url":"https://api.github.com/users/otseobande","html_url":"https://github.com/otseobande","followers_url":"https://api.github.com/users/otseobande/followers","following_url":"https://api.github.com/users/otseobande/following{/other_user}","gists_url":"https://api.github.com/users/otseobande/gists{/gist_id}","starred_url":"https://api.github.com/users/otseobande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otseobande/subscriptions","organizations_url":"https://api.github.com/users/otseobande/orgs","repos_url":"https://api.github.com/users/otseobande/repos","events_url":"https://api.github.com/users/otseobande/events{/privacy}","received_events_url":"https://api.github.com/users/otseobande/received_events","type":"User","site_admin":false},"body":"Using setState with values that are currently in state like you did with `!this.state.showCancelModal` can be buggy because `setState` is an async method and repeated fast calls to the method may not behave the way we expect it to. To solve this you can use the callback method of setting state instead by passing a callback to the `setState` method this callback receives the previous state as the first argument and should return the new state object removing the need to use `this.state`. Based on this, the  `setState` in the `toggleCancelModal` can be rewritten as \r\n```\r\n this.setState(state => ({ \r\n      showCancelModal: !state.showCancelModal \r\n})\r\n```","created_at":"2018-08-31T13:10:44Z","updated_at":"2018-08-31T13:12:27Z","html_url":"https://github.com/andela/gondor-rc/pull/42#discussion_r214347989","pull_request_url":"https://api.github.com/repos/andela/gondor-rc/pulls/42","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/andela/gondor-rc/pulls/comments/214347989"},"html":{"href":"https://github.com/andela/gondor-rc/pull/42#discussion_r214347989"},"pull_request":{"href":"https://api.github.com/repos/andela/gondor-rc/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/andela/gondor-rc/pulls/42","id":212226430,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyMjI2NDMw","html_url":"https://github.com/andela/gondor-rc/pull/42","diff_url":"https://github.com/andela/gondor-rc/pull/42.diff","patch_url":"https://github.com/andela/gondor-rc/pull/42.patch","issue_url":"https://api.github.com/repos/andela/gondor-rc/issues/42","number":42,"state":"open","locked":false,"title":"#159361810 Customer cancel order","user":{"login":"Stylll","id":13545380,"node_id":"MDQ6VXNlcjEzNTQ1Mzgw","avatar_url":"https://avatars2.githubusercontent.com/u/13545380?v=4","gravatar_id":"","url":"https://api.github.com/users/Stylll","html_url":"https://github.com/Stylll","followers_url":"https://api.github.com/users/Stylll/followers","following_url":"https://api.github.com/users/Stylll/following{/other_user}","gists_url":"https://api.github.com/users/Stylll/gists{/gist_id}","starred_url":"https://api.github.com/users/Stylll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stylll/subscriptions","organizations_url":"https://api.github.com/users/Stylll/orgs","repos_url":"https://api.github.com/users/Stylll/repos","events_url":"https://api.github.com/users/Stylll/events{/privacy}","received_events_url":"https://api.github.com/users/Stylll/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nAdd feature for customer to cancel an order\r\n\r\n#### Description of Task to be completed?\r\n- create cancel order button on order history page\r\n- display a popup confirmation when customer tries to cancel an order\r\n- cancel option should only be available if the orders has not been approved by the vendor\r\n- customers money should be refunded after order has been canceled\r\n\r\n#### How should this be manually tested?\r\n- login as a vendor\r\n- click on the accounts icon on the sidebar\r\n- edit the customers group and enable order access for customer (this enables the customer cancel an order)\r\n- login or create an account as a customer\r\n- order for a product and checkout\r\n- visit the order history page\r\n- click on the cancel order button available at the top of the order details\r\n- click yes in the modal popup to confirm deletion\r\n- an in-app notification will be sent confirming the order has been canceled\r\n\r\n#### Any background context you want to provide?\r\nN/A\r\n\r\n#### What are the relevant pivotal tracker stories?\r\n#159361810\r\n\r\n#### Screenshots or gifs (if appropriate):\r\n![cancel-order-demo](https://user-images.githubusercontent.com/13545380/44882049-a7d4ed00-aca9-11e8-92d8-3fd11ef8b452.gif)\r\n\r\n\r\n#### Questions:","created_at":"2018-08-30T22:17:11Z","updated_at":"2018-08-31T13:12:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c13f006cced9214d5ef1b23496408666cc6c0035","assignee":null,"assignees":[],"requested_reviewers":[{"login":"rovilay","id":27569442,"node_id":"MDQ6VXNlcjI3NTY5NDQy","avatar_url":"https://avatars0.githubusercontent.com/u/27569442?v=4","gravatar_id":"","url":"https://api.github.com/users/rovilay","html_url":"https://github.com/rovilay","followers_url":"https://api.github.com/users/rovilay/followers","following_url":"https://api.github.com/users/rovilay/following{/other_user}","gists_url":"https://api.github.com/users/rovilay/gists{/gist_id}","starred_url":"https://api.github.com/users/rovilay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rovilay/subscriptions","organizations_url":"https://api.github.com/users/rovilay/orgs","repos_url":"https://api.github.com/users/rovilay/repos","events_url":"https://api.github.com/users/rovilay/events{/privacy}","received_events_url":"https://api.github.com/users/rovilay/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/gondor-rc/pulls/42/commits","review_comments_url":"https://api.github.com/repos/andela/gondor-rc/pulls/42/comments","review_comment_url":"https://api.github.com/repos/andela/gondor-rc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/gondor-rc/issues/42/comments","statuses_url":"https://api.github.com/repos/andela/gondor-rc/statuses/6771b17282068acfd4ca111715227414bc18efd7","head":{"label":"andela:feature/159361810/customer-cancel-order","ref":"feature/159361810/customer-cancel-order","sha":"6771b17282068acfd4ca111715227414bc18efd7","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":142571564,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI1NzE1NjQ=","name":"gondor-rc","full_name":"andela/gondor-rc","owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/gondor-rc","description":null,"fork":false,"url":"https://api.github.com/repos/andela/gondor-rc","forks_url":"https://api.github.com/repos/andela/gondor-rc/forks","keys_url":"https://api.github.com/repos/andela/gondor-rc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/gondor-rc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/gondor-rc/teams","hooks_url":"https://api.github.com/repos/andela/gondor-rc/hooks","issue_events_url":"https://api.github.com/repos/andela/gondor-rc/issues/events{/number}","events_url":"https://api.github.com/repos/andela/gondor-rc/events","assignees_url":"https://api.github.com/repos/andela/gondor-rc/assignees{/user}","branches_url":"https://api.github.com/repos/andela/gondor-rc/branches{/branch}","tags_url":"https://api.github.com/repos/andela/gondor-rc/tags","blobs_url":"https://api.github.com/repos/andela/gondor-rc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/gondor-rc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/gondor-rc/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/gondor-rc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/gondor-rc/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/gondor-rc/languages","stargazers_url":"https://api.github.com/repos/andela/gondor-rc/stargazers","contributors_url":"https://api.github.com/repos/andela/gondor-rc/contributors","subscribers_url":"https://api.github.com/repos/andela/gondor-rc/subscribers","subscription_url":"https://api.github.com/repos/andela/gondor-rc/subscription","commits_url":"https://api.github.com/repos/andela/gondor-rc/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/gondor-rc/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/gondor-rc/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/gondor-rc/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/gondor-rc/contents/{+path}","compare_url":"https://api.github.com/repos/andela/gondor-rc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/gondor-rc/merges","archive_url":"https://api.github.com/repos/andela/gondor-rc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/gondor-rc/downloads","issues_url":"https://api.github.com/repos/andela/gondor-rc/issues{/number}","pulls_url":"https://api.github.com/repos/andela/gondor-rc/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/gondor-rc/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/gondor-rc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/gondor-rc/labels{/name}","releases_url":"https://api.github.com/repos/andela/gondor-rc/releases{/id}","deployments_url":"https://api.github.com/repos/andela/gondor-rc/deployments","created_at":"2018-07-27T11:58:49Z","updated_at":"2018-08-30T09:20:40Z","pushed_at":"2018-08-31T09:10:50Z","git_url":"git://github.com/andela/gondor-rc.git","ssh_url":"git@github.com:andela/gondor-rc.git","clone_url":"https://github.com/andela/gondor-rc.git","svn_url":"https://github.com/andela/gondor-rc","homepage":null,"size":44469,"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":2,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"staging"}},"base":{"label":"andela:staging","ref":"staging","sha":"65626e6a456ed8c803e6642a1caf1a9fb0787446","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":142571564,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI1NzE1NjQ=","name":"gondor-rc","full_name":"andela/gondor-rc","owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/gondor-rc","description":null,"fork":false,"url":"https://api.github.com/repos/andela/gondor-rc","forks_url":"https://api.github.com/repos/andela/gondor-rc/forks","keys_url":"https://api.github.com/repos/andela/gondor-rc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/gondor-rc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/gondor-rc/teams","hooks_url":"https://api.github.com/repos/andela/gondor-rc/hooks","issue_events_url":"https://api.github.com/repos/andela/gondor-rc/issues/events{/number}","events_url":"https://api.github.com/repos/andela/gondor-rc/events","assignees_url":"https://api.github.com/repos/andela/gondor-rc/assignees{/user}","branches_url":"https://api.github.com/repos/andela/gondor-rc/branches{/branch}","tags_url":"https://api.github.com/repos/andela/gondor-rc/tags","blobs_url":"https://api.github.com/repos/andela/gondor-rc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/gondor-rc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/gondor-rc/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/gondor-rc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/gondor-rc/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/gondor-rc/languages","stargazers_url":"https://api.github.com/repos/andela/gondor-rc/stargazers","contributors_url":"https://api.github.com/repos/andela/gondor-rc/contributors","subscribers_url":"https://api.github.com/repos/andela/gondor-rc/subscribers","subscription_url":"https://api.github.com/repos/andela/gondor-rc/subscription","commits_url":"https://api.github.com/repos/andela/gondor-rc/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/gondor-rc/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/gondor-rc/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/gondor-rc/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/gondor-rc/contents/{+path}","compare_url":"https://api.github.com/repos/andela/gondor-rc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/gondor-rc/merges","archive_url":"https://api.github.com/repos/andela/gondor-rc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/gondor-rc/downloads","issues_url":"https://api.github.com/repos/andela/gondor-rc/issues{/number}","pulls_url":"https://api.github.com/repos/andela/gondor-rc/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/gondor-rc/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/gondor-rc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/gondor-rc/labels{/name}","releases_url":"https://api.github.com/repos/andela/gondor-rc/releases{/id}","deployments_url":"https://api.github.com/repos/andela/gondor-rc/deployments","created_at":"2018-07-27T11:58:49Z","updated_at":"2018-08-30T09:20:40Z","pushed_at":"2018-08-31T09:10:50Z","git_url":"git://github.com/andela/gondor-rc.git","ssh_url":"git@github.com:andela/gondor-rc.git","clone_url":"https://github.com/andela/gondor-rc.git","svn_url":"https://github.com/andela/gondor-rc","homepage":null,"size":44469,"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":2,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/gondor-rc/pulls/42"},"html":{"href":"https://github.com/andela/gondor-rc/pull/42"},"issue":{"href":"https://api.github.com/repos/andela/gondor-rc/issues/42"},"comments":{"href":"https://api.github.com/repos/andela/gondor-rc/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/gondor-rc/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/gondor-rc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/gondor-rc/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/andela/gondor-rc/statuses/6771b17282068acfd4ca111715227414bc18efd7"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"otseobande"}}