Merged in feat/SW-3548-contact-details-prefill-of- (pull request #3027)
feat(SW-3548): Fetch user data for unlinked users on details page Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -14,6 +14,7 @@ import { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
|||||||
|
|
||||||
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
|
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
||||||
|
import { useBookingFlowContext } from "../../../../hooks/useBookingFlowContext"
|
||||||
import useLang from "../../../../hooks/useLang"
|
import useLang from "../../../../hooks/useLang"
|
||||||
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
||||||
import { useEnterDetailsStore } from "../../../../stores/enter-details"
|
import { useEnterDetailsStore } from "../../../../stores/enter-details"
|
||||||
@@ -45,6 +46,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const config = useBookingFlowConfig()
|
const config = useBookingFlowConfig()
|
||||||
|
const bookingFlowContextUserData = useBookingFlowContext().user.data
|
||||||
|
|
||||||
const { lastRoom, addPreSubmitCallback } = useEnterDetailsStore((state) => ({
|
const { lastRoom, addPreSubmitCallback } = useEnterDetailsStore((state) => ({
|
||||||
lastRoom: state.lastRoom,
|
lastRoom: state.lastRoom,
|
||||||
@@ -58,7 +60,24 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
idx,
|
idx,
|
||||||
} = useRoomContext()
|
} = useRoomContext()
|
||||||
|
|
||||||
const initialData = room.guest
|
let partialUser
|
||||||
|
if (
|
||||||
|
!user &&
|
||||||
|
config.variant !== "scandic" &&
|
||||||
|
bookingFlowContextUserData?.firstName &&
|
||||||
|
bookingFlowContextUserData.lastName &&
|
||||||
|
bookingFlowContextUserData.email
|
||||||
|
) {
|
||||||
|
partialUser = {
|
||||||
|
firstName: bookingFlowContextUserData.firstName,
|
||||||
|
lastName: bookingFlowContextUserData.lastName,
|
||||||
|
email: bookingFlowContextUserData.email,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const initialData = {
|
||||||
|
...room.guest,
|
||||||
|
...partialUser,
|
||||||
|
}
|
||||||
|
|
||||||
const memberRate = "member" in room.roomRate ? room.roomRate.member : null
|
const memberRate = "member" in room.roomRate ? room.roomRate.member : null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user