{"version":3,"file":"react_components-DDPX7iv6.js","sources":["../../../app/javascript/components/authentication_modals/LinkAuthedUserConfirmationModal.jsx","../../../app/javascript/components/authentication_modals/UnknownReviewerConfirmationModal.jsx","../../../app/javascript/components/commodity_code_picker/SearchBar.jsx","../../../app/javascript/components/commodity_code_picker/SelectedSegments.tsx","../../../app/assets/images/supplier_commodity_picker/arrow-down-right.svg","../../../app/assets/images/supplier_commodity_picker/checkbox-selected.svg","../../../app/assets/images/supplier_commodity_picker/checkbox-unchecked.svg","../../../app/javascript/components/commodity_code_picker/picker/Focusable.tsx","../../../app/javascript/components/commodity_code_picker/picker/CommodityClass.tsx","../../../app/assets/images/supplier_commodity_picker/checkbox-partial-selected.svg","../../../app/assets/images/supplier_commodity_picker/collapse-small.svg","../../../app/assets/images/supplier_commodity_picker/expand-small.svg","../../../app/javascript/components/commodity_code_picker/picker/Family.tsx","../../../app/assets/images/supplier_commodity_picker/segment-checkbox-unchecked.svg","../../../app/assets/images/supplier_commodity_picker/collapse-large.svg","../../../app/assets/images/supplier_commodity_picker/expand-large.svg","../../../app/javascript/components/commodity_code_picker/picker/Segment.tsx","../../../app/assets/images/supplier_commodity_picker/close-info-box.svg","../../../app/assets/images/supplier_commodity_picker/info-i.svg","../../../app/javascript/components/commodity_code_picker/prop_shapes/commodity_class.ts","../../../app/javascript/components/commodity_code_picker/prop_shapes/family.ts","../../../app/javascript/components/commodity_code_picker/prop_shapes/segment.ts","../../../app/javascript/components/commodity_code_picker/Picker.jsx","../../../app/javascript/components/commodity_code_picker/Base.jsx","../../../app/javascript/components/commodity_code_picker/Wrapper.jsx","../../../app/javascript/components/image_uploader/Form.jsx","../../../app/javascript/components/image_uploader/Uploader.jsx","../../../app/javascript/components/SearchSuppliers.jsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/FormContext.ts","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/generateUrl.ts","../../../app/javascript/components/common/dropdown/SelectItems.tsx","../../../app/javascript/components/common/dropdown/Dropdown.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/ContractAndVechicleSelectForm.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/ContractAndVehicleSection.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/Preview.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/SectionHeader.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/SharingSection.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/CopyUrl.tsx","../../../app/javascript/components/supplier_onboarding/supplier_review_link_form/UrlGenerationSection.tsx","../../../app/javascript/components/supplier_onboarding/SupplierReviewLinkForm.tsx","../../../app/javascript/packs/react_components.js"],"sourcesContent":["import React from 'react'\nimport UserConfirmationModal from './UserConfirmationModal'\nimport PropTypes from 'prop-types'\nimport EnterPassword from './pages/EnterPassword'\nimport SetPassword from './pages/SetPassword'\nimport EnterCode from './pages/EnterCode'\n\nclass LinkAuthedUserConfirmationModal extends React.Component {\n constructor (props) {\n super(props)\n this.state = this.initialState()\n }\n\n initialState = () => (\n {\n confirmed: false,\n isRevealed: false\n }\n )\n\n handleModalClose = (close) => {\n if (!this.state.confirmed) {\n this.setState(this.initialState())\n close()\n }\n }\n\n renderContent = ({ currentPage, isRevealed, advanceToPage, close }) => {\n switch (currentPage) {\n case 'EnterPassword':\n return (\n {\n if (this.props.requestedUrl) {\n window.location.href = this.props.requestedUrl\n } else {\n close()\n }\n }}\n onResetPassword={() => advanceToPage('EnterCode')}\n />\n )\n case 'EnterCode':\n return (\n {\n this.setState({ confirmed: true })\n advanceToPage('SetPassword')\n }}\n />\n )\n case 'SetPassword':\n return (\n {\n if (this.props.requestedUrl) {\n window.location.href = this.props.requestedUrl\n } else {\n close()\n }\n }}\n />\n )\n }\n }\n\n render () {\n return (\n \n )\n }\n}\n\nLinkAuthedUserConfirmationModal.propTypes = {\n email: PropTypes.string.isRequired,\n userHasPassword: PropTypes.bool,\n requestedUrl: PropTypes.string,\n supportEmail: PropTypes.string.isRequired\n}\n\nLinkAuthedUserConfirmationModal.defaultProps = {\n userHasPassword: false\n}\n\nexport default LinkAuthedUserConfirmationModal\n","/* global Rails */\n\nimport React from 'react'\nimport { api } from 'components/api'\nimport { reviewRecordEmailPath, reviewAssociateUserPath } from '../routes/api'\nimport EnterEmail from './pages/EnterEmail'\nimport EnterPassword from './pages/EnterPassword'\nimport SetPassword from './pages/SetPassword'\nimport EnterCode from './pages/EnterCode'\nimport SignUpPage1 from './pages/SignUpPage1'\nimport SignUpPage2 from './pages/SignUpPage2'\nimport InvalidEmail from './pages/InvalidEmail'\nimport UserConfirmationModal from './UserConfirmationModal'\nimport PropTypes from 'prop-types'\n\nclass UnknownReviewerConfirmationModal extends React.Component {\n constructor (props) {\n super(props)\n\n this.state = this.initialState()\n }\n\n initialState = () => (\n {\n email: this.props.email,\n name: '',\n userStatus: null,\n userType: null,\n confirmed: false\n }\n )\n\n pageAfterEnterEmail = ({ userStatus, userType }) => {\n let nextPage\n\n if (userType === 'supplier' || ['rejected', 'disabled'].includes(userStatus)) {\n nextPage = 'InvalidEmail'\n } else if (['verified', 'self_registered'].includes(userStatus)) {\n nextPage = 'EnterPassword'\n } else if (['approved', 'phonerep_added', 'preloaded'].includes(userStatus)) {\n nextPage = 'EnterCode'\n } else {\n nextPage = 'SignUpPage1'\n }\n\n return nextPage\n }\n\n handleModalClose = () => {\n if (!this.state.confirmed) {\n this.setState(this.initialState())\n }\n }\n\n submitReviewForm = () => {\n const form = document.getElementById('review-form')\n Rails.fire(form, 'submit')\n }\n\n signUpPageSubHeaderMessage = () => (\n

\n Please provide your information to continue submitting your review.\n

\n )\n\n captureReviewSource = ({ email, userId }) => {\n if (userId) {\n return api.patchWithCsrf({\n url: reviewAssociateUserPath(this.props.reviewId),\n data: {\n user_id: userId,\n user_identity_unverified: true\n }\n })\n } else {\n return api.patchWithCsrf({\n url: reviewRecordEmailPath(this.props.reviewId),\n data: { email }\n })\n }\n }\n\n markVerified = ({ userId }) => {\n return api.patchWithCsrf({\n url: reviewAssociateUserPath(this.props.reviewId),\n data: {\n user_id: userId,\n user_identity_unverified: false\n }\n })\n }\n\n renderPage = ({ currentPage, advanceToPage, goBackToPreviousPage, close }) => {\n const { reviewId } = this.props\n switch (currentPage) {\n case 'EnterEmail':\n return (\n One last step! You're moments away from submitting your review.

\n }\n createAccountMessage={\n

One last step! Create your account to submit your review.

\n }\n onSuccess={(data) => {\n this.setState(data, () => {\n this.captureReviewSource(this.state).then(() => {\n advanceToPage(this.pageAfterEnterEmail(this.state))\n })\n })\n }}\n onCreateAccount={() => {\n close()\n $('#sign-up-modal').foundation('open')\n }}\n />\n )\n case 'EnterPassword':\n return (\n \n

One last step! You're moments away from submitting your review.

\n

Enter the password for your {this.state.email} account.

\n \n }\n onGoBack={goBackToPreviousPage}\n onSuccess={() => {\n this.markVerified(this.state).then(() => {\n close()\n this.submitReviewForm()\n })\n }}\n onResetPassword={() => advanceToPage('EnterCode')}\n />\n )\n case 'EnterCode':\n return (\n \n We emailed a code to your email address {this.state.email}. Please enter the code to finish\n submitting\n your review.\n

\n }\n reviewId={reviewId}\n onSuccess={() => {\n this.setState({ confirmed: true }, () => {\n this.markVerified(this.state).then(() => {\n advanceToPage('SetPassword')\n })\n })\n }}\n />\n )\n case 'SetPassword':\n return (\n {\n close()\n this.submitReviewForm()\n }}\n />\n )\n case 'SignUpPage1':\n return (\n {\n this.setState(data)\n advanceToPage('SignUpPage2')\n }}\n />\n )\n case 'SignUpPage2':\n return (\n {\n this.setState(data, () => {\n this.captureReviewSource(this.state).then(() => {\n advanceToPage('EnterCode')\n })\n })\n }}\n />\n )\n case 'InvalidEmail':\n return (\n Your account does not have permission to post reviews on Procurated.}\n supportEmail={this.props.supportEmail}\n />\n )\n }\n }\n\n render () {\n return (\n \n )\n }\n}\n\nUnknownReviewerConfirmationModal.propTypes = {\n email: PropTypes.string.isRequired,\n reviewId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n page: PropTypes.string.isRequired,\n supportEmail: PropTypes.string.isRequired\n}\n\nUnknownReviewerConfirmationModal.defaultProps = {\n email: '',\n page: 'EnterEmail'\n}\n\nexport default UnknownReviewerConfirmationModal\n","// TODO: CONVERT TO TYPESCRIPT\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { api } from 'components/api'\nimport { commodityCodeSearchPath } from 'components/routes/api'\n\nexport default class SearchBar extends React.Component {\n constructor (props) {\n super(props)\n\n this.state = {\n searchTerm: '',\n searchResults: [],\n lastSearchEmpty: false\n }\n }\n\n shouldSearch = () => {\n return this.state.searchTerm.length >= 2\n }\n\n search = async () => {\n const response = await api.get({ url: commodityCodeSearchPath(), params: { search: this.state.searchTerm } })\n if (response.status === 200) {\n const searchResults = response.data\n this.setState({\n searchResults,\n lastSearchEmpty: searchResults.length === 0\n })\n }\n }\n\n handleChange = async (event) => {\n this.setState({ searchTerm: event.target.value }, () => {\n if (this.shouldSearch()) {\n this.search()\n } else if (this.state.searchResults.length > 0) {\n this.setState({ searchResults: [] })\n }\n })\n }\n\n handleClear = () => {\n this.setState({\n searchTerm: '',\n searchResults: []\n })\n }\n\n renderTextWithBoldSearchTermMatches = (text) => {\n if (!this.state.searchTerm) { return }\n\n // Find instances of search term within string (regardless of whitespace)\n const regex = new RegExp(`(?.*)(?${this.state.searchTerm.replace(' ', '').split('').join('\\\\s*')})(?.*)`, 'i')\n const matchResults = text.match(regex)\n\n // If the search term appears within the item description, make it bold\n if (matchResults) {\n const { prematch, match, postmatch } = matchResults.groups\n return <>{prematch}{match}{postmatch}\n } else {\n return <>{text}\n }\n }\n\n renderSearchResult = ({ hierarchy, code, item_description: itemDescription }) => {\n let hierarchyTagText\n switch (hierarchy) {\n case 'commodity_class':\n hierarchyTagText = 'class'\n break\n default:\n hierarchyTagText = hierarchy\n }\n\n return (\n
\n
\n \n {this.renderTextWithBoldSearchTermMatches(`${hierarchyTagText} ${code}`)}\n \n
\n
\n \n {this.renderTextWithBoldSearchTermMatches(itemDescription)}\n \n
\n
\n \n
\n
\n )\n }\n\n renderSearchResults = (searchResults) => {\n if (searchResults.length > 0) {\n return (\n
    \n {\n searchResults.map((searchResult) => (\n this.props.handleSearchResultClick(searchResult)}\n key={searchResult.id}\n >\n {this.renderSearchResult(searchResult)}\n \n ))\n }\n
\n )\n } else if (this.state.lastSearchEmpty) {\n return (\n
\n No results found.\n
\n )\n }\n }\n\n render () {\n return (\n
\n
\n