Merged in feature/select-rate-vertical-data-flow (pull request #2535)
Feature/select rate vertical data flow * add fix from SW-2666 * use translations for room packages * move types to it's own file * Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/select-rate-vertical-data-flow * merge * feature/select-rate: double rate for campaing rates * revert NODE_ENV check in Cookiebot script * revert testing values * fix(SW-3171): fix all filter selected in price details * fix(SW-3166): multiroom anchoring when changing filter * fix(SW-3172): check hotelType, show correct breakfast message * Merge branch 'feature/select-rate-vertical-data-flow' of bitbucket.org:scandic-swap/web into feature/select-rate-vertical-data-flow * fix: show special needs icons for subsequent roomTypes SW-3167 * fix: Display strike through text when logged in SW-3168 * fix: Reinstate the scrollToView behaviour when selecting a rate SW-3169 * merge * . * PR fixes * fix: don't return notFound() * . * always include defaults for room packages * merge * merge * merge * Remove floating h1 for new select-rate Approved-by: Anton Gunnarsson
This commit is contained in:
68
apps/scandic-web/contexts/SelectRate/DebugButton.tsx
Normal file
68
apps/scandic-web/contexts/SelectRate/DebugButton.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
import { Button } from "@scandic-hotels/design-system/Button"
|
||||
|
||||
import { useSelectRateContext } from "./SelectRateContext"
|
||||
import { type SelectRateContext } from "./types"
|
||||
|
||||
export function DebugButton() {
|
||||
const context = useSelectRateContext()
|
||||
|
||||
if (process.env.NODE_ENV !== "development") {
|
||||
return null
|
||||
}
|
||||
|
||||
const handleClick = () => {
|
||||
const allRoomAvailability = getAllRoomAvailability(context)
|
||||
const allRoomPackages = getAllRoomPackages(context)
|
||||
console.log("%c SelectRateContext: ", "background: #AD0015; color: #FFF", {
|
||||
...context,
|
||||
...allRoomAvailability,
|
||||
...allRoomPackages,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
style={{
|
||||
position: "fixed",
|
||||
bottom: "1rem",
|
||||
right: "4rem",
|
||||
background: "green",
|
||||
border: "none",
|
||||
padding: "0.5rem 1rem",
|
||||
zIndex: 1000,
|
||||
}}
|
||||
onClick={handleClick}
|
||||
// eslint-disable-next-line formatjs/no-literal-string-in-jsx
|
||||
>
|
||||
DEBUG
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function getAllRoomAvailability(context: SelectRateContext) {
|
||||
const obj: Record<
|
||||
string,
|
||||
ReturnType<SelectRateContext["getAvailabilityForRoom"]> | null
|
||||
> = {}
|
||||
for (let i = 0; i < context.input.roomCount; i++) {
|
||||
const key = `getAvailabilityForRoom(${i})`
|
||||
const availability = context.getAvailabilityForRoom(i) ?? null
|
||||
obj[key] = availability
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
function getAllRoomPackages(context: SelectRateContext) {
|
||||
const obj: Record<
|
||||
string,
|
||||
ReturnType<SelectRateContext["getPackagesForRoom"]> | null
|
||||
> = {}
|
||||
for (let i = 0; i < context.input.roomCount; i++) {
|
||||
const key = `getPackagesForRoom(${i})`
|
||||
const availability = context.getPackagesForRoom(i) ?? null
|
||||
obj[key] = availability
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
Reference in New Issue
Block a user