feat(SW-2708): Meeting package widget mobile UI
Approved-by: Matilda Landström
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import useLang from "@/hooks/useLang"
|
||||
|
||||
const SOURCE =
|
||||
"https://scandic-bookingengine.s3.eu-central-1.amazonaws.com/script_stage.js"
|
||||
|
||||
export function useMeetingPackageWidget(destination?: string) {
|
||||
const lang = useLang()
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const script = document.createElement("script")
|
||||
script.src = SOURCE
|
||||
script.setAttribute("langcode", lang || "en")
|
||||
script.setAttribute("whitelabel_id", "224905")
|
||||
script.setAttribute("widget_id", "scandic_default_new")
|
||||
script.setAttribute("version", "frontpage-scandic")
|
||||
if (destination) {
|
||||
script.setAttribute("destination", destination)
|
||||
}
|
||||
document.body.appendChild(script)
|
||||
|
||||
function onLoad() {
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
script.addEventListener("load", onLoad)
|
||||
|
||||
return () => {
|
||||
script.removeEventListener("load", onLoad)
|
||||
document.body.removeChild(script)
|
||||
}
|
||||
}, [destination, lang])
|
||||
|
||||
return { isLoading }
|
||||
}
|
||||
Reference in New Issue
Block a user