feat(SW-66, SW-348): search functionality and ui

This commit is contained in:
Simon Emanuelsson
2024-08-28 10:47:57 +02:00
parent b9dbcf7d90
commit af850c90e7
437 changed files with 7663 additions and 9881 deletions
@@ -21,73 +21,74 @@ import { affix as bookingwidgetAffix } from "./utils"
import { ContentTypeEnum } from "@/types/requests/contentType"
export const bookingwidgetQueryRouter = router({
getToggle: contentstackBaseProcedure.query(async ({ ctx }) => {
const failedResponse = { hideBookingWidget: false }
const { contentType, uid, lang } = ctx
toggle: router({
get: contentstackBaseProcedure.query(async ({ ctx }) => {
const failedResponse = { hideBookingWidget: false }
const { contentType, uid, lang } = ctx
// This condition is to handle 404 page case
if (!contentType || !uid) {
console.log("No proper params defined: ", contentType, uid)
return failedResponse
}
let GetPageSettings = ""
const contentTypeCMS = <ValueOf<typeof ContentTypeEnum>>(
contentType.replaceAll("-", "_")
)
switch (contentTypeCMS) {
case ContentTypeEnum.accountPage:
GetPageSettings = GetAccountPageSettings
break
case ContentTypeEnum.loyaltyPage:
GetPageSettings = GetLoyaltyPageSettings
break
case ContentTypeEnum.contentPage:
GetPageSettings = GetContentPageSettings
break
case ContentTypeEnum.hotelPage:
GetPageSettings = GetHotelPageSettings
break
case ContentTypeEnum.currentBlocksPage:
GetPageSettings = GetCurrentBlocksPageSettings
break
}
if (!GetPageSettings) {
console.error("No proper Content type defined: ", contentType)
return failedResponse
}
const response = await request<ValidateBookingWidgetToggleType>(
GetPageSettings,
{
uid: uid,
locale: lang,
},
{
next: {
tags: [generateTag(lang, uid, bookingwidgetAffix)],
},
// This condition is to handle 404 page case
if (!contentType || !uid) {
console.log("No proper params defined: ", contentType, uid)
return failedResponse
}
)
const bookingWidgetToggleData = validateBookingWidgetToggleSchema.safeParse(
response.data
)
if (!bookingWidgetToggleData.success) {
console.error(
"Flag hide_booking_widget fetch error: ",
bookingWidgetToggleData.error
let GetPageSettings = ""
const contentTypeCMS = <ValueOf<typeof ContentTypeEnum>>(
contentType.replaceAll("-", "_")
)
return failedResponse
}
const hideBookingWidget =
bookingWidgetToggleData.data[contentTypeCMS]?.page_settings
?.hide_booking_widget
switch (contentTypeCMS) {
case ContentTypeEnum.accountPage:
GetPageSettings = GetAccountPageSettings
break
case ContentTypeEnum.loyaltyPage:
GetPageSettings = GetLoyaltyPageSettings
break
case ContentTypeEnum.contentPage:
GetPageSettings = GetContentPageSettings
break
case ContentTypeEnum.hotelPage:
GetPageSettings = GetHotelPageSettings
break
case ContentTypeEnum.currentBlocksPage:
GetPageSettings = GetCurrentBlocksPageSettings
break
}
return {
hideBookingWidget,
}
if (!GetPageSettings) {
console.error("No proper Content type defined: ", contentType)
return failedResponse
}
const response = await request<ValidateBookingWidgetToggleType>(
GetPageSettings,
{
uid: uid,
locale: lang,
},
{
next: {
tags: [generateTag(lang, uid, bookingwidgetAffix)],
},
}
)
const bookingWidgetToggleData =
validateBookingWidgetToggleSchema.safeParse(response.data)
if (!bookingWidgetToggleData.success) {
console.error(
"Flag hide_booking_widget fetch error: ",
bookingWidgetToggleData.error
)
return failedResponse
}
const hideBookingWidget =
!!bookingWidgetToggleData.data[contentTypeCMS]?.page_settings
?.hide_booking_widget
return {
hideBookingWidget,
}
}),
}),
})