Fix/STAY-135 & STAY-127 * fix: make quantity and delivery separate steps in mobile * fix: update design for delivery step in ancillary flow * fix: add error state for missing time * fix: only allow points or cash payment for ancillaries * fix: break out stepper to design system * fix: update design of select quantity step in add ancillaries flow * fix: add error states for quantity * fix: handle insufficient points case * fix: update stepper to include optional disabledMessage tooltip * fix: handle validations * fix: change name to camel case Approved-by: Bianca Widstam Approved-by: Chuma Mcphoy (We Ahead)
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
"use client"
|
|
|
|
import { useFormContext } from "react-hook-form"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import Caption from "@scandic-hotels/design-system/Caption"
|
|
import Stepper from "@scandic-hotels/design-system/Stepper"
|
|
|
|
import styles from "./adult-selector.module.css"
|
|
|
|
type AdultSelectorProps = {
|
|
roomIndex: number
|
|
currentAdults: number
|
|
}
|
|
export default function AdultSelector({
|
|
roomIndex = 0,
|
|
currentAdults,
|
|
}: AdultSelectorProps) {
|
|
const name = `rooms.${roomIndex}.adults`
|
|
const intl = useIntl()
|
|
const adultsLabel = intl.formatMessage({
|
|
id: "common.adults",
|
|
defaultMessage: "Adults",
|
|
})
|
|
const { setValue } = useFormContext()
|
|
|
|
function increaseAdultsCount() {
|
|
if (currentAdults < 6) {
|
|
setValue(name, currentAdults + 1, { shouldDirty: true })
|
|
}
|
|
}
|
|
|
|
function decreaseAdultsCount() {
|
|
if (currentAdults > 1) {
|
|
setValue(name, currentAdults - 1, { shouldDirty: true })
|
|
}
|
|
}
|
|
|
|
return (
|
|
<section className={styles.container}>
|
|
<Caption color="uiTextHighContrast" type="bold">
|
|
{adultsLabel}
|
|
</Caption>
|
|
<Stepper
|
|
count={currentAdults}
|
|
handleOnDecrease={decreaseAdultsCount}
|
|
handleOnIncrease={increaseAdultsCount}
|
|
disableDecrease={currentAdults == 1}
|
|
disableIncrease={currentAdults == 6}
|
|
/>
|
|
</section>
|
|
)
|
|
}
|