{"version":3,"file":"Feedback-b4CrvX-3.js","sources":["../../../node_modules/prop-types/lib/ReactPropTypesSecret.js","../../../node_modules/prop-types/factoryWithThrowingShims.js","../../../node_modules/prop-types/index.js","../../../app/javascript/components/types/Feedback.jsx"],"sourcesContent":["/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nfunction emptyFunction() {}\nfunction emptyFunctionWithReset() {}\nemptyFunctionWithReset.resetWarningCache = emptyFunction;\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bigint: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n elementType: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim,\n\n checkPropTypes: emptyFunctionWithReset,\n resetWarningCache: emptyFunction\n };\n\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (process.env.NODE_ENV !== 'production') {\n var ReactIs = require('react-is');\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n","import PropTypes from \"prop-types\";\nimport { useState } from \"react\";\n\nimport classNames from \"classnames\";\nimport cn from \"./Feedback.module.css\";\n\nfunction Feedback({ done = () => {}, kind = \"lesson\" }) {\n const [hasSubmitted, setSubmitted] = useState(false);\n const [isLoading, setLoading] = useState(false);\n const [score, setScore] = useState(null);\n const [comment, setComment] = useState(null);\n\n const buttons = [\n {\n score: 5,\n emoji: \"love\",\n label: \"Loved it!\",\n },\n {\n score: 3,\n emoji: \"good\",\n label: \"Pretty good\",\n },\n {\n score: 2,\n emoji: \"decent\",\n label: \"Could be improved\",\n },\n {\n score: 1,\n emoji: \"bad\",\n label: \"I didn't like it\",\n },\n ];\n\n const handleCommentChange = (event) => {\n setComment(event.target.value);\n };\n\n const handleSubmit = async () => {\n if (hasSubmitted) {\n return;\n }\n\n setLoading(true);\n const { token } = window.CSSMasterClass;\n\n const csrfToken = document.querySelector(\"meta[name='csrf-token']\");\n\n if (!csrfToken) {\n throw new Error(\"No token available.\");\n }\n\n const options = {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-CSRF-Token\": csrfToken.content,\n },\n credentials: \"include\", // Include cookies in the request,\n body: JSON.stringify({\n token,\n score,\n comment,\n }),\n };\n\n try {\n const response = await fetch(`/api/feedback/${kind}`, options);\n\n if (!response.ok) {\n throw new Error(\"Network response was not ok\");\n }\n\n setSubmitted(true);\n done();\n } catch (error) {\n console.error(\"Error fetching data: \" + error.message);\n } finally {\n setLoading(false);\n }\n };\n\n const componentCN = classNames({\n [cn.component]: true,\n [cn[\"submitted\"]]: hasSubmitted,\n });\n\n return (\n
Great job! How did you find this {kind}?
\n\n\n {buttons.map((item) => {\n const cn = classNames({\n [`button`]: true,\n [`is-outlined`]: score !== item.score,\n [`is-primary`]: score === item.score,\n });\n\n return (\n \n );\n })}\n
\n\n \n\n