Merged in feature/SW-3516-pass-eurobonus-number-on-booking (pull request #2902)

* feat(SW-3516): Include partnerLoyaltyNumber on bookings

- Added user context to BookingFlowProviders for user state management.
- Updated booking input and output schemas to accommodate new user data.
- Refactored booking mutation logic to include user-related information.
- Improved type definitions for better TypeScript support across booking components.


Approved-by: Anton Gunnarsson
This commit is contained in:
Joakim Jäderberg
2025-10-08 10:48:42 +00:00
parent b685c928e4
commit 17df3ee71a
18 changed files with 510 additions and 370 deletions

View File

@@ -1,32 +1,6 @@
import { useSession } from "next-auth/react"
import { logger } from "@scandic-hotels/common/logger"
import type { Session } from "next-auth"
import { useBookingFlowContext } from "@scandic-hotels/booking-flow/hooks/useBookingFlowContext"
export function useIsUserLoggedIn() {
const { data: session } = useSession()
const isUserLoggedIn = isValidClientSession(session)
return isUserLoggedIn
}
function isValidClientSession(session: Session | null) {
if (!session) {
return false
}
if (session.error) {
logger.error(`Session error: ${session.error}`)
return false
}
if (session.token.error) {
logger.error(`Session token error: ${session.token.error}`)
return false
}
if (session.token.expires_at && session.token.expires_at < Date.now()) {
logger.error(`Session expired: ${session.token.expires_at}`)
return false
}
return true
const { isLoggedIn } = useBookingFlowContext()
return isLoggedIn
}