{"version":3,"sources":["data/newsletters.js","components/Checkbox.jsx","components/NewsletterForm.jsx","App.jsx","serviceWorker.js","index.jsx"],"names":["Newsletters","Checkbox","_ref","type","name","checked","onChange","id","_jsx","className","NewsletterForm","React","Component","constructor","props","super","this","state","checkedItems","Map","affl","email","handleChange","bind","handleEmailChange","handleAfflChange","handleSubmit","e","target","isChecked","setState","prevState","set","value","preventDefault","alert","dailyNewsId","dailyNewsToggled","array","Array","from","filter","obj","elementIds","elem","push","user_email","newsletter_ids","demographics","affiliation","fetchData","method","headers","Accept","body","JSON","stringify","fetch","then","res","json","data","console","log","success","callback","callbackStatus","objAffl","fetchDataAffl","render","_jsxs","children","src","alt","style","textAlign","class","href","onSubmit","map","item","get","description","key","placeholder","required","color","disabled","selected","fontSize","i","_Fragment","url","App","Boolean","window","location","hostname","match","ReactDOM","StrictMode","document","getElementById","navigator","serviceWorker","ready","registration","unregister","catch","error","message"],"mappings":"oMAAO,MAAMA,EAAc,CAAC,CACxB,GAAM,aACN,KAAQ,mBACR,YAAe,0FACf,IAAO,4B,WCUIC,MAXEC,IAAA,IAAC,KAACC,EAAO,WAAU,KAAEC,EAAI,QAAEC,GAAU,EAAK,SAAEC,EAAQ,GAAEC,GAAGL,EAAA,OACtEM,cAAA,SAAOC,UAAU,iBAAiBN,KAAMA,EAAMC,KAAMA,EAAMC,QAASA,EAASC,SAAUA,EAAUC,GAAIA,GAAK,ECA7G,MAAMG,UAAuBC,IAAMC,UACjCC,YAAYC,GACVC,MAAMD,GAENE,KAAKC,MAAQ,CACXC,aAAc,IAAIC,IAClBC,KAAM,MACNC,MAAO,IAGTL,KAAKM,aAAeN,KAAKM,aAAaC,KAAKP,MAC3CA,KAAKQ,kBAAoBR,KAAKQ,kBAAkBD,KAAKP,MACrDA,KAAKS,iBAAmBT,KAAKS,iBAAiBF,KAAKP,MACnDA,KAAKU,aAAeV,KAAKU,aAAaH,KAAKP,KAC7C,CAEAM,aAAaK,GACX,MAAMpB,EAAKoB,EAAEC,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U,gBAAe8D,SACxC/D,cAAA,SACEkE,MAAO,CAAEe,SAAU,QACnBhF,UAAU,YACVN,KAAK,SACL8B,MAAM,gBAGVzB,cAAA,SACAA,cAAA,SACCyD,GACCzD,cAAA,OAAKD,GAAG,kBAAkBE,UAAWyD,EAAeK,SACjDN,IAGLK,eAAA,OAAK7D,UAAU,aAAY8D,SAAA,CACzB/D,cAAA,KAAA+D,SACE/D,cAAA,KAAA+D,SAAG,kGAKJvE,EAAY+E,KAAI,CAACC,EAAMU,IACtBpB,eAAAqB,WAAA,CAAApB,SAAA,CACGmB,EAAI,GAAK,MACVlF,cAAA,KAAGqE,KAAMG,EAAKY,IAAKhE,OAAO,SAASnB,UAAU,YAAW8D,SACrDS,EAAK5E,oBAQtB,EAGaM,Q,KChQAmF,MAbf,WACE,OACErF,cAAAmF,WAAA,CAAApB,SACED,eAAA,OAAK7D,UAAU,UAAS8D,SAAA,CACtB/D,cAAA,OAAKC,UAAU,qBAAoB8D,SACjC/D,cAACE,EAAc,MAEjBF,cAAA,aAIR,ECHoBsF,QACa,cAA7BC,OAAOC,SAASC,UAEa,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACrB,2DCbRC,IAAS9B,OACL7D,cAACG,IAAMyF,WAAU,CAAA7B,SACb/D,cAACqF,EAAG,MAERQ,SAASC,eAAe,SD0HpB,kBAAmBC,WACnBA,UAAUC,cAAcC,MACnB/C,MAAKgD,IACFA,EAAaC,YAAY,IAE5BC,OAAMC,IACH/C,QAAQ+C,MAAMA,EAAMC,QAAQ,G","file":"static/js/main.80a5d011.chunk.js","sourcesContent":["export const Newsletters = [{\n 'id': '314837ec05',\n 'name': 'Daily Newsletter',\n 'description': 'Keep up to date with all of The Daily Princetonian’s coverage, delivered weekdays.',\n 'url': 'http://eepurl.com/GveCn'\n}];\n","import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst Checkbox = ({type = 'checkbox', name, checked = false, onChange, id}) => (\n \n);\n\nCheckbox.propTypes = {\n type: PropTypes.string,\n name: PropTypes.string.isRequired,\n checked: PropTypes.bool,\n onChange: PropTypes.func.isRequired,\n}\n\nexport default Checkbox;\n","import React from \"react\";\nimport { Newsletters } from \"../data/newsletters.js\";\nimport Checkbox from \"./Checkbox\";\n\nclass NewsletterForm extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n checkedItems: new Map(),\n affl: \"bad\",\n email: \"\",\n };\n\n this.handleChange = this.handleChange.bind(this);\n this.handleEmailChange = this.handleEmailChange.bind(this);\n this.handleAfflChange = this.handleAfflChange.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n }\n\n handleChange(e) {\n const id = e.target.id;\n const isChecked = e.target.checked;\n this.setState((prevState) => ({\n checkedItems: prevState.checkedItems.set(id, isChecked),\n }));\n }\n\n handleAfflChange(e) {\n const affl = e.target.value;\n if (\n affl === \"student\" ||\n affl === \"graduate_student\" ||\n affl === \"prospective_student\" ||\n affl === \"parent\" ||\n affl === \"prospective_parent\" ||\n affl === \"alum\" ||\n affl === \"faculty/staff\" ||\n affl === \"other\"\n ) {\n this.setState({ affl: affl });\n } else {\n this.setState({ affl: \"bad\" });\n }\n }\n\n handleEmailChange(e) {\n const email = e.target.value;\n this.setState({ email: email });\n }\n\n handleSubmit(e) {\n e.preventDefault();\n\n if (this.state.affl === \"bad\") {\n alert(\n \"Please select a Princeton University affiliation from the dropdown.\"\n );\n return;\n }\n\n // daily subscribers requires affiliation\n const dailyNewsId = \"314837ec05\";\n let dailyNewsToggled = false;\n\n const array = Array.from(this.state.checkedItems, ([id, isChecked]) => ({\n id,\n isChecked,\n })).filter((obj) => obj.isChecked);\n let elementIds = [];\n\n for (let elem of array) {\n if (elem.id === dailyNewsId) {\n dailyNewsToggled = true;\n } else {\n elementIds.push(elem.id);\n }\n }\n\n const obj = {\n user_email: this.state.email,\n newsletter_ids: elementIds,\n demographics: {\n affiliation: this.state.affl,\n },\n };\n\n var fetchData = {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(obj),\n };\n\n fetch(\n \"https://dailyprince-subscribe-api.herokuapp.com/subscribe\",\n fetchData\n )\n .then((res) => res.json())\n .then((data) => {\n console.log(data.success);\n if (data.success === \"unsuccessful\") {\n this.setState({\n callback:\n \"Something went wrong. Have you already subscribed to this service? Check your inbox or contact tech@dailyprincetonian.com.\",\n });\n this.setState({ callbackStatus: \"red\" });\n } else {\n this.setState({\n callback: \"Success! Thank you for subscribing.\",\n });\n this.setState({ callbackStatus: \"green\" });\n }\n });\n\n if (dailyNewsToggled) {\n const objAffl = {\n user_email: this.state.email,\n affiliation: this.state.affl,\n newsletter_ids: [dailyNewsId],\n };\n\n var fetchDataAffl = {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(objAffl),\n };\n\n fetch(\n \"https://dailyprince-subscribe-api.herokuapp.com/subscribe/affiliation\",\n fetchDataAffl\n )\n .then((res) => res.json())\n .then((data) => {\n console.log(data.success);\n if (\n data.success === \"unsuccessful\" ||\n this.state.callbackStatus === \"red\"\n ) {\n this.setState({\n callback:\n \"Something went wrong. Have you already subscribed to this service? Check your inbox or contact tech@dailyprincetonian.com.\",\n });\n this.setState({ callbackStatus: \"red\" });\n } else {\n this.setState({\n callback: \"Success! Thank you for subscribing.\",\n });\n this.setState({ callbackStatus: \"green\" });\n }\n });\n }\n }\n\n render() {\n const { callback, callbackStatus } = this.state;\n return (\n
\n \n

\n {\" \"}\n SUBSCRIBE for reliable, timely, and truthful\n news that matters\n

\n

\n (Looking for a{\" \"}\n \n \n PRINT SUBSCRIPTION\n \n {\" \"}\n instead?)\n

\n
\n

\n Select each newsletter you’d like to receive\n

\n
\n
\n {Newsletters.map((item) => (\n \n ))}\n
\n
\n

Your Email Address*

\n \n

Princeton University Affiliation

\n \n \n \n \n \n \n \n \n \n \n \n *required fields\n

\n

\n
\n \n
\n
\n
\n {callback && (\n
\n {callback}\n
\n )}\n
\n

\n \n If you encounter problems, manually subscribe to our newsletters\n using the following links:\n \n

\n {Newsletters.map((item, i) => (\n <>\n {i > 0 && \" | \"}\n \n {item.name}\n \n \n ))}\n
\n \n
\n );\n }\n}\n\nexport default NewsletterForm;\n","import React from \"react\";\nimport NewsletterForm from \"./components/NewsletterForm.jsx\";\nimport \"./App.css\";\n\nfunction App() {\n return (\n <>\n
\n
\n \n
\n

\n
\n \n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: {'Service-Worker': 'script'},\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}