From 438de66a1f0ec1c2a711d8f29be83eb71350ab5e Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Tue, 24 Jun 2025 09:47:18 +0000 Subject: [PATCH] Merged in feat/SW-3076 (pull request #2416) feat(SW-3076: change phone country code on country select) * feat(SW-3076: change phone country code on country select) Approved-by: Simon.Emanuelsson --- .../EnterDetails/Details/Multiroom/index.tsx | 10 ++++++++++ .../EnterDetails/Details/RoomOne/index.tsx | 17 ++++++++++++++++- .../TempDesignSystem/Form/Phone/index.tsx | 9 ++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Details/Multiroom/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Details/Multiroom/index.tsx index b290d6a88..de13dc606 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Details/Multiroom/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Details/Multiroom/index.tsx @@ -85,6 +85,8 @@ export default function Details() { control, subscribe, formState: { isValid }, + setValue, + watch, } = methods useFormTracking("checkout", subscribe, control, ` - room ${roomNr}`) @@ -119,6 +121,14 @@ export default function Details() { } }, [crossValidationData, methods]) + const countryCode = watch("countryCode") + + useEffect(() => { + if (countryCode) { + setValue("phoneNumberCC", countryCode.toLowerCase()) + } + }, [countryCode, setValue]) + const guestIsGoingToJoin = methods.watch("join") const guestIsMember = methods.watch("membershipNo") diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Details/RoomOne/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Details/RoomOne/index.tsx index 6944509ec..6c16a9693 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Details/RoomOne/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Details/RoomOne/index.tsx @@ -42,6 +42,7 @@ export default function Details({ user }: DetailsProps) { roomNr, idx, } = useRoomContext() + const initialData = room.guest const memberRate = "member" in room.roomRate ? room.roomRate.member : null @@ -74,7 +75,15 @@ export default function Details({ user }: DetailsProps) { reValidateMode: "onChange", }) - const { formState, handleSubmit, trigger, control, subscribe } = methods + const { + formState, + handleSubmit, + trigger, + control, + subscribe, + setValue, + watch, + } = methods useFormTracking( "checkout", @@ -103,7 +112,13 @@ export default function Details({ user }: DetailsProps) { }, [handleSubmit, formState.isValid, onSubmit, setIncomplete]) useEffect(updateDetailsStore, [updateDetailsStore]) + const countryCode = watch("countryCode") + useEffect(() => { + if (countryCode) { + setValue("phoneNumberCC", countryCode.toLowerCase()) + } + }, [countryCode, setValue]) return (
{ + if (!ccFieldState.isTouched) { + setCountry(phoneNumberCC) + } + }, [phoneNumberCC, setCountry, ccFieldState]) return (