{"action":"created","comment":{"url":"https://api.github.com/repos/commercetools/ui-kit/pulls/comments/244166208","pull_request_review_id":188104919,"id":244166208,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDE2NjIwOA==","diff_hunk":"@@ -171,3 +196,121 @@ LocalizedMoneyInput.hasEmptyValue([\n   { amount: '', currencyCode: 'USD' },\n ]); // ->  true\n ```\n+\n+### Example\n+\n+Here's an example of how `LocalizedMoneyInput` would be used inside a form.\n+\n+```jsx\n+import React from 'react';\n+import { IntlProvider } from 'react-intl';\n+import { Formik } from 'formik';\n+import omitEmpty from 'omit-empty';\n+import ErrorMessage from '@commercetools-frontend/ui-kit/messages/error-message';\n+import { LocalizedMoneyInput } from '@commercetools-frontend/ui-kit';\n+\n+\n+// the existing document, e.g. from the database\n+const doc = {\n+  prices: [\n+    {\n+      currencyCode: 'ALL',\n+      centAmount: 1200\n+    },\n+    {\n+      currencyCode: 'AMD',\n+      centAmount: 3300,\n+    }\n+  ],\n+};\n+\n+// A function to convert a document to form values.\n+const docToFormValues = aDoc => ({\n+  // The parseMoneyValue function will turn a MoneyValue into a\n+  // value the LocalizedMoneyInput component can handle ({currency: amount})\n+  prices: LocalizedMoneyInput.parseMoneyValues(aDoc.prices),\n+});\n+\n+// a function to convert form values back to a document\n+const formValuesToDoc = formValues => ({\n+  // The convertToMoneyValue function will turn a LocalizedMoneyInput\n+  // value into a value the API can handle\n+  // It automatically converts to centPrecision or highPrecision\n+  // depending on the number of supplied fraction digits and the\n+  // used currency code.\n+  // If you want to forbid highPrecision, then the form's validation\n+  // needs to add an error when it sees a highPrecision price.\n+  // See example below\n+  prices: LocalizedMoneyInput.convertToMoneyValues(formValues.prices),\n+});\n+\n+const validate = formValues => {\n+  const errors = { prices: {} };\n+  Object.keys(formValues.prices).forEach(currency => {\n+    errors.prices[currency] = {};\n+  })\n+  const emptyCurrencies = LocalizedMoneyInput.getEmptyCurrencies(formValues.prices);\n+  // ['ERU', 'USD']\n+  // THis form dosen't accept highprecision prices\n+  const highPrecisionCurrencies = LocalizedMoneyInput.getHighPrecisionCurrencies(formValues.prices);\n+  // ['CAD', 'USD']\n+  emptyCurrencies.forEach(emptyCurrency => {","path":"src/components/inputs/localized-money-input/README.md","position":257,"original_position":141,"commit_id":"1722ab7bc43971e069d4155eca991da5a7af180a","original_commit_id":"1722ab7bc43971e069d4155eca991da5a7af180a","user":{"login":"dferber90","id":1765075,"node_id":"MDQ6VXNlcjE3NjUwNzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1765075?v=4","gravatar_id":"","url":"https://api.github.com/users/dferber90","html_url":"https://github.com/dferber90","followers_url":"https://api.github.com/users/dferber90/followers","following_url":"https://api.github.com/users/dferber90/following{/other_user}","gists_url":"https://api.github.com/users/dferber90/gists{/gist_id}","starred_url":"https://api.github.com/users/dferber90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dferber90/subscriptions","organizations_url":"https://api.github.com/users/dferber90/orgs","repos_url":"https://api.github.com/users/dferber90/repos","events_url":"https://api.github.com/users/dferber90/events{/privacy}","received_events_url":"https://api.github.com/users/dferber90/received_events","type":"User","site_admin":false},"body":"The spacing in this example is a bit weird. We do\r\n\r\n```\r\nget empty currency errors\r\nget high precision currency errors\r\nadd empty currency errors\r\n\r\nadd high precision currency errors\r\n```\r\n\r\ninstead of\r\n\r\n```\r\nget empty currency errors\r\nget high precision currency errors\r\n\r\nadd empty currency errors\r\nadd high precision currency errors\r\n```\r\n\r\nor\r\n\r\n```\r\nget empty currency errors\r\nadd empty currency errors\r\n\r\nget high precision currency errors\r\nadd high precision currency errors\r\n```\r\n","created_at":"2018-12-27T14:47:54Z","updated_at":"2018-12-27T14:49:48Z","html_url":"https://github.com/commercetools/ui-kit/pull/339#discussion_r244166208","pull_request_url":"https://api.github.com/repos/commercetools/ui-kit/pulls/339","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/commercetools/ui-kit/pulls/comments/244166208"},"html":{"href":"https://github.com/commercetools/ui-kit/pull/339#discussion_r244166208"},"pull_request":{"href":"https://api.github.com/repos/commercetools/ui-kit/pulls/339"}}},"pull_request":{"url":"https://api.github.com/repos/commercetools/ui-kit/pulls/339","id":239117535,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM5MTE3NTM1","html_url":"https://github.com/commercetools/ui-kit/pull/339","diff_url":"https://github.com/commercetools/ui-kit/pull/339.diff","patch_url":"https://github.com/commercetools/ui-kit/pull/339.patch","issue_url":"https://api.github.com/repos/commercetools/ui-kit/issues/339","number":339,"state":"open","locked":false,"title":"Add  LocalizedMoneyInput Component","user":{"login":"islam3zzat","id":7680511,"node_id":"MDQ6VXNlcjc2ODA1MTE=","avatar_url":"https://avatars1.githubusercontent.com/u/7680511?v=4","gravatar_id":"","url":"https://api.github.com/users/islam3zzat","html_url":"https://github.com/islam3zzat","followers_url":"https://api.github.com/users/islam3zzat/followers","following_url":"https://api.github.com/users/islam3zzat/following{/other_user}","gists_url":"https://api.github.com/users/islam3zzat/gists{/gist_id}","starred_url":"https://api.github.com/users/islam3zzat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/islam3zzat/subscriptions","organizations_url":"https://api.github.com/users/islam3zzat/orgs","repos_url":"https://api.github.com/users/islam3zzat/repos","events_url":"https://api.github.com/users/islam3zzat/events{/privacy}","received_events_url":"https://api.github.com/users/islam3zzat/received_events","type":"User","site_admin":false},"body":"<!--\r\n  This is the general template.\r\n\r\n  Add the following to the URL to use a specific template\r\n    ?template=add-new-component.md      Template for adding new components\r\n    ?template=bugfix.md                 Template for bug fixes\r\n    ?template=refactoring.md            Template for refactoring code\r\n--->\r\n\r\n#### Summary\r\n\r\n<!-- provide a short summary of your changes -->\r\n\r\n![image](https://user-images.githubusercontent.com/7680511/50085010-13ab7900-01f9-11e9-9b66-3ab1586c4e85.png)\r\n\r\n![image](https://user-images.githubusercontent.com/7680511/50085025-1f973b00-01f9-11e9-98be-6e23fac653f7.png)\r\n\r\n\r\n#### Description\r\n\r\n<!-- provide some context -->\r\n","created_at":"2018-12-17T11:51:08Z","updated_at":"2018-12-27T14:49:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cf3afffd9e49fe33d9cd15464abdcbf3ae59993","assignee":null,"assignees":[],"requested_reviewers":[{"login":"filippobocik","id":39400108,"node_id":"MDQ6VXNlcjM5NDAwMTA4","avatar_url":"https://avatars2.githubusercontent.com/u/39400108?v=4","gravatar_id":"","url":"https://api.github.com/users/filippobocik","html_url":"https://github.com/filippobocik","followers_url":"https://api.github.com/users/filippobocik/followers","following_url":"https://api.github.com/users/filippobocik/following{/other_user}","gists_url":"https://api.github.com/users/filippobocik/gists{/gist_id}","starred_url":"https://api.github.com/users/filippobocik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filippobocik/subscriptions","organizations_url":"https://api.github.com/users/filippobocik/orgs","repos_url":"https://api.github.com/users/filippobocik/repos","events_url":"https://api.github.com/users/filippobocik/events{/privacy}","received_events_url":"https://api.github.com/users/filippobocik/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1045035317,"node_id":"MDU6TGFiZWwxMDQ1MDM1MzE3","url":"https://api.github.com/repos/commercetools/ui-kit/labels/%F0%9F%91%A8%E2%80%8D%F0%9F%8E%A8%20Status:%20UI/UX%20Review","name":"👨‍🎨 Status: UI/UX Review","color":"d4c5f9","default":false},{"id":1045018183,"node_id":"MDU6TGFiZWwxMDQ1MDE4MTgz","url":"https://api.github.com/repos/commercetools/ui-kit/labels/%F0%9F%91%A8%E2%80%8D%F0%9F%91%A9%E2%80%8D%F0%9F%91%A6%E2%80%8D%F0%9F%91%A6%20Status:%20Dev%20Review","name":"👨‍👩‍👦‍👦 Status: Dev Review","color":"5319e7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/commercetools/ui-kit/pulls/339/commits","review_comments_url":"https://api.github.com/repos/commercetools/ui-kit/pulls/339/comments","review_comment_url":"https://api.github.com/repos/commercetools/ui-kit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/commercetools/ui-kit/issues/339/comments","statuses_url":"https://api.github.com/repos/commercetools/ui-kit/statuses/1722ab7bc43971e069d4155eca991da5a7af180a","head":{"label":"commercetools:add-localized-money-input","ref":"add-localized-money-input","sha":"1722ab7bc43971e069d4155eca991da5a7af180a","user":{"login":"commercetools","id":1084585,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwODQ1ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"repo":{"id":146916092,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY5MTYwOTI=","name":"ui-kit","full_name":"commercetools/ui-kit","private":false,"owner":{"login":"commercetools","id":1084585,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwODQ1ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/commercetools/ui-kit","description":"Component library 💅","fork":false,"url":"https://api.github.com/repos/commercetools/ui-kit","forks_url":"https://api.github.com/repos/commercetools/ui-kit/forks","keys_url":"https://api.github.com/repos/commercetools/ui-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/commercetools/ui-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/commercetools/ui-kit/teams","hooks_url":"https://api.github.com/repos/commercetools/ui-kit/hooks","issue_events_url":"https://api.github.com/repos/commercetools/ui-kit/issues/events{/number}","events_url":"https://api.github.com/repos/commercetools/ui-kit/events","assignees_url":"https://api.github.com/repos/commercetools/ui-kit/assignees{/user}","branches_url":"https://api.github.com/repos/commercetools/ui-kit/branches{/branch}","tags_url":"https://api.github.com/repos/commercetools/ui-kit/tags","blobs_url":"https://api.github.com/repos/commercetools/ui-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/commercetools/ui-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/commercetools/ui-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/commercetools/ui-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/commercetools/ui-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/commercetools/ui-kit/languages","stargazers_url":"https://api.github.com/repos/commercetools/ui-kit/stargazers","contributors_url":"https://api.github.com/repos/commercetools/ui-kit/contributors","subscribers_url":"https://api.github.com/repos/commercetools/ui-kit/subscribers","subscription_url":"https://api.github.com/repos/commercetools/ui-kit/subscription","commits_url":"https://api.github.com/repos/commercetools/ui-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/commercetools/ui-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/commercetools/ui-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/commercetools/ui-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/commercetools/ui-kit/contents/{+path}","compare_url":"https://api.github.com/repos/commercetools/ui-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/commercetools/ui-kit/merges","archive_url":"https://api.github.com/repos/commercetools/ui-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/commercetools/ui-kit/downloads","issues_url":"https://api.github.com/repos/commercetools/ui-kit/issues{/number}","pulls_url":"https://api.github.com/repos/commercetools/ui-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/commercetools/ui-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/commercetools/ui-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/commercetools/ui-kit/labels{/name}","releases_url":"https://api.github.com/repos/commercetools/ui-kit/releases{/id}","deployments_url":"https://api.github.com/repos/commercetools/ui-kit/deployments","created_at":"2018-08-31T16:20:21Z","updated_at":"2018-12-27T13:20:13Z","pushed_at":"2018-12-27T14:35:09Z","git_url":"git://github.com/commercetools/ui-kit.git","ssh_url":"git@github.com:commercetools/ui-kit.git","clone_url":"https://github.com/commercetools/ui-kit.git","svn_url":"https://github.com/commercetools/ui-kit","homepage":"https://uikit.commercetools.com","size":3634,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":19,"watchers":7,"default_branch":"master"}},"base":{"label":"commercetools:master","ref":"master","sha":"7cc36682a5672d8bc31b4272d5e5333a58ee4f88","user":{"login":"commercetools","id":1084585,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwODQ1ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"repo":{"id":146916092,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY5MTYwOTI=","name":"ui-kit","full_name":"commercetools/ui-kit","private":false,"owner":{"login":"commercetools","id":1084585,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwODQ1ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1084585?v=4","gravatar_id":"","url":"https://api.github.com/users/commercetools","html_url":"https://github.com/commercetools","followers_url":"https://api.github.com/users/commercetools/followers","following_url":"https://api.github.com/users/commercetools/following{/other_user}","gists_url":"https://api.github.com/users/commercetools/gists{/gist_id}","starred_url":"https://api.github.com/users/commercetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commercetools/subscriptions","organizations_url":"https://api.github.com/users/commercetools/orgs","repos_url":"https://api.github.com/users/commercetools/repos","events_url":"https://api.github.com/users/commercetools/events{/privacy}","received_events_url":"https://api.github.com/users/commercetools/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/commercetools/ui-kit","description":"Component library 💅","fork":false,"url":"https://api.github.com/repos/commercetools/ui-kit","forks_url":"https://api.github.com/repos/commercetools/ui-kit/forks","keys_url":"https://api.github.com/repos/commercetools/ui-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/commercetools/ui-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/commercetools/ui-kit/teams","hooks_url":"https://api.github.com/repos/commercetools/ui-kit/hooks","issue_events_url":"https://api.github.com/repos/commercetools/ui-kit/issues/events{/number}","events_url":"https://api.github.com/repos/commercetools/ui-kit/events","assignees_url":"https://api.github.com/repos/commercetools/ui-kit/assignees{/user}","branches_url":"https://api.github.com/repos/commercetools/ui-kit/branches{/branch}","tags_url":"https://api.github.com/repos/commercetools/ui-kit/tags","blobs_url":"https://api.github.com/repos/commercetools/ui-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/commercetools/ui-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/commercetools/ui-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/commercetools/ui-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/commercetools/ui-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/commercetools/ui-kit/languages","stargazers_url":"https://api.github.com/repos/commercetools/ui-kit/stargazers","contributors_url":"https://api.github.com/repos/commercetools/ui-kit/contributors","subscribers_url":"https://api.github.com/repos/commercetools/ui-kit/subscribers","subscription_url":"https://api.github.com/repos/commercetools/ui-kit/subscription","commits_url":"https://api.github.com/repos/commercetools/ui-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/commercetools/ui-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/commercetools/ui-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/commercetools/ui-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/commercetools/ui-kit/contents/{+path}","compare_url":"https://api.github.com/repos/commercetools/ui-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/commercetools/ui-kit/merges","archive_url":"https://api.github.com/repos/commercetools/ui-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/commercetools/ui-kit/downloads","issues_url":"https://api.github.com/repos/commercetools/ui-kit/issues{/number}","pulls_url":"https://api.github.com/repos/commercetools/ui-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/commercetools/ui-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/commercetools/ui-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/commercetools/ui-kit/labels{/name}","releases_url":"https://api.github.com/repos/commercetools/ui-kit/releases{/id}","deployments_url":"https://api.github.com/repos/commercetools/ui-kit/deployments","created_at":"2018-08-31T16:20:21Z","updated_at":"2018-12-27T13:20:13Z","pushed_at":"2018-12-27T14:35:09Z","git_url":"git://github.com/commercetools/ui-kit.git","ssh_url":"git@github.com:commercetools/ui-kit.git","clone_url":"https://github.com/commercetools/ui-kit.git","svn_url":"https://github.com/commercetools/ui-kit","homepage":"https://uikit.commercetools.com","size":3634,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":19,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/commercetools/ui-kit/pulls/339"},"html":{"href":"https://github.com/commercetools/ui-kit/pull/339"},"issue":{"href":"https://api.github.com/repos/commercetools/ui-kit/issues/339"},"comments":{"href":"https://api.github.com/repos/commercetools/ui-kit/issues/339/comments"},"review_comments":{"href":"https://api.github.com/repos/commercetools/ui-kit/pulls/339/comments"},"review_comment":{"href":"https://api.github.com/repos/commercetools/ui-kit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/commercetools/ui-kit/pulls/339/commits"},"statuses":{"href":"https://api.github.com/repos/commercetools/ui-kit/statuses/1722ab7bc43971e069d4155eca991da5a7af180a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dferber90"}}