{"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
\n
\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 setScore(item.score)}\n >\n \n \n {item.label}\n \n \n );\n })}\n

\n\n \n\n
\n \n Submit Feedback\n \n
\n
\n\n
\n Thank you for your feedback! It will help improve this {kind}.\n
\n
\n );\n}\n\nFeedback.propTypes = {\n done: PropTypes.func,\n kind: PropTypes.string,\n};\n\nexport default Feedback;\n"],"names":["ReactPropTypesSecret","ReactPropTypesSecret_1","require$$0","emptyFunction","emptyFunctionWithReset","factoryWithThrowingShims","shim","props","propName","componentName","location","propFullName","secret","err","getShim","ReactPropTypes","propTypesModule","Feedback","done","kind","hasSubmitted","setSubmitted","useState","isLoading","setLoading","score","setScore","comment","setComment","buttons","handleCommentChange","event","handleSubmit","token","csrfToken","options","error","componentCN","classNames","cn","jsxs","jsx","item","PropTypes"],"mappings":"iGASIA,EAAuB,+CAE3BC,EAAiBD,ECFbA,EAAuBE,EAE3B,SAASC,GAAgB,CAAE,CAC3B,SAASC,GAAyB,CAAE,CACpCA,EAAuB,kBAAoBD,EAE3C,IAAAE,EAAiB,UAAW,CAC1B,SAASC,EAAKC,EAAOC,EAAUC,EAAeC,EAAUC,EAAcC,EAAQ,CAC5E,GAAIA,IAAWZ,EAIf,KAAIa,EAAM,IAAI,MACZ,iLAGN,EACI,MAAAA,EAAI,KAAO,sBACLA,EACV,CACEP,EAAK,WAAaA,EAClB,SAASQ,GAAU,CACjB,OAAOR,CAEX,CAEE,IAAIS,EAAiB,CACnB,MAAOT,EACP,OAAQA,EACR,KAAMA,EACN,KAAMA,EACN,OAAQA,EACR,OAAQA,EACR,OAAQA,EACR,OAAQA,EAER,IAAKA,EACL,QAAS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