diff --git a/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/ChildInfoSelector.tsx b/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/ChildInfoSelector.tsx index d0ff98aba..483b2b18a 100644 --- a/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/ChildInfoSelector.tsx +++ b/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/ChildInfoSelector.tsx @@ -4,17 +4,9 @@ import Select from "@/components/TempDesignSystem/Select" import { Child, - ChildBed, + ChildInfoSelectorProps, } from "@/types/components/bookingWidget/guestsRoomsPicker" -type ChildSelectorProps = { - child: Child - index: number - availableBedTypes?: ChildBed[] - updateChild: (child: Child, index: number) => void - childAgeError: boolean -} - export default function ChildInfoSelector({ child = { age: -1, bed: -1 }, index = 0, @@ -24,10 +16,11 @@ export default function ChildInfoSelector({ { label: "In extra bed", value: 2 }, ], updateChild = (child: Child, index: number) => {}, - childAgeError, -}: ChildSelectorProps) { + isValid, +}: ChildInfoSelectorProps) { const intl = useIntl() const ageLabel = intl.formatMessage({ id: "Age" }) + const ageReqdErrMsg = intl.formatMessage({ id: "Child age is required" }) const bedLabel = intl.formatMessage({ id: "Bed" }) const ageList = [ @@ -70,9 +63,7 @@ export default function ChildInfoSelector({ name="age" placeholder={ageLabel} /> - {childAgeError && child.age < 0 ? ( - Child Age is required - ) : null} + {!isValid && child.age < 0 ? {ageReqdErrMsg} : null}
{child.age !== -1 ? ( diff --git a/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/index.tsx b/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/index.tsx index 8cf9edb67..62042dec5 100644 --- a/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/index.tsx +++ b/components/GuestsRoomsPicker/GuestsRoomPicker/ChildSelector/index.tsx @@ -17,7 +17,7 @@ export default function ChildSelector({ roomChildren = [], adultCount = 1, updateChildren = (children: Child[]) => {}, - childAgeError, + isValid, }: ChildSelectorProps) { const intl = useIntl() const childrenLabel = intl.formatMessage({ id: "Children" }) @@ -107,7 +107,7 @@ export default function ChildSelector({ child={child} availableBedTypes={childBedTypes[index]} updateChild={updateChildInfo} - childAgeError={childAgeError} + isValid={isValid} />
))} diff --git a/components/GuestsRoomsPicker/GuestsRoomPicker/index.tsx b/components/GuestsRoomsPicker/GuestsRoomPicker/index.tsx index b7237a74e..c954a1cae 100644 --- a/components/GuestsRoomsPicker/GuestsRoomPicker/index.tsx +++ b/components/GuestsRoomsPicker/GuestsRoomPicker/index.tsx @@ -17,7 +17,7 @@ export default function GuestsRoomPicker({ handleOnSelect = (selected: GuestsRoom, index: number) => {}, room = { adults: 1, children: [] }, index = 1, - childAgeError, + isValid, }: GuestsRoomPickerProps) { const intl = useIntl() const roomLabel = intl.formatMessage({ id: "Room" }) @@ -42,7 +42,7 @@ export default function GuestsRoomPicker({ roomChildren={room.children} adultCount={room.adults} updateChildren={updateChildren} - childAgeError={childAgeError} + isValid={isValid} /> ) diff --git a/components/GuestsRoomsPicker/GuestsRoomsPicker.tsx b/components/GuestsRoomsPicker/GuestsRoomsPicker.tsx index 9414046db..9ca9ce75f 100644 --- a/components/GuestsRoomsPicker/GuestsRoomsPicker.tsx +++ b/components/GuestsRoomsPicker/GuestsRoomsPicker.tsx @@ -1,5 +1,6 @@ "use client" import { useState } from "react" +import { useIntl } from "react-intl" import useLang from "@/hooks/useLang" @@ -23,9 +24,11 @@ export default function GuestsRoomsPicker({ }, ], closePicker, - childAgeError, + isValid, }: GuestsRoomsPickerProps) { const lang = useLang() + const intl = useIntl() + const doneLabel = intl.formatMessage({ id: "Done" }) const [selectedGuests, setSelectedGuests] = useState(initialSelected) @@ -39,6 +42,7 @@ export default function GuestsRoomsPicker({ setSelectedGuests(updatedSelectedGuests) } + // Not in MVP scope function addRoom() { if (selectedGuests.length < 4) { let updatedSelectedGuests = JSON.parse(JSON.stringify(selectedGuests)) @@ -51,6 +55,7 @@ export default function GuestsRoomsPicker({ } } + // Not in MVP scope function removeRoom(index: number) { if (selectedGuests.length > 1) { let updatedSelectedGuests = JSON.parse(JSON.stringify(selectedGuests)) @@ -68,7 +73,7 @@ export default function GuestsRoomsPicker({ room={room} handleOnSelect={handleSelectRoomGuests} index={index} - childAgeError={childAgeError} + isValid={isValid} /> {/* Not in MVP {index > 0 ? ( @@ -86,7 +91,9 @@ export default function GuestsRoomsPicker({ Add Room ) : null} */} - + ) diff --git a/components/GuestsRoomsPicker/index.tsx b/components/GuestsRoomsPicker/index.tsx index 42fa366cc..dae0b4f7d 100644 --- a/components/GuestsRoomsPicker/index.tsx +++ b/components/GuestsRoomsPicker/index.tsx @@ -21,7 +21,7 @@ export default function GuestsRoomsPickerForm({ }: GuestsRoomsFormProps) { const intl = useIntl() const [isOpen, setIsOpen] = useState(false) - const [isAgeError, setIsAgeError] = useState(false) + const [isValid, setIsValid] = useState(true) const selectedGuests = useWatch({ name }) const { register, setValue } = useFormContext() const ref = useRef(null) @@ -30,14 +30,14 @@ export default function GuestsRoomsPickerForm({ } function handleSelectGuest(selected: GuestsRoom[]) { setValue(name, selected) - setIsAgeError(false) + setIsValid(true) } const closePicker = useCallback(() => { const guestRoomsValidData = guestRoomsSchema.safeParse(selectedGuests) if (guestRoomsValidData.success) { setIsOpen(false) } else { - setIsAgeError(true) + setIsValid(false) } }, [selectedGuests]) @@ -90,7 +90,7 @@ export default function GuestsRoomsPickerForm({ handleOnSelect={handleSelectGuest} initialSelected={selectedGuests} closePicker={closePicker} - childAgeError={isAgeError} + isValid={isValid} /> diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index ba9699d47..eefb8e0f9 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -86,6 +86,7 @@ "Discard unsaved changes?": "Slette ændringer, der ikke er gemt?", "Distance to city centre": "{number}km til centrum", "Do you want to start the day with Scandics famous breakfast buffé?": "Vil du starte dagen med Scandics berømte morgenbuffet?", + "Done": "Færdig", "Download the Scandic app": "Download Scandic-appen", "Earn bonus nights & points": "Optjen bonusnætter og point", "Edit": "Redigere", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 98e640c48..9ca065cb8 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -86,6 +86,7 @@ "Discard unsaved changes?": "Nicht gespeicherte Änderungen verwerfen?", "Distance to city centre": "{number}km zum Stadtzentrum", "Do you want to start the day with Scandics famous breakfast buffé?": "Möchten Sie den Tag mit Scandics berühmtem Frühstücksbuffet beginnen?", + "Done": "Fertig", "Download the Scandic app": "Laden Sie die Scandic-App herunter", "Earn bonus nights & points": "Sammeln Sie Bonusnächte und -punkte", "Edit": "Bearbeiten", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index feb80f103..fd03010ca 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -50,6 +50,7 @@ "Check out the credit cards saved to your profile. Pay with a saved card when signed in for a smoother web experience.": "Check out the credit cards saved to your profile. Pay with a saved card when signed in for a smoother web experience.", "Child": "Child", "Children": "Children", + "Child age is required": "Child age is required", "Choose room": "Choose room", "Cities": "Cities", "City": "City", @@ -88,6 +89,7 @@ "Discard unsaved changes?": "Discard unsaved changes?", "Distance to city centre": "{number}km to city centre", "Do you want to start the day with Scandics famous breakfast buffé?": "Do you want to start the day with Scandics famous breakfast buffé?", + "Done": "Done", "Download the Scandic app": "Download the Scandic app", "Earn bonus nights & points": "Earn bonus nights & points", "Edit": "Edit", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 1f3dfdfa8..73b1cbfe5 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -86,6 +86,7 @@ "Discard unsaved changes?": "Hylkäätkö tallentamattomat muutokset?", "Distance to city centre": "{number}km Etäisyys kaupunkiin", "Do you want to start the day with Scandics famous breakfast buffé?": "Haluatko aloittaa päiväsi Scandicsin kuuluisalla aamiaisbuffella?", + "Done": "Valmis", "Download the Scandic app": "Lataa Scandic-sovellus", "Earn bonus nights & points": "Ansaitse bonusöitä ja -pisteitä", "Edit": "Muokata", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index ab2181fe9..911dc126e 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -85,6 +85,7 @@ "Discard unsaved changes?": "Forkaste endringer som ikke er lagret?", "Distance to city centre": "{number}km til sentrum", "Do you want to start the day with Scandics famous breakfast buffé?": "Vil du starte dagen med Scandics berømte frokostbuffé?", + "Done": "Ferdig", "Download the Scandic app": "Last ned Scandic-appen", "Earn bonus nights & points": "Tjen bonusnetter og poeng", "Edit": "Redigere", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index 3f96e263f..942a574cb 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -85,6 +85,7 @@ "Discard unsaved changes?": "Vill du ignorera ändringar som inte har sparats?", "Distance to city centre": "{number}km till centrum", "Do you want to start the day with Scandics famous breakfast buffé?": "Vill du starta dagen med Scandics berömda frukostbuffé?", + "Done": "Klar", "Download the Scandic app": "Ladda ner Scandic-appen", "Earn bonus nights & points": "Tjäna bonusnätter och poäng", "Edit": "Redigera", diff --git a/types/components/bookingWidget/guestsRoomsPicker.ts b/types/components/bookingWidget/guestsRoomsPicker.ts index a888d5cc3..638229d1e 100644 --- a/types/components/bookingWidget/guestsRoomsPicker.ts +++ b/types/components/bookingWidget/guestsRoomsPicker.ts @@ -21,14 +21,14 @@ export interface GuestsRoomsPickerProps { handleOnSelect: (selected: GuestsRoom[]) => void initialSelected?: GuestsRoom[] closePicker: () => void - childAgeError: boolean + isValid: boolean } export type GuestsRoomPickerProps = { handleOnSelect: (selected: GuestsRoom, index: number) => void room: GuestsRoom index: number - childAgeError: boolean + isValid: boolean } export type AdultSelectorProps = { @@ -40,5 +40,13 @@ export type ChildSelectorProps = { roomChildren: Child[] adultCount: number updateChildren: (children: Child[]) => void - childAgeError: boolean + isValid: boolean +} + +export type ChildInfoSelectorProps = { + child: Child + index: number + availableBedTypes?: ChildBed[] + updateChild: (child: Child, index: number) => void + isValid: boolean }