{"action":"created","comment":{"url":"https://api.github.com/repos/Paynless/paynless/pulls/comments/176274690","pull_request_review_id":105948710,"id":176274690,"diff_hunk":"@@ -0,0 +1,127 @@\n+import React, { Component } from 'react';\n+import { Link } from 'react-router-dom';\n+import { db, firebaseAuth } from '../../config';\n+import { withAuth } from 'fireview';\n+import { Tab } from '../customer';\n+import AdminTab from './adminTab';\n+import MenuItem from './menuItem';\n+import CircularProgress from 'material-ui/CircularProgress';\n+\n+class AdminSingleTab extends Component {\n+  state = {\n+    selectedTab: {},\n+    menuItems: [],\n+    isLoaded: false\n+  }\n+\n+  componentDidMount(){\n+    this.listen(this.props);\n+  }\n+\n+  componentWillReceiveProps(props){\n+    this.listen(props);\n+    this.fetchMenuItems(props);\n+  }\n+\n+  componentWillUnmount() {\n+    this.removeListenerTabs && this.removeListenerTabs();\n+  }\n+\n+  async listen(props){\n+    const {user} = props.withAuth;\n+    if(!user) return;\n+    if(this.removeListenerTabs) this.removeListenerTabs();\n+\n+    const  { merchantId } = await db.collection(\"users\").where(\"uid\", \"==\", user.uid).get()\n+    .then(snapshot => {\n+      return snapshot.docs;\n+    })\n+    .then(docs => docs[0].data())\n+\n+    const users = await db.collection(\"users\").get()\n+    .then(snapshot => {\n+      return snapshot.docs;\n+    })\n+    .then(docs => docs.map(doc => doc.data()))\n+\n+    this.removeListenerTabs = db.collection(\"Tabs\").where(\"merchantId\", \"==\", merchantId).where(\"open\", \"==\", true)\n+    .onSnapshot((snapshot) => {\n+      let tabDoc = snapshot.docs.filter(doc => doc.id === props.match.params.tabId)[0]\n+      console.log('tab: ', tabDoc.data());\n+      let tab = tabDoc.data()\n+      let user = users.filter(user => user.uid === tab.uid)[0]\n+      this.setState({selectedTab: Object.assign({}, tab, {user: user}), isLoaded: true})\n+    });\n+\n+\n+  }\n+\n+  async fetchMenuItems(props){\n+    const {user} = props.withAuth;\n+    if(!user) return;\n+\n+    const  { merchantId } = await db.collection(\"users\").where(\"uid\", \"==\", user.uid).get()\n+    .then(snapshot => {\n+      return snapshot.docs;\n+    })\n+    .then(docs => docs[0].data())\n+\n+    const { menu } = await db.collection(\"Merchants\").doc(merchantId).get()\n+    .then(snapshot => {\n+      if(snapshot.exists){\n+        return snapshot.data()\n+      }\n+    })\n+    this.setState({menuItems: menu});\n+  }\n+\n+  handleAdd = (name, price) => {\n+    let currentTab = this.state.selectedTab;\n+    let tabId = this.props.match.params.tabId;\n+    console.log('items: ', currentTab.items)\n+    if(currentTab.items.filter(item => item.name === name).length){\n+      let index = currentTab.items.findIndex(item => item.name === name)\n+      console.log('index: ', index);\n+      currentTab.items[index].quantity++;\n+    } else {\n+      console.log('don\\'t have it');","path":"src/components/admin/adminSingleTab.js","position":87,"original_position":87,"commit_id":"c3379ae13c8d7703d1c42040eb530b37fece9af9","original_commit_id":"c3379ae13c8d7703d1c42040eb530b37fece9af9","user":{"login":"mechmillan","id":25711137,"avatar_url":"https://avatars3.githubusercontent.com/u/25711137?v=4","gravatar_id":"","url":"https://api.github.com/users/mechmillan","html_url":"https://github.com/mechmillan","followers_url":"https://api.github.com/users/mechmillan/followers","following_url":"https://api.github.com/users/mechmillan/following{/other_user}","gists_url":"https://api.github.com/users/mechmillan/gists{/gist_id}","starred_url":"https://api.github.com/users/mechmillan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mechmillan/subscriptions","organizations_url":"https://api.github.com/users/mechmillan/orgs","repos_url":"https://api.github.com/users/mechmillan/repos","events_url":"https://api.github.com/users/mechmillan/events{/privacy}","received_events_url":"https://api.github.com/users/mechmillan/received_events","type":"User","site_admin":false},"body":"remove console logs eventually","created_at":"2018-03-21T23:51:05Z","updated_at":"2018-03-21T23:51:05Z","html_url":"https://github.com/Paynless/paynless/pull/30#discussion_r176274690","pull_request_url":"https://api.github.com/repos/Paynless/paynless/pulls/30","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Paynless/paynless/pulls/comments/176274690"},"html":{"href":"https://github.com/Paynless/paynless/pull/30#discussion_r176274690"},"pull_request":{"href":"https://api.github.com/repos/Paynless/paynless/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/Paynless/paynless/pulls/30","id":176638897,"html_url":"https://github.com/Paynless/paynless/pull/30","diff_url":"https://github.com/Paynless/paynless/pull/30.diff","patch_url":"https://github.com/Paynless/paynless/pull/30.patch","issue_url":"https://api.github.com/repos/Paynless/paynless/issues/30","number":30,"state":"open","locked":false,"title":"Feature: Ability to add items to a tab","user":{"login":"sirmateus88","id":33664840,"avatar_url":"https://avatars3.githubusercontent.com/u/33664840?v=4","gravatar_id":"","url":"https://api.github.com/users/sirmateus88","html_url":"https://github.com/sirmateus88","followers_url":"https://api.github.com/users/sirmateus88/followers","following_url":"https://api.github.com/users/sirmateus88/following{/other_user}","gists_url":"https://api.github.com/users/sirmateus88/gists{/gist_id}","starred_url":"https://api.github.com/users/sirmateus88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirmateus88/subscriptions","organizations_url":"https://api.github.com/users/sirmateus88/orgs","repos_url":"https://api.github.com/users/sirmateus88/repos","events_url":"https://api.github.com/users/sirmateus88/events{/privacy}","received_events_url":"https://api.github.com/users/sirmateus88/received_events","type":"User","site_admin":false},"body":"*Feature:*\r\n- Admins can add any menu items to the tab","created_at":"2018-03-21T23:40:43Z","updated_at":"2018-03-21T23:51:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d521138040f78517d61c97ad9e5ffd2b0890740","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Paynless/paynless/pulls/30/commits","review_comments_url":"https://api.github.com/repos/Paynless/paynless/pulls/30/comments","review_comment_url":"https://api.github.com/repos/Paynless/paynless/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Paynless/paynless/issues/30/comments","statuses_url":"https://api.github.com/repos/Paynless/paynless/statuses/c3379ae13c8d7703d1c42040eb530b37fece9af9","head":{"label":"Paynless:SingleTabView","ref":"SingleTabView","sha":"c3379ae13c8d7703d1c42040eb530b37fece9af9","user":{"login":"Paynless","id":37413460,"avatar_url":"https://avatars3.githubusercontent.com/u/37413460?v=4","gravatar_id":"","url":"https://api.github.com/users/Paynless","html_url":"https://github.com/Paynless","followers_url":"https://api.github.com/users/Paynless/followers","following_url":"https://api.github.com/users/Paynless/following{/other_user}","gists_url":"https://api.github.com/users/Paynless/gists{/gist_id}","starred_url":"https://api.github.com/users/Paynless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paynless/subscriptions","organizations_url":"https://api.github.com/users/Paynless/orgs","repos_url":"https://api.github.com/users/Paynless/repos","events_url":"https://api.github.com/users/Paynless/events{/privacy}","received_events_url":"https://api.github.com/users/Paynless/received_events","type":"Organization","site_admin":false},"repo":{"id":125544779,"name":"paynless","full_name":"Paynless/paynless","owner":{"login":"Paynless","id":37413460,"avatar_url":"https://avatars3.githubusercontent.com/u/37413460?v=4","gravatar_id":"","url":"https://api.github.com/users/Paynless","html_url":"https://github.com/Paynless","followers_url":"https://api.github.com/users/Paynless/followers","following_url":"https://api.github.com/users/Paynless/following{/other_user}","gists_url":"https://api.github.com/users/Paynless/gists{/gist_id}","starred_url":"https://api.github.com/users/Paynless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paynless/subscriptions","organizations_url":"https://api.github.com/users/Paynless/orgs","repos_url":"https://api.github.com/users/Paynless/repos","events_url":"https://api.github.com/users/Paynless/events{/privacy}","received_events_url":"https://api.github.com/users/Paynless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Paynless/paynless","description":"A progressive web application used for quick and seamless check-ins at bars and restaurants.","fork":false,"url":"https://api.github.com/repos/Paynless/paynless","forks_url":"https://api.github.com/repos/Paynless/paynless/forks","keys_url":"https://api.github.com/repos/Paynless/paynless/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Paynless/paynless/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Paynless/paynless/teams","hooks_url":"https://api.github.com/repos/Paynless/paynless/hooks","issue_events_url":"https://api.github.com/repos/Paynless/paynless/issues/events{/number}","events_url":"https://api.github.com/repos/Paynless/paynless/events","assignees_url":"https://api.github.com/repos/Paynless/paynless/assignees{/user}","branches_url":"https://api.github.com/repos/Paynless/paynless/branches{/branch}","tags_url":"https://api.github.com/repos/Paynless/paynless/tags","blobs_url":"https://api.github.com/repos/Paynless/paynless/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Paynless/paynless/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Paynless/paynless/git/refs{/sha}","trees_url":"https://api.github.com/repos/Paynless/paynless/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Paynless/paynless/statuses/{sha}","languages_url":"https://api.github.com/repos/Paynless/paynless/languages","stargazers_url":"https://api.github.com/repos/Paynless/paynless/stargazers","contributors_url":"https://api.github.com/repos/Paynless/paynless/contributors","subscribers_url":"https://api.github.com/repos/Paynless/paynless/subscribers","subscription_url":"https://api.github.com/repos/Paynless/paynless/subscription","commits_url":"https://api.github.com/repos/Paynless/paynless/commits{/sha}","git_commits_url":"https://api.github.com/repos/Paynless/paynless/git/commits{/sha}","comments_url":"https://api.github.com/repos/Paynless/paynless/comments{/number}","issue_comment_url":"https://api.github.com/repos/Paynless/paynless/issues/comments{/number}","contents_url":"https://api.github.com/repos/Paynless/paynless/contents/{+path}","compare_url":"https://api.github.com/repos/Paynless/paynless/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Paynless/paynless/merges","archive_url":"https://api.github.com/repos/Paynless/paynless/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Paynless/paynless/downloads","issues_url":"https://api.github.com/repos/Paynless/paynless/issues{/number}","pulls_url":"https://api.github.com/repos/Paynless/paynless/pulls{/number}","milestones_url":"https://api.github.com/repos/Paynless/paynless/milestones{/number}","notifications_url":"https://api.github.com/repos/Paynless/paynless/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Paynless/paynless/labels{/name}","releases_url":"https://api.github.com/repos/Paynless/paynless/releases{/id}","deployments_url":"https://api.github.com/repos/Paynless/paynless/deployments","created_at":"2018-03-16T16:51:02Z","updated_at":"2018-03-21T22:54:49Z","pushed_at":"2018-03-21T23:40:43Z","git_url":"git://github.com/Paynless/paynless.git","ssh_url":"git@github.com:Paynless/paynless.git","clone_url":"https://github.com/Paynless/paynless.git","svn_url":"https://github.com/Paynless/paynless","homepage":"https://www.paynless.co","size":356,"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":13,"license":null,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"Paynless:master","ref":"master","sha":"6a1a705eda1ec5f373d2c54f4732281a1c8e7184","user":{"login":"Paynless","id":37413460,"avatar_url":"https://avatars3.githubusercontent.com/u/37413460?v=4","gravatar_id":"","url":"https://api.github.com/users/Paynless","html_url":"https://github.com/Paynless","followers_url":"https://api.github.com/users/Paynless/followers","following_url":"https://api.github.com/users/Paynless/following{/other_user}","gists_url":"https://api.github.com/users/Paynless/gists{/gist_id}","starred_url":"https://api.github.com/users/Paynless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paynless/subscriptions","organizations_url":"https://api.github.com/users/Paynless/orgs","repos_url":"https://api.github.com/users/Paynless/repos","events_url":"https://api.github.com/users/Paynless/events{/privacy}","received_events_url":"https://api.github.com/users/Paynless/received_events","type":"Organization","site_admin":false},"repo":{"id":125544779,"name":"paynless","full_name":"Paynless/paynless","owner":{"login":"Paynless","id":37413460,"avatar_url":"https://avatars3.githubusercontent.com/u/37413460?v=4","gravatar_id":"","url":"https://api.github.com/users/Paynless","html_url":"https://github.com/Paynless","followers_url":"https://api.github.com/users/Paynless/followers","following_url":"https://api.github.com/users/Paynless/following{/other_user}","gists_url":"https://api.github.com/users/Paynless/gists{/gist_id}","starred_url":"https://api.github.com/users/Paynless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paynless/subscriptions","organizations_url":"https://api.github.com/users/Paynless/orgs","repos_url":"https://api.github.com/users/Paynless/repos","events_url":"https://api.github.com/users/Paynless/events{/privacy}","received_events_url":"https://api.github.com/users/Paynless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Paynless/paynless","description":"A progressive web application used for quick and seamless check-ins at bars and restaurants.","fork":false,"url":"https://api.github.com/repos/Paynless/paynless","forks_url":"https://api.github.com/repos/Paynless/paynless/forks","keys_url":"https://api.github.com/repos/Paynless/paynless/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Paynless/paynless/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Paynless/paynless/teams","hooks_url":"https://api.github.com/repos/Paynless/paynless/hooks","issue_events_url":"https://api.github.com/repos/Paynless/paynless/issues/events{/number}","events_url":"https://api.github.com/repos/Paynless/paynless/events","assignees_url":"https://api.github.com/repos/Paynless/paynless/assignees{/user}","branches_url":"https://api.github.com/repos/Paynless/paynless/branches{/branch}","tags_url":"https://api.github.com/repos/Paynless/paynless/tags","blobs_url":"https://api.github.com/repos/Paynless/paynless/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Paynless/paynless/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Paynless/paynless/git/refs{/sha}","trees_url":"https://api.github.com/repos/Paynless/paynless/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Paynless/paynless/statuses/{sha}","languages_url":"https://api.github.com/repos/Paynless/paynless/languages","stargazers_url":"https://api.github.com/repos/Paynless/paynless/stargazers","contributors_url":"https://api.github.com/repos/Paynless/paynless/contributors","subscribers_url":"https://api.github.com/repos/Paynless/paynless/subscribers","subscription_url":"https://api.github.com/repos/Paynless/paynless/subscription","commits_url":"https://api.github.com/repos/Paynless/paynless/commits{/sha}","git_commits_url":"https://api.github.com/repos/Paynless/paynless/git/commits{/sha}","comments_url":"https://api.github.com/repos/Paynless/paynless/comments{/number}","issue_comment_url":"https://api.github.com/repos/Paynless/paynless/issues/comments{/number}","contents_url":"https://api.github.com/repos/Paynless/paynless/contents/{+path}","compare_url":"https://api.github.com/repos/Paynless/paynless/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Paynless/paynless/merges","archive_url":"https://api.github.com/repos/Paynless/paynless/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Paynless/paynless/downloads","issues_url":"https://api.github.com/repos/Paynless/paynless/issues{/number}","pulls_url":"https://api.github.com/repos/Paynless/paynless/pulls{/number}","milestones_url":"https://api.github.com/repos/Paynless/paynless/milestones{/number}","notifications_url":"https://api.github.com/repos/Paynless/paynless/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Paynless/paynless/labels{/name}","releases_url":"https://api.github.com/repos/Paynless/paynless/releases{/id}","deployments_url":"https://api.github.com/repos/Paynless/paynless/deployments","created_at":"2018-03-16T16:51:02Z","updated_at":"2018-03-21T22:54:49Z","pushed_at":"2018-03-21T23:40:43Z","git_url":"git://github.com/Paynless/paynless.git","ssh_url":"git@github.com:Paynless/paynless.git","clone_url":"https://github.com/Paynless/paynless.git","svn_url":"https://github.com/Paynless/paynless","homepage":"https://www.paynless.co","size":356,"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":13,"license":null,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Paynless/paynless/pulls/30"},"html":{"href":"https://github.com/Paynless/paynless/pull/30"},"issue":{"href":"https://api.github.com/repos/Paynless/paynless/issues/30"},"comments":{"href":"https://api.github.com/repos/Paynless/paynless/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/Paynless/paynless/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/Paynless/paynless/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Paynless/paynless/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/Paynless/paynless/statuses/c3379ae13c8d7703d1c42040eb530b37fece9af9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mechmillan"}}