Feat(SW-1274) modify date my stay * feat(SW-1676): Modify guest details step 1 * feat(SW-1676) Integration to api to update guest details * feat(SW-1676) Reuse of old modal * feat(SW-1676) updated modify guest * feat(SW-1676) cleanup * feat(SW-1274) modify stay modal and datepicker * feat(SW-1274) DatePicker from modify dates * feat(SW-1274) Modify dates fixes and merge conflicts * feat(SW-1274) handle modify for multiroom * feat(SW-1274) update manage stay * feat(SW-1274) fixed some comments * feat(SW-1274) use Modal instead * feat(SW-1274) fixed formatChildBedPreferences * feat(SW-1274) removed any as prop * feat(SW-1274) fix rebase conflicts * feat(SW-1274) fix flicker on modify modal * feat(SW-1274) CalendarButton * feat(SW-1274) fixed gap variable * feat(SW-1274) simplified code * feat(SW-1274) Split up DatePicker on mode * feat(SW-1274) Updated file structure for datepicker Approved-by: Arvid Norlin
100 lines
2.8 KiB
TypeScript
100 lines
2.8 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { BookingStatusEnum } from "@/constants/booking"
|
|
|
|
import { ChevronDownIcon } from "@/components/Icons"
|
|
import Modal from "@/components/Modal"
|
|
import Button from "@/components/TempDesignSystem/Button"
|
|
|
|
import GuaranteeLateArrival from "../GuaranteeLateArrival"
|
|
import { useManageStayStore } from "../stores/manageStayStore"
|
|
import CancelStay from "./ActionPanel/Actions/CancelStay"
|
|
import ModifyStay from "./ActionPanel/Actions/ModifyStay"
|
|
import ActionPanel from "./ActionPanel"
|
|
|
|
import type { Hotel } from "@/types/hotel"
|
|
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
|
import { type CreditCard, type User } from "@/types/user"
|
|
|
|
interface ManageStayProps {
|
|
booking: BookingConfirmation["booking"]
|
|
hotel: Hotel
|
|
setBookingStatus: (status: BookingStatusEnum) => void
|
|
bookingStatus: string | null
|
|
user: User | null
|
|
savedCreditCards: CreditCard[] | null
|
|
refId: string
|
|
}
|
|
|
|
export default function ManageStay({
|
|
booking,
|
|
hotel,
|
|
setBookingStatus,
|
|
bookingStatus,
|
|
user,
|
|
savedCreditCards,
|
|
refId,
|
|
}: ManageStayProps) {
|
|
const intl = useIntl()
|
|
const {
|
|
isOpen,
|
|
activeView,
|
|
actions: { setIsOpen, handleCloseModal, setActiveView },
|
|
} = useManageStayStore()
|
|
|
|
const showGuaranteeButton =
|
|
bookingStatus !== BookingStatusEnum.Cancelled && !booking.guaranteeInfo
|
|
|
|
function renderContent() {
|
|
switch (activeView) {
|
|
case "cancelStay":
|
|
return (
|
|
<CancelStay
|
|
booking={booking}
|
|
hotel={hotel}
|
|
setBookingStatus={() =>
|
|
setBookingStatus(BookingStatusEnum.Cancelled)
|
|
}
|
|
/>
|
|
)
|
|
case "modifyStay":
|
|
return <ModifyStay booking={booking} user={user} />
|
|
case "guaranteeLateArrival":
|
|
return (
|
|
<GuaranteeLateArrival
|
|
booking={booking}
|
|
handleCloseModal={handleCloseModal}
|
|
handleBackToManageStay={() => setActiveView("actionPanel")}
|
|
savedCreditCards={savedCreditCards}
|
|
refId={refId}
|
|
/>
|
|
)
|
|
default:
|
|
return (
|
|
<ActionPanel
|
|
booking={booking}
|
|
hotel={hotel}
|
|
bookingStatus={bookingStatus}
|
|
onCancelClick={() => setActiveView("cancelStay")}
|
|
onGuaranteeClick={() => setActiveView("guaranteeLateArrival")}
|
|
showGuaranteeButton={showGuaranteeButton}
|
|
/>
|
|
)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Button variant="icon" fullWidth onClick={() => setIsOpen(true)}>
|
|
{intl.formatMessage({ id: "Manage stay" })}
|
|
<ChevronDownIcon width={24} height={24} color="burgundy" />
|
|
</Button>
|
|
<Modal isOpen={isOpen} onToggle={handleCloseModal} withActions hideHeader>
|
|
{renderContent()}
|
|
</Modal>
|
|
</>
|
|
)
|
|
}
|