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AAQ,EAAzG,EAXV,KAgBD0B,IAAekC,EAAWC,WACzB,OAAK,UAAU,iCAAf,WACGjE,GAAaD,OAAd,EA5HN,KAFJ,EAsIF,SACEoI,aACGD,EAAK,EACLpG,IAAekC,EAAWC,SAAWb,GACpCzC,EAACoI,GAAD,CACE,eACA,SAAU,GACV,QAAStB,EACT,SAAU,wBACV,0BAAkC,IAC5BzF,EACSyF,IAEPrE,GACElE,EAAIC,SACND,EAAIC,QAAQ6J,OAInB,EACD,gBAAiB,IAAM,CACjB9J,EAAIC,SAAWD,EAAIC,UAAY8J,SAASC,eAC1ChK,EAAIC,QAAQgK,MAEf,EApBH,SAsBGjB,EAAM,EAAD,CAtBR,GAyBDxF,GAAkBE,MAChBhC,GAAD,CAEE,QAASkC,EACT,UAAWJ,EAAe9C,UAC1B,SAAU8C,EAAe/C,SACzB,MAAO+C,EAAesC,MACtB,iBAAkBmC,IALb,EAAEpG,EADT,EASDmC,KAAakG,GAAoC,IAAGlG,EAAU,GAAGtE,GAAMyK,KAAMC,QAAS3B,IAA3D,EAAE5G,EAAjB,CAtCf,EADF,CA0CD","names":["priceApiUrl","getPriceAsync","body","postAsync","IconWithScroll","props","handleClick","event","preventDefault","scrollAnchor","scrollToSection","ref","current","getAttribute","useRef","target","mainClass","Svg","serviceApiUrl","getServiceAsync","postcode","serviceId","getAsync","loadTrustpilot","trustpilot","TrustBox","locale","templateId","businessunitId","height","reviewUrl","theme","stars","width","React","useEffect","_jsx","OrderFlow","lazy","__vitePreload","orderFlowKey","ServiceShoppingForm","ctaTexts","getQuoteMessage","loginMessage","paymentPeriod","postcodePlaceholder","postcodeTooltip","savedPostCode","productNotAvailableInRegion","postCodePattern","startingPrice","title","validationMessages","requiredValidationText","breakpoint","useBreakpoint","closeClicked","setCloseClicked","useState","finalPrice","setFinalPrice","totalPriceWithoutVAT","setTotalPriceWithoutVAT","priceTooltip","setPriceTooltip","setPostcode","orderFlowModel","setOrderFlowModel","orderFlowVisible","setOrderFlowVisible","orderInfo","setOrderInfo","isApiCalling","setIsApiCalling","cartInfo","setCartInfo","showReplicate","setShowReplicate","formSubmitTitle","setFormSubmitTitle","formSubmitText","setFormSubmitText","isValid","setIsValid","errors","setErrors","finalPaymentPeriod","setFinalPaymentPeriod","Breakpoint","desktop","handleValidatePostCode","value","hasError","push","RegExp","test","trim","invalidPostcode","pushContinueClickEvent","window","dataLayer","handleContinueClick","then","data","steps","constructor","Array","length","catch","error","console","log","finally","handlePostCodeChange","handleEditSelection","findIndex","s","type","StepType","userGate","filter","callGetPriceApiAsync","order","items","totalPrice","notIncludeVatTotalPrice","tooltip","callAddToCartApiAsync","addToCartAsync","item","name","variant","description","price","priceIncludedTax","quantity","id","productId","updateCountItemsInCart","handleOrderFlowClose","undefined","promises","all","values","handleAddToCart","handleClose","ref2","handleCloseMinicart","handlePostcodeClick","replicate","disabled","classWithOptionalReplicateModifier","baseClass","className","inner","_Fragment","_jsxs","__html","Button","continue","PostcodeBox","IconWithTooltip","addToCart","edit","iconPath","viewBoxWidth","viewBoxHeight","FullModal","focus","document","activeElement","blur","MiniCart","cart","onClose"],"sources":["../../../../firstmile.widgets/src/api/price.ts","../../../../firstmile.widgets/src/components/icon-with-scroll/IconWithScroll.tsx","../../../../firstmile.widgets/src/api/service.ts","../../../../firstmile.widgets/src/components/trustbox/trust-box-helper.ts","../../../../firstmile.widgets/src/components/trustbox/TrustBox.tsx","../../../../firstmile.widgets/src/blocks/service-order-form/PostCodeForm.tsx"],"sourcesContent":["import { postAsync } from \"./_base\";\n\nconst priceApiUrl = import.meta.env.VITE_APP_API_PRICE_URL\n\nexport const getPriceAsync = (body: any) => {\n return postAsync(priceApiUrl, undefined, body);\n}","import Svg from \"@src/components/svg/Svg\";\nimport { SyntheticEvent, useRef } from \"react\";\n\ninterface Props {\n target: string;\n mainClass?: string;\n}\n\nconst IconWithScroll = (props: Props) => {\n const handleClick = (event: SyntheticEvent) => {\n event.preventDefault();\n \n // @ts-ignore\n if(typeof scrollAnchor === 'undefined') {\n return;\n }\n\n // @ts-ignore\n scrollAnchor.scrollToSection(ref.current?.getAttribute('href'));\n }\n\n const ref = useRef(null);\n\n return (\n \n \n \n );\n};\n\nexport default IconWithScroll;\n","import { getAsync } from \"./_base\"\n\nconst serviceApiUrl = import.meta.env.VITE_APP_API_SERVICE_URL;\n\nexport const getServiceAsync = (postcode: string, serviceId: number) => {\n return getAsync(serviceApiUrl + '/' + serviceId, { postcode });\n}","export const loadTrustpilot = (ref: any) => {\n // If window.Trustpilot is available it means that we need to load the TrustBox from our ref.\n // If it's not, it means the script you pasted into isn't loaded just yet.\n // When it is, it will automatically load the TrustBox.\n const trustpilot = (window).Trustpilot;\n if (trustpilot) {\n trustpilot.loadFromElement(ref, true);\n }\n}","import React from \"react\";\nimport { loadTrustpilot } from \"./trust-box-helper\";\n\n// See: https://support.trustpilot.com/hc/en-us/articles/115011421468--Add-a-TrustBox-widget-to-a-single-page-application#add-a-trustbox-widget-with-a-react-application-1\n\nexport interface TrustBoxProps {\n locale: string;\n templateId: string;\n businessunitId: string;\n height: string;\n width: string;\n theme: string;\n reviewUrl?: string;\n stars?: string;\n}\n\nconst TrustBox = ({ locale, templateId, businessunitId, height, reviewUrl, theme, stars, width }: TrustBoxProps) => {\n // Create a reference to the
element which will represent the TrustBox\n const ref = React.useRef(null);\n\n React.useEffect(() => {\n loadTrustpilot(ref.current);\n }, []);\n\n return (\n \n {reviewUrl && (\n \n Trustpilot\n \n )}\n
\n );\n};\nexport default TrustBox;\n","import { addToCartAsync, updateCountItemsInCart } from \"@src/api/cart\";\nimport { getPriceAsync } from \"@src/api/price\";\nimport { OrderInfo } from \"@src/app/order-info-context\";\nimport { CartModel } from \"@src/app/types\";\nimport PostcodeBox from \"@src/components/form/PostcodeBox\";\nimport IconWithTooltip from \"@src/components/icon-with-tooltip/IconWithTooltip\";\nimport IconWithScroll from \"@src/components/icon-with-scroll/IconWithScroll\";\nimport FullModal from \"@src/components/modal/FullModal\";\nimport useBreakpoint, { Breakpoint } from \"@src/hooks/use-breakpoint\";\nimport { lazy, useEffect, useRef } from \"react\";\nimport { useState } from \"react\";\nimport { getServiceAsync } from \"../../api/service\";\nimport Button from \"../../components/button/Button\";\nimport TrustBox, { TrustBoxProps } from \"../../components/trustbox/TrustBox\";\nimport MiniCart from \"../mini-cart/MiniCart\";\nimport { OrderFlowModel, StepType } from \"../order-flow/OrderFlow\";\nimport { gtmPushEventAddToCart } from \"@src/helpers/gtm\";\n\nconst OrderFlow = lazy(() => import(\"../order-flow/OrderFlow\"));\n\ninterface ValidationMessages {\n invalidPostcode: string;\n}\n\ninterface CtaTexts {\n continue: string;\n edit: string;\n addToCart: string;\n}\n\ninterface Cart {\n addedToCartText: string;\n viewCartText: string;\n viewCartUrl: string;\n checkoutText: string;\n checkoutUrl: string;\n vatText: string;\n totalText: string;\n}\n\ninterface Props {\n ctaTexts: CtaTexts;\n getQuoteMessage: string;\n loginMessage: string;\n paymentPeriod: string;\n postCodePattern: string;\n cart: Cart;\n postcodePlaceholder: string;\n postcodeTooltip: string;\n savedPostCode: string;\n productNotAvailableInRegion: string;\n serviceId: number;\n startingPrice: string;\n title: string;\n trustpilot: TrustBoxProps;\n validationMessages: ValidationMessages;\n requiredValidationText?: string;\n}\n\nlet orderFlowKey = 1;\n\nconst ServiceShoppingForm = ({\n ctaTexts,\n getQuoteMessage,\n loginMessage,\n paymentPeriod,\n postcodePlaceholder,\n postcodeTooltip,\n savedPostCode,\n productNotAvailableInRegion,\n postCodePattern,\n serviceId,\n startingPrice,\n title,\n trustpilot,\n validationMessages,\n requiredValidationText,\n ...props\n}: Props) => {\n const breakpoint = useBreakpoint();\n const [closeClicked, setCloseClicked] = useState(false);\n const [finalPrice, setFinalPrice] = useState();\n const [totalPriceWithoutVAT, setTotalPriceWithoutVAT] = useState();\n const [priceTooltip, setPriceTooltip] = useState();\n const [postcode, setPostcode] = useState();\n const [orderFlowModel, setOrderFlowModel] = useState();\n const [orderFlowVisible, setOrderFlowVisible] = useState(false);\n const [orderInfo, setOrderInfo] = useState();\n const [isApiCalling, setIsApiCalling] = useState(false);\n const [cartInfo, setCartInfo] = useState();\n const [showReplicate, setShowReplicate] = useState(false);\n const [formSubmitTitle, setFormSubmitTitle] = useState();\n const [formSubmitText, setFormSubmitText] = useState();\n const [isValid, setIsValid] = useState(true);\n const [errors, setErrors] = useState([]);\n\n const [finalPaymentPeriod, setFinalPaymentPeriod] = useState(paymentPeriod);\n\n useEffect(() => {\n if (breakpoint === Breakpoint.desktop) {\n setShowReplicate(false);\n }\n }, [breakpoint]);\n\n useEffect(() => {\n if (savedPostCode) {\n setPostcode(savedPostCode);\n }\n }, []);\n\n const handleValidatePostCode = (value?: string) => {\n let hasError = false;\n const errors: string[] = [];\n\n if (!value) {\n hasError = true;\n if (requiredValidationText) {\n errors.push(requiredValidationText);\n }\n }\n\n if (postCodePattern) {\n if (!value || !new RegExp(postCodePattern, \"gi\").test(value.trim())) {\n hasError = true;\n\n if (validationMessages.invalidPostcode) {\n errors.push(validationMessages.invalidPostcode);\n }\n }\n }\n\n return {\n isValid: !hasError,\n errors,\n };\n };\n\n const pushContinueClickEvent = () => {\n if (window.dataLayer)\n window.dataLayer.push({\n event: \"postcodeEntered\",\n });\n };\n\n const handleContinueClick = () => {\n const { isValid, errors } = handleValidatePostCode(postcode);\n setIsValid(isValid);\n setErrors(errors);\n\n if (!postcode || !isValid) {\n return;\n }\n\n pushContinueClickEvent();\n setIsApiCalling(true);\n getServiceAsync(postcode.trim(), serviceId)\n .then((data: OrderFlowModel) => {\n if (data.postcode && data.steps.constructor === Array && data.steps.length) {\n setOrderFlowModel(data);\n setOrderFlowVisible(true);\n }\n })\n .catch((error) => {\n console.log(error);\n setOrderFlowVisible(false);\n })\n .finally(() => setIsApiCalling(false));\n };\n\n const handlePostCodeChange = (value: string | undefined) => {\n setPostcode(value);\n setErrors([]);\n setIsValid(true);\n };\n\n const handleEditSelection = () => {\n if (orderFlowModel?.steps?.length) {\n const userGateIndex = orderFlowModel.steps.findIndex((s) => s.type == StepType.userGate);\n if (userGateIndex >= 0) {\n setOrderFlowModel({ ...orderFlowModel, steps: orderFlowModel.steps.filter((s) => s.type !== StepType.userGate) });\n }\n\n setOrderFlowVisible(true);\n }\n };\n\n const callGetPriceApiAsync = async (order: OrderInfo) => {\n const data = await getPriceAsync({ items: [order], paymentPeriod });\n setFinalPrice(data.totalPrice);\n if (data.paymentPeriod) setFinalPaymentPeriod(data.paymentPeriod);\n setTotalPriceWithoutVAT(data.notIncludeVatTotalPrice);\n setPriceTooltip(data.tooltip);\n setFormSubmitTitle(data.formSubmitTitle);\n setFormSubmitText(data.formSubmitText);\n };\n\n const callAddToCartApiAsync = async (order: OrderInfo) => {\n const data = await addToCartAsync({ items: [order] });\n const item = data.items[0];\n gtmPushEventAddToCart({\n name: item.name,\n variant: item.description,\n price: item.priceIncludedTax,\n quantity: item.quantity,\n id: item.productId,\n });\n updateCountItemsInCart();\n return data;\n };\n\n const handleOrderFlowClose = (orderInfo?: any) => {\n setOrderFlowVisible(false);\n\n if (orderInfo) {\n setFinalPrice(undefined);\n setOrderInfo(orderInfo);\n setIsApiCalling(true);\n const promises = [callAddToCartApiAsync(orderInfo), callGetPriceApiAsync(orderInfo)];\n Promise.all(promises)\n .then((values) => setCartInfo(values[0]))\n .catch((error) => {\n console.log(error);\n })\n .finally(() => setIsApiCalling(false));\n }\n };\n\n const handleAddToCart = () => {\n if (orderInfo) {\n setCartInfo(undefined);\n setIsApiCalling(true);\n callAddToCartApiAsync(orderInfo)\n .then((data) => setCartInfo(data as CartModel))\n .catch((error) => {\n console.log(error);\n })\n .finally(() => setIsApiCalling(false));\n }\n };\n\n const handleClose = () => {\n if (closeClicked) {\n setShowReplicate(false);\n setCloseClicked(false);\n } else {\n setCloseClicked(true);\n }\n };\n\n const ref = useRef(null);\n\n (window as any).ref2 = ref;\n\n const handleCloseMinicart = () => {\n setCartInfo(undefined);\n };\n\n const handlePostcodeClick = (replicate?: boolean) => {\n if (!replicate && breakpoint != Breakpoint.desktop) {\n setShowReplicate(true);\n }\n };\n\n const disabled = isApiCalling;\n\n const classWithOptionalReplicateModifier = (baseClass: string, replicate?: boolean) => {\n let className = baseClass;\n\n if (replicate) {\n className += \" \" + baseClass + \"--replicate\";\n }\n\n if (finalPrice) {\n className += \" \" + baseClass + \"--has-price\";\n }\n\n return className;\n };\n\n const inner = (replicate?: boolean) => {\n return (\n
\n
\n {savedPostCode && !finalPrice && !formSubmitTitle && (\n <>\n

{title}

\n

{startingPrice}

\n
\n
{postcode}
\n {productNotAvailableInRegion && (\n
\n )}\n {!productNotAvailableInRegion && (\n \n )}\n
\n
\n
\n
\n
\n \n )}\n\n {!finalPrice && !formSubmitTitle && !savedPostCode && (\n <>\n

{title}

\n

{startingPrice}

\n\n handlePostcodeClick(replicate)}\n onChange={handlePostCodeChange}\n isValid={isValid}\n errors={errors}\n ref={replicate ? ref : undefined}\n />\n\n {(breakpoint == Breakpoint.desktop || replicate) && (\n \n )}\n\n
\n
\n \n \n\n {!replicate && breakpoint != Breakpoint.desktop && (\n
\n \n
\n )}\n \n )}\n {finalPrice && (\n <>\n
\n

{totalPriceWithoutVAT}

\n {priceTooltip && }\n
\n

{finalPaymentPeriod}

\n \n \n \n )}\n\n {formSubmitTitle && (\n <>\n
\n

{formSubmitTitle}

\n {formSubmitText &&
{formSubmitText}
}\n
\n \n \n )}\n\n {breakpoint === Breakpoint.desktop && (\n
\n \n
\n )}\n \n \n );\n };\n\n return (\n <>\n {inner()}\n {breakpoint !== Breakpoint.desktop && showReplicate && (\n {\n if (closeClicked) {\n handleClose();\n } else {\n if (showReplicate) {\n if (ref.current) {\n ref.current.focus();\n }\n }\n }\n }}\n handleTouchMove={() => {\n if (ref.current && ref.current === document.activeElement) {\n ref.current.blur();\n }\n }}\n >\n {inner(true)}\n \n )}\n {orderFlowModel && orderFlowVisible && (\n \n )}\n {cartInfo && }\n \n );\n};\n\nexport default ServiceShoppingForm;\n"],"file":"assets/app/post-code-form-b7ef225f.js"}