{"version":3,"sources":["components/Corporate/PageFeedback/StyledPageFeedback.ts","components/Corporate/PageFeedback/index.tsx"],"names":["Wrapper","styled","div","theme","spacing","py","color","sendFeedback","hideOnPrint","Form","form","Title","p","text_m","mq","ThanksText","OptionsWrapper","CommentsWrapper","Label","span","TextArea","textarea","text_s","colors","input","border","element","focused","Submit","button","RichText","ContentRichText","pb","lessThan","px","PageFeedback","props","useTranslation","t","useLocation","pathname","search","history","useHistory","useState","helpful","setHelpful","comment","setComment","loading","setLoading","response","setResponse","error","setError","bowserLoaded","setBowserLoaded","Bowser","useRef","sitecoreContext","editMode","rendering","showPageFeedback","route","fields","onPageFeedback","value","sendFeedbackParam","Number","params","useEffect","a","async","default","getBowser","then","bowser","current","onHelpfulChange","event","target","onSubmit","preventDefault","path","window","location","href","getBrowser","getParser","navigator","userAgent","data","wasHelpful","url","domain","browser","name","version","customText","axios","post","queryString","stringify","headers","catch","err","console","field","Radio","id","onChange","checked","htmlFor","undefined","placeholder","disabled","type","compose","withSitecoreContext"],"mappings":"85DAMO,IAAMA,EAAUC,UAAOC,IAAV,KAChB,gBAAGC,EAAH,EAAGA,MAAH,OAAeC,YAAQ,CAAED,QAAOE,GAAI,MAClBC,YAAM,cAKZ,qBAAGC,aAAgC,4CAC/CC,KAGSC,EAAOR,UAAOS,KAAV,KAOJC,EAAQV,UAAOW,EAAV,IACdC,IAEAC,YAAG,OAKMC,EAAad,UAAOW,EAAV,IAEnBC,KAGSG,EAAiBf,UAAOC,IAAV,KAMde,EAAkBhB,UAAOC,IAAV,KAMfgB,EAAQjB,UAAOkB,KAAV,IAIdL,YAAG,OAKMM,EAAWnB,UAAOoB,SAAV,IACjBC,KACQ,qBAAGnB,MAAkBoB,OAAOb,KAAKc,MAAMC,SAO/CX,YAAG,OAKM,qBAAGX,MAAkBoB,OAAOb,KAAKc,MAAMC,UAMlB,qBAAGtB,MAAkBoB,OAAOG,QAAQC,WAIzDC,EAAS3B,UAAO4B,OAAV,IACfA,YAAO,OAAQ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A,GAAiC,OAAbM,GAC5C,kBAAClC,EAAD,KACE,kBAACG,EAAD,CACE8F,YAAa5E,EAAE,2CACf4B,MAAOnB,EACPiD,KAAK,UACLc,SA3FY,SAAC/B,GACvB/B,EAAW+B,EAAMC,OAAOd,QA2FdiD,SAAUlE,IAEZ,kBAACrB,EAAD,CAAQwF,KAAK,UAAUnE,EAAU,UAAY,SAIhDE,GAAY,kBAACpC,EAAD,kCACZsC,GAAS,kBAACtC,EAAD,kCAlDP,MAwDIsG,sBAAQC,gCAARD,CAA+BlF","file":"static/js/PageFeedback.d735747e.chunk.js","sourcesContent":["import styled from 'styled-components';\r\nimport { text_m, text_s, mq, button, hideOnPrint } from '_utils/styles';\r\nimport color from '_utils/styles/color';\r\nimport { spacing } from '_utils/props';\r\nimport { ContentRichText } from '../ContentRichText';\r\n\r\nexport const Wrapper = styled.div`\r\n ${({ theme }) => spacing({ theme, py: 7 })}\r\n background-color: ${color('all.white')};\r\n overflow: hidden;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n border-top: ${({ sendFeedback }) => (sendFeedback ? `2px solid #DDDEE1;` : `1px solid #DDDEE1;`)};\r\n ${hideOnPrint}\r\n`;\r\n\r\nexport const Form = styled.form`\r\n height: 88px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n`;\r\n\r\nexport const Title = styled.p`\r\n ${text_m}\r\n margin: 0 16px 0;\r\n ${mq('md')} {\r\n margin: 0 24px 0;\r\n }\r\n`;\r\n\r\nexport const ThanksText = styled.p`\r\n text-align: center;\r\n ${text_m}\r\n`;\r\n\r\nexport const OptionsWrapper = styled.div`\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n`;\r\n\r\nexport const CommentsWrapper = styled.div`\r\n align-items: center;\r\n justify-content: center;\r\n display: flex;\r\n`;\r\n\r\nexport const Label = styled.span`\r\n display: block;\r\n\r\n margin-right: 16px;\r\n ${mq('md')} {\r\n margin-right: 24px;\r\n }\r\n`;\r\n\r\nexport const TextArea = styled.textarea`\r\n ${text_s};\r\n border: ${({ theme }) => theme.colors.form.input.border};\r\n height: 88px;\r\n width: 176px;\r\n padding: 16px;\r\n margin-right: 16px;\r\n border-radius: 4px;\r\n position: relative;\r\n ${mq('md')} {\r\n width: 372px;\r\n margin-right: 24px;\r\n }\r\n &::placeholder {\r\n color: ${({ theme }) => theme.colors.form.input.border};\r\n }\r\n outline: 0;\r\n\r\n /* psuedo focus outline */\r\n &:focus {\r\n box-shadow: 0px 0px 0px 2px ${({ theme }) => theme.colors.element.focused};\r\n }\r\n`;\r\n\r\nexport const Submit = styled.button`\r\n ${button('slim', 'primary')}\r\n`;\r\n\r\nexport const RichText = styled(ContentRichText)`\r\n ${({ theme }) =>\r\n spacing({\r\n theme,\r\n pb: 3\r\n })}\r\n text-align: center;\r\n ${mq.lessThan('md')} {\r\n ${({ theme }) => spacing({ theme, px: 5 })}\r\n }\r\n`;\r\n","import React, { useState, useEffect, useRef } from 'react';\r\nimport { compose } from 'ramda';\r\nimport { useLocation, useHistory } from 'react-router-dom';\r\nimport { withSitecoreContext } from '@sitecore-jss/sitecore-jss-react';\r\nimport axios from 'axios';\r\nimport queryString from 'query-string';\r\nimport { useTranslation } from 'react-i18next';\r\n\r\nimport {\r\n Wrapper,\r\n Form,\r\n OptionsWrapper,\r\n CommentsWrapper,\r\n Label,\r\n Title,\r\n ThanksText,\r\n TextArea,\r\n Submit,\r\n RichText\r\n} from './StyledPageFeedback';\r\n\r\nimport Radio from '_utils/components/Corporate/Radio';\r\n\r\nexport const PageFeedback = (props) => {\r\n const [t] = useTranslation();\r\n const { pathname, search } = useLocation();\r\n const history = useHistory();\r\n const [helpful, setHelpful] = useState(null);\r\n const [comment, setComment] = useState('');\r\n const [loading, setLoading] = useState(false);\r\n const [response, setResponse] = useState(null);\r\n const [error, setError] = useState(null);\r\n const [bowserLoaded, setBowserLoaded] = useState(null);\r\n const Bowser = useRef();\r\n\r\n const { sitecoreContext, editMode, rendering } = props;\r\n const showPageFeedback = sitecoreContext?.route?.fields?.onPageFeedback.value || null;\r\n const sendFeedbackParam = Number(rendering?.params?.sendFeedback);\r\n\r\n const endpoint =\r\n 'https://script.google.com/macros/s/AKfycbysjcflZyONKGhwLjHf6TFIawugXvA2MOvNjAzzfKp0-BuLOh-c9i6R59ybbwPcLeBuwQ/exec';\r\n\r\n useEffect(() => {\r\n // optimise initial load by deferring this lib\r\n async function getBowser() {\r\n const { default: Bowser } = await import(/* webpackChunkName: \"bowser\" */ 'bowser');\r\n return Bowser;\r\n }\r\n\r\n getBowser().then((bowser) => {\r\n Bowser.current = bowser;\r\n setBowserLoaded(true);\r\n });\r\n }, []);\r\n\r\n // reset form on page transition\r\n useEffect(() => {\r\n setHelpful(null);\r\n setComment('');\r\n setLoading(false);\r\n setResponse(null);\r\n setError(null);\r\n }, [pathname, search]);\r\n\r\n if (editMode || !showPageFeedback) {\r\n return null;\r\n }\r\n\r\n const onHelpfulChange = (event) => {\r\n setHelpful(event.target.value);\r\n };\r\n\r\n const onCommentChange = (event) => {\r\n setComment(event.target.value);\r\n };\r\n\r\n const handleFormSubmit = (event) => {\r\n event.preventDefault();\r\n\r\n setLoading(true);\r\n\r\n let path = '';\r\n path = window.location.href;\r\n const browser = Bowser.current.getParser(window.navigator.userAgent);\r\n let getBrowser = browser.getBrowser();\r\n\r\n let data = {\r\n wasHelpful: helpful,\r\n comment,\r\n url: path,\r\n domain: 'www.cityofsydney.nsw.gov.au',\r\n browser: `${getBrowser.name} ${getBrowser.version}`,\r\n customText: t('page-feedback-question-text')\r\n };\r\n\r\n const headers = {\r\n 'Content-Type': 'application/x-www-form-urlencoded'\r\n };\r\n\r\n axios\r\n .post(endpoint, queryString.stringify(data), {\r\n headers: headers\r\n })\r\n .then((response) => {\r\n if (response && response.data) {\r\n setResponse(response.data);\r\n }\r\n })\r\n .catch((err) => {\r\n if (err) {\r\n console.error(err);\r\n\r\n setError(err);\r\n }\r\n })\r\n .then(() => {\r\n setLoading(false);\r\n });\r\n };\r\n\r\n if (!bowserLoaded) {\r\n return null;\r\n }\r\n\r\n return (\r\n \r\n
\r\n {helpful === null && sendFeedbackParam !== 1 ? (\r\n \r\n ) : (\r\n \r\n {t('page-feedback-question-text')}\r\n
\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n
\r\n
\r\n )}\r\n\r\n {helpful !== undefined && helpful !== null && response === null && (\r\n \r\n \r\n {loading ? 'Sending' : 'Send'}\r\n \r\n )}\r\n\r\n {response && Thanks for your feedback!}\r\n {error && Failed to send feedback}\r\n \r\n
\r\n );\r\n};\r\n\r\nexport default compose(withSitecoreContext())(PageFeedback);\r\n"],"sourceRoot":""}