feat: SW-276 Updated translations

This commit is contained in:
Hrishikesh Vaipurkar
2024-09-18 16:47:19 +02:00
parent a7167dde6a
commit 510880d697
12 changed files with 41 additions and 28 deletions

View File

@@ -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 ? (
<span>Child Age is required</span>
) : null}
{!isValid && child.age < 0 ? <span>{ageReqdErrMsg}</span> : null}
</div>
<div>
{child.age !== -1 ? (

View File

@@ -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}
/>
</div>
))}

View File

@@ -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}
/>
</section>
)

View File

@@ -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<GuestsRoom[]>(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
</Button>
) : null} */}
<Button onClick={closePicker}>Done</Button>
<Button onClick={closePicker} disabled={!isValid}>
{doneLabel}
</Button>
</div>
</>
)

View File

@@ -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<HTMLDivElement | null>(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}
/>
</div>
</div>

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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
}