feat(SW-2719): Added Dialogshift chat widget to certain hotel pages
Approved-by: Matilda Landström
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import "dialogshift-webchat-sdk/bundles/dialogshift-webchat-sdk.min.css"
|
||||||
|
|
||||||
|
import { useEffect, useRef } from "react"
|
||||||
|
|
||||||
|
import type { Lang } from "@/constants/languages"
|
||||||
|
|
||||||
|
interface DialogshiftWidgetClientProps {
|
||||||
|
widgetId: string
|
||||||
|
language: Lang
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DialogshiftWidgetClient({
|
||||||
|
widgetId,
|
||||||
|
language,
|
||||||
|
}: DialogshiftWidgetClientProps) {
|
||||||
|
const dialogshiftRef = useRef<any>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadDialogshift = async () => {
|
||||||
|
try {
|
||||||
|
dialogshiftRef.current = await import("dialogshift-webchat-sdk")
|
||||||
|
dialogshiftRef.current.instance({
|
||||||
|
id: widgetId,
|
||||||
|
locale: language,
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load Dialogshift chat:", error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dialogshiftRef.current) {
|
||||||
|
loadDialogshift()
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (dialogshiftRef.current?.instance) {
|
||||||
|
dialogshiftRef.current.instance().destroy()
|
||||||
|
dialogshiftRef.current = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [widgetId, language])
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { getLang } from "@/i18n/serverContext"
|
||||||
|
|
||||||
|
import DialogshiftWidgetClient from "./Client"
|
||||||
|
|
||||||
|
interface DialogshiftWidgetProps {
|
||||||
|
hotelId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const DIALOG_SHIFT_WIDGET_IDS = [
|
||||||
|
{
|
||||||
|
hotelName: "Scandic Berlin Kurfürstendamm",
|
||||||
|
hotelId: "554",
|
||||||
|
widgetId: "pro1dbe",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hotelName: "Scandic Berlin Potsdamer Platz",
|
||||||
|
hotelId: "551",
|
||||||
|
widgetId: "pro2363",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hotelName: "Scandic Hamburg Emporio",
|
||||||
|
hotelId: "550",
|
||||||
|
widgetId: "pro219b",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export default async function DialogshiftWidget({
|
||||||
|
hotelId,
|
||||||
|
}: DialogshiftWidgetProps) {
|
||||||
|
const lang = await getLang()
|
||||||
|
const widgetId = DIALOG_SHIFT_WIDGET_IDS.find(
|
||||||
|
(item) => item.hotelId === hotelId
|
||||||
|
)?.widgetId
|
||||||
|
|
||||||
|
if (!widgetId) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return <DialogshiftWidgetClient widgetId={widgetId} language={lang} />
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ import RestaurantBarSidePeek from "./SidePeeks/RestaurantBar"
|
|||||||
import RoomSidePeek from "./SidePeeks/Room"
|
import RoomSidePeek from "./SidePeeks/Room"
|
||||||
import WellnessAndExerciseSidePeek from "./SidePeeks/WellnessAndExercise"
|
import WellnessAndExerciseSidePeek from "./SidePeeks/WellnessAndExercise"
|
||||||
import AmenitiesList from "./AmenitiesList"
|
import AmenitiesList from "./AmenitiesList"
|
||||||
|
import DialogshiftWidget from "./DialogshiftWidget"
|
||||||
import Facilities from "./Facilities"
|
import Facilities from "./Facilities"
|
||||||
import IntroSection from "./IntroSection"
|
import IntroSection from "./IntroSection"
|
||||||
import PreviewImages from "./PreviewImages"
|
import PreviewImages from "./PreviewImages"
|
||||||
@@ -287,6 +288,9 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
|
|||||||
<RoomSidePeek key={room.name} hotelId={hotelId} room={room} />
|
<RoomSidePeek key={room.name} hotelId={hotelId} room={room} />
|
||||||
))}
|
))}
|
||||||
</SidePeeks>
|
</SidePeeks>
|
||||||
|
|
||||||
|
<DialogshiftWidget hotelId={hotelId} />
|
||||||
|
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<TrackingSDK
|
<TrackingSDK
|
||||||
pageData={trackingPageData}
|
pageData={trackingPageData}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"deepmerge": "^4.3.1",
|
"deepmerge": "^4.3.1",
|
||||||
|
"dialogshift-webchat-sdk": "^2.10.1",
|
||||||
"downshift": "^9.0.9",
|
"downshift": "^9.0.9",
|
||||||
"embla-carousel": "^8.6.0",
|
"embla-carousel": "^8.6.0",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
|
|||||||
@@ -7124,6 +7124,7 @@ __metadata:
|
|||||||
date-fns: "npm:^4.1.0"
|
date-fns: "npm:^4.1.0"
|
||||||
dayjs: "npm:^1.11.13"
|
dayjs: "npm:^1.11.13"
|
||||||
deepmerge: "npm:^4.3.1"
|
deepmerge: "npm:^4.3.1"
|
||||||
|
dialogshift-webchat-sdk: "npm:^2.10.1"
|
||||||
dotenv: "npm:^16.5.0"
|
dotenv: "npm:^16.5.0"
|
||||||
downshift: "npm:^9.0.9"
|
downshift: "npm:^9.0.9"
|
||||||
embla-carousel: "npm:^8.6.0"
|
embla-carousel: "npm:^8.6.0"
|
||||||
@@ -12497,6 +12498,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"dialogshift-webchat-sdk@npm:^2.10.1":
|
||||||
|
version: 2.10.1
|
||||||
|
resolution: "dialogshift-webchat-sdk@npm:2.10.1"
|
||||||
|
checksum: 10c0/6b88f5818093792516307dcf70edbb7f686d88982894fe29703b9a0f83876cd39b944d3f1bf2ee4495f203a96b918fa3114412d716d2ca02ca11ceff115635c7
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"diff-sequences@npm:^29.6.3":
|
"diff-sequences@npm:^29.6.3":
|
||||||
version: 29.6.3
|
version: 29.6.3
|
||||||
resolution: "diff-sequences@npm:29.6.3"
|
resolution: "diff-sequences@npm:29.6.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user