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)
72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
"use client"
|
|
|
|
import { useEffect } from "react"
|
|
|
|
import { dt } from "@scandic-hotels/common/dt"
|
|
import Modal from "@scandic-hotels/design-system/Modal"
|
|
|
|
import { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow"
|
|
|
|
import Form from "./Form"
|
|
import { calculateBreakfastData } from "./utils"
|
|
|
|
import styles from "./addAncillaryFlowModal.module.css"
|
|
|
|
import type { AddAncillaryFlowModalProps } from "@/types/components/myPages/myStay/ancillaries"
|
|
|
|
export default function AddAncillaryFlowModal({
|
|
booking,
|
|
packages,
|
|
user,
|
|
savedCreditCards,
|
|
}: AddAncillaryFlowModalProps) {
|
|
const {
|
|
isOpen,
|
|
closeModal,
|
|
selectedAncillary,
|
|
setBreakfastData,
|
|
isBreakfast,
|
|
} = useAddAncillaryStore((state) => ({
|
|
selectedAncillary: state.selectedAncillary,
|
|
closeModal: state.closeModal,
|
|
setBreakfastData: state.setBreakfastData,
|
|
isBreakfast: state.isBreakfast,
|
|
isOpen: state.isOpen,
|
|
}))
|
|
|
|
useEffect(() => {
|
|
setBreakfastData(
|
|
calculateBreakfastData(
|
|
isBreakfast,
|
|
packages,
|
|
booking.adults,
|
|
booking.childrenAges,
|
|
dt(booking.checkOutDate)
|
|
.startOf("day")
|
|
.diff(dt(booking.checkInDate).startOf("day"), "days")
|
|
)
|
|
)
|
|
}, [
|
|
booking.adults,
|
|
booking.checkInDate,
|
|
booking.checkOutDate,
|
|
booking.childrenAges,
|
|
isBreakfast,
|
|
packages,
|
|
setBreakfastData,
|
|
])
|
|
|
|
return (
|
|
<Modal
|
|
isOpen={isOpen}
|
|
onToggle={closeModal}
|
|
title={selectedAncillary?.title || ""}
|
|
withActions
|
|
contentClassName={styles.modalContent}
|
|
className={styles.modal}
|
|
>
|
|
<Form user={user} savedCreditCards={savedCreditCards} booking={booking} />
|
|
</Modal>
|
|
)
|
|
}
|