{"action":"created","comment":{"url":"https://api.github.com/repos/pagarme/pilot/pulls/comments/151752059","pull_request_review_id":77486049,"id":151752059,"diff_hunk":"@@ -0,0 +1,336 @@\n+import React from 'react'\n+import PropTypes from 'prop-types'\n+import {\n+  __,\n+  F,\n+  T,\n+  always,\n+  allPass,\n+  anyPass,\n+  and,\n+  inc,\n+  dec,\n+  cond,\n+  ifElse,\n+  pipe,\n+  clamp,\n+  equals,\n+  isNil,\n+  isEmpty,\n+  find,\n+  lte,\n+  lt,\n+  gt,\n+  gte,\n+  is,\n+  prop,\n+  objOf,\n+  unless,\n+  when,\n+  toString,\n+  length,\n+  tail,\n+  path as rPath,\n+  head,\n+  propSatisfies,\n+  complement,\n+} from 'ramda'\n+import classNames from 'classnames'\n+\n+import ArrowLeft from 'react-icons/lib/md/keyboard-arrow-left'\n+import ArrowRight from 'react-icons/lib/md/keyboard-arrow-right'\n+\n+import style from './style.css'\n+\n+const convertToNumber = unless(anyPass([isNil, isEmpty]), Number)\n+\n+const createState = pipe(\n+  convertToNumber,\n+  objOf('inputPage')\n+)\n+\n+const preventInvalidKeys = (event) => {\n+  const notAllowedKeys = ['e', 'E', '-', '+', '.', ',']\n+  const isNotAllowed = pipe(equals, find(__, notAllowedKeys))\n+  if (isNotAllowed(event.key)) {\n+    event.preventDefault()\n+  }\n+}\n+\n+class Pagination extends React.Component {\n+  constructor (props) {\n+    super(props)\n+\n+    this.state = {\n+      inputPage: null,\n+    }\n+\n+    this.onInputChange = this.onInputChange.bind(this)\n+    this.getCurrentPage = this.getCurrentPage.bind(this)\n+    this.goTo = this.goTo.bind(this)\n+    this.submitInput = this.submitInput.bind(this)\n+    this.calculateInputValue = this.calculateInputValue.bind(this)\n+    this.disableButton = this.disableButton.bind(this)\n+  }\n+\n+  onInputChange (event) {\n+    event.preventDefault()\n+\n+    const {\n+      totalPages,\n+      onError,\n+    } = this.props\n+\n+    const { value: newPage } = event.target\n+    const getLength = pipe(toString, length)\n+\n+    const hasValidLength = pipe(\n+      length,\n+      gte(getLength(totalPages))\n+    )\n+\n+    const startsWithZero = allPass([\n+      pipe(length, equals(2)),\n+      pipe(head, equals('0')),\n+    ])\n+\n+    const hasError = pipe(\n+      anyPass([\n+        gt(0),\n+        lt(totalPages),\n+      ]),\n+      and(newPage)\n+    )\n+\n+    const tailIfNeeded = pipe(\n+      when(startsWithZero, tail),\n+      createState\n+    )\n+\n+    const handleError = pipe(\n+      Number,\n+      hasError,\n+      onError\n+    )\n+\n+    if (hasValidLength(newPage)) {\n+      this.setState(tailIfNeeded(newPage))\n+      handleError(newPage)\n+    }\n+  }\n+\n+  getCurrentPage () {\n+    const {\n+      totalPages,\n+      onPageChange,\n+      currentPage,\n+      onError,\n+    } = this.props\n+\n+    const { inputPage } = this.state\n+\n+    this.setState({\n+      inputPage: null,\n+    })\n+\n+    const isValidCurrentPage = allPass([\n+      propSatisfies(is(Number), 'currentPage'),\n+      propSatisfies(complement(is(Number)), 'inputPage'),\n+    ])\n+\n+    const isValidInput = pipe(\n+      prop('inputPage'),\n+      anyPass([\n+        lt(totalPages),\n+        gt(1),\n+      ])\n+    )\n+\n+    const getCorrectPage = cond([\n+      [isValidCurrentPage, always(currentPage)],\n+      [isValidInput, always(currentPage)],\n+      [T, always(inputPage)],\n+    ])\n+\n+    onPageChange(getCorrectPage({ currentPage, inputPage }))\n+\n+    onError(false)\n+  }\n+\n+  goTo (path) {\n+    const {\n+      currentPage,\n+      totalPages,\n+      onPageChange,\n+    } = this.props\n+\n+    const range = clamp(1, totalPages)\n+\n+    const calculateNewPage = ifElse(\n+      equals('next'),\n+      always(inc(currentPage)),\n+      always(dec(currentPage))\n+    )\n+\n+    const newPage = pipe(\n+      calculateNewPage,\n+      range\n+    )\n+\n+    onPageChange(newPage(path))\n+  }\n+\n+  calculateInputValue () {\n+    const { inputPage } = this.state\n+    const { currentPage } = this.props\n+\n+    const calculateValue = ifElse(\n+      equals(''),\n+      always(''),\n+      when(anyPass([isNil, isEmpty]), always(currentPage))","path":"webapp/src/components/Toolbar/Pagination/index.js","position":190,"original_position":190,"commit_id":"604f428e3d8318ba512c350ce0fcaef53f6b5aed","original_commit_id":"604f428e3d8318ba512c350ce0fcaef53f6b5aed","user":{"login":"darakeon","id":16213361,"avatar_url":"https://avatars1.githubusercontent.com/u/16213361?v=4","gravatar_id":"","url":"https://api.github.com/users/darakeon","html_url":"https://github.com/darakeon","followers_url":"https://api.github.com/users/darakeon/followers","following_url":"https://api.github.com/users/darakeon/following{/other_user}","gists_url":"https://api.github.com/users/darakeon/gists{/gist_id}","starred_url":"https://api.github.com/users/darakeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darakeon/subscriptions","organizations_url":"https://api.github.com/users/darakeon/orgs","repos_url":"https://api.github.com/users/darakeon/repos","events_url":"https://api.github.com/users/darakeon/events{/privacy}","received_events_url":"https://api.github.com/users/darakeon/received_events","type":"User","site_admin":false},"body":"Maybe it should be break in lines too","created_at":"2017-11-17T18:09:48Z","updated_at":"2017-11-17T18:22:21Z","html_url":"https://github.com/pagarme/pilot/pull/310#discussion_r151752059","pull_request_url":"https://api.github.com/repos/pagarme/pilot/pulls/310","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pagarme/pilot/pulls/comments/151752059"},"html":{"href":"https://github.com/pagarme/pilot/pull/310#discussion_r151752059"},"pull_request":{"href":"https://api.github.com/repos/pagarme/pilot/pulls/310"}}},"pull_request":{"url":"https://api.github.com/repos/pagarme/pilot/pulls/310","id":149067913,"html_url":"https://github.com/pagarme/pilot/pull/310","diff_url":"https://github.com/pagarme/pilot/pull/310.diff","patch_url":"https://github.com/pagarme/pilot/pull/310.patch","issue_url":"https://api.github.com/repos/pagarme/pilot/issues/310","number":310,"state":"open","locked":false,"title":"pagination: add basic component","user":{"login":"LeoNero","id":7756101,"avatar_url":"https://avatars1.githubusercontent.com/u/7756101?v=4","gravatar_id":"","url":"https://api.github.com/users/LeoNero","html_url":"https://github.com/LeoNero","followers_url":"https://api.github.com/users/LeoNero/followers","following_url":"https://api.github.com/users/LeoNero/following{/other_user}","gists_url":"https://api.github.com/users/LeoNero/gists{/gist_id}","starred_url":"https://api.github.com/users/LeoNero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeoNero/subscriptions","organizations_url":"https://api.github.com/users/LeoNero/orgs","repos_url":"https://api.github.com/users/LeoNero/repos","events_url":"https://api.github.com/users/LeoNero/events{/privacy}","received_events_url":"https://api.github.com/users/LeoNero/received_events","type":"User","site_admin":false},"body":"Closes #305 ","created_at":"2017-10-26T23:16:52Z","updated_at":"2017-11-17T18:22:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef6e8beecce43271181ab394fac2289ee57226ec","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/pagarme/pilot/milestones/21","html_url":"https://github.com/pagarme/pilot/milestone/21","labels_url":"https://api.github.com/repos/pagarme/pilot/milestones/21/labels","id":2849540,"number":21,"title":"Transactions","description":"","creator":{"login":"felquis","id":736728,"avatar_url":"https://avatars0.githubusercontent.com/u/736728?v=4","gravatar_id":"","url":"https://api.github.com/users/felquis","html_url":"https://github.com/felquis","followers_url":"https://api.github.com/users/felquis/followers","following_url":"https://api.github.com/users/felquis/following{/other_user}","gists_url":"https://api.github.com/users/felquis/gists{/gist_id}","starred_url":"https://api.github.com/users/felquis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felquis/subscriptions","organizations_url":"https://api.github.com/users/felquis/orgs","repos_url":"https://api.github.com/users/felquis/repos","events_url":"https://api.github.com/users/felquis/events{/privacy}","received_events_url":"https://api.github.com/users/felquis/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":19,"state":"open","created_at":"2017-10-19T02:30:47Z","updated_at":"2017-11-17T17:12:10Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/pagarme/pilot/pulls/310/commits","review_comments_url":"https://api.github.com/repos/pagarme/pilot/pulls/310/comments","review_comment_url":"https://api.github.com/repos/pagarme/pilot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pagarme/pilot/issues/310/comments","statuses_url":"https://api.github.com/repos/pagarme/pilot/statuses/604f428e3d8318ba512c350ce0fcaef53f6b5aed","head":{"label":"pagarme:add/pagination","ref":"add/pagination","sha":"604f428e3d8318ba512c350ce0fcaef53f6b5aed","user":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars2.githubusercontent.com/u/3846050?v=4","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"repo":{"id":96902421,"name":"pilot","full_name":"pagarme/pilot","owner":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars2.githubusercontent.com/u/3846050?v=4","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pagarme/pilot","description":":airplane: The next iteration of Pagar.me's Dashboard","fork":false,"url":"https://api.github.com/repos/pagarme/pilot","forks_url":"https://api.github.com/repos/pagarme/pilot/forks","keys_url":"https://api.github.com/repos/pagarme/pilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pagarme/pilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pagarme/pilot/teams","hooks_url":"https://api.github.com/repos/pagarme/pilot/hooks","issue_events_url":"https://api.github.com/repos/pagarme/pilot/issues/events{/number}","events_url":"https://api.github.com/repos/pagarme/pilot/events","assignees_url":"https://api.github.com/repos/pagarme/pilot/assignees{/user}","branches_url":"https://api.github.com/repos/pagarme/pilot/branches{/branch}","tags_url":"https://api.github.com/repos/pagarme/pilot/tags","blobs_url":"https://api.github.com/repos/pagarme/pilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pagarme/pilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pagarme/pilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/pagarme/pilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pagarme/pilot/statuses/{sha}","languages_url":"https://api.github.com/repos/pagarme/pilot/languages","stargazers_url":"https://api.github.com/repos/pagarme/pilot/stargazers","contributors_url":"https://api.github.com/repos/pagarme/pilot/contributors","subscribers_url":"https://api.github.com/repos/pagarme/pilot/subscribers","subscription_url":"https://api.github.com/repos/pagarme/pilot/subscription","commits_url":"https://api.github.com/repos/pagarme/pilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/pagarme/pilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/pagarme/pilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/pagarme/pilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/pagarme/pilot/contents/{+path}","compare_url":"https://api.github.com/repos/pagarme/pilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pagarme/pilot/merges","archive_url":"https://api.github.com/repos/pagarme/pilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pagarme/pilot/downloads","issues_url":"https://api.github.com/repos/pagarme/pilot/issues{/number}","pulls_url":"https://api.github.com/repos/pagarme/pilot/pulls{/number}","milestones_url":"https://api.github.com/repos/pagarme/pilot/milestones{/number}","notifications_url":"https://api.github.com/repos/pagarme/pilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pagarme/pilot/labels{/name}","releases_url":"https://api.github.com/repos/pagarme/pilot/releases{/id}","deployments_url":"https://api.github.com/repos/pagarme/pilot/deployments","created_at":"2017-07-11T14:28:12Z","updated_at":"2017-11-13T22:22:22Z","pushed_at":"2017-11-17T17:14:00Z","git_url":"git://github.com/pagarme/pilot.git","ssh_url":"git@github.com:pagarme/pilot.git","clone_url":"https://github.com/pagarme/pilot.git","svn_url":"https://github.com/pagarme/pilot","homepage":"","size":159492,"stargazers_count":151,"watchers_count":151,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":21,"forks":16,"open_issues":21,"watchers":151,"default_branch":"master"}},"base":{"label":"pagarme:master","ref":"master","sha":"e876141a635ac9bf2266689561538a4bf81332d3","user":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars2.githubusercontent.com/u/3846050?v=4","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"repo":{"id":96902421,"name":"pilot","full_name":"pagarme/pilot","owner":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars2.githubusercontent.com/u/3846050?v=4","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pagarme/pilot","description":":airplane: The next iteration of Pagar.me's Dashboard","fork":false,"url":"https://api.github.com/repos/pagarme/pilot","forks_url":"https://api.github.com/repos/pagarme/pilot/forks","keys_url":"https://api.github.com/repos/pagarme/pilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pagarme/pilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pagarme/pilot/teams","hooks_url":"https://api.github.com/repos/pagarme/pilot/hooks","issue_events_url":"https://api.github.com/repos/pagarme/pilot/issues/events{/number}","events_url":"https://api.github.com/repos/pagarme/pilot/events","assignees_url":"https://api.github.com/repos/pagarme/pilot/assignees{/user}","branches_url":"https://api.github.com/repos/pagarme/pilot/branches{/branch}","tags_url":"https://api.github.com/repos/pagarme/pilot/tags","blobs_url":"https://api.github.com/repos/pagarme/pilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pagarme/pilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pagarme/pilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/pagarme/pilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pagarme/pilot/statuses/{sha}","languages_url":"https://api.github.com/repos/pagarme/pilot/languages","stargazers_url":"https://api.github.com/repos/pagarme/pilot/stargazers","contributors_url":"https://api.github.com/repos/pagarme/pilot/contributors","subscribers_url":"https://api.github.com/repos/pagarme/pilot/subscribers","subscription_url":"https://api.github.com/repos/pagarme/pilot/subscription","commits_url":"https://api.github.com/repos/pagarme/pilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/pagarme/pilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/pagarme/pilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/pagarme/pilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/pagarme/pilot/contents/{+path}","compare_url":"https://api.github.com/repos/pagarme/pilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pagarme/pilot/merges","archive_url":"https://api.github.com/repos/pagarme/pilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pagarme/pilot/downloads","issues_url":"https://api.github.com/repos/pagarme/pilot/issues{/number}","pulls_url":"https://api.github.com/repos/pagarme/pilot/pulls{/number}","milestones_url":"https://api.github.com/repos/pagarme/pilot/milestones{/number}","notifications_url":"https://api.github.com/repos/pagarme/pilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pagarme/pilot/labels{/name}","releases_url":"https://api.github.com/repos/pagarme/pilot/releases{/id}","deployments_url":"https://api.github.com/repos/pagarme/pilot/deployments","created_at":"2017-07-11T14:28:12Z","updated_at":"2017-11-13T22:22:22Z","pushed_at":"2017-11-17T17:14:00Z","git_url":"git://github.com/pagarme/pilot.git","ssh_url":"git@github.com:pagarme/pilot.git","clone_url":"https://github.com/pagarme/pilot.git","svn_url":"https://github.com/pagarme/pilot","homepage":"","size":159492,"stargazers_count":151,"watchers_count":151,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":21,"forks":16,"open_issues":21,"watchers":151,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pagarme/pilot/pulls/310"},"html":{"href":"https://github.com/pagarme/pilot/pull/310"},"issue":{"href":"https://api.github.com/repos/pagarme/pilot/issues/310"},"comments":{"href":"https://api.github.com/repos/pagarme/pilot/issues/310/comments"},"review_comments":{"href":"https://api.github.com/repos/pagarme/pilot/pulls/310/comments"},"review_comment":{"href":"https://api.github.com/repos/pagarme/pilot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pagarme/pilot/pulls/310/commits"},"statuses":{"href":"https://api.github.com/repos/pagarme/pilot/statuses/604f428e3d8318ba512c350ce0fcaef53f6b5aed"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"darakeon"}}