Feat(SW-1275) cancel booking my stay * feat(SW-1276) UI implementation Desktop part 1 for MyStay * feat(SW-1276) UI implementation Desktop part 2 for MyStay * feat(SW-1276) UI implementation Mobile part 1 for MyStay * refactor: move files from MyStay/MyStay to MyStay * feat(SW-1276) Sidepeek implementation * feat(SW-1276): Refactoring * feat(SW-1276) UI implementation Mobile part 2 for MyStay * feat(SW-1276): translations * feat(SW-1276) fixed skeleton * feat(SW-1276): Added missing translations * feat(SW-1276) fixed translations * feat(SW-1275) cancel modal * feat(SW-1275): Mutate cancel booking * feat(SW-1275) added translations * feat(SW-1275) match current cancellationReason * feat(SW-1275) Added modal for manage stay * feat(SW-1275) Added missing icon * feat(SW-1275) New Dont cancel button * feat(SW-1275) Added preperation for Cancellation number * feat(SW-1275): added --modal-box-shadow * feat(SW-1718) Add to calendar * feat(SW-1718) general add to calendar Approved-by: Niclas Edenvin
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import useLang from "@/hooks/useLang"
|
|
|
|
import { ModalContent } from "../ManageStay/ModalContent"
|
|
import useCancelStay from "./hooks/useCancelStay"
|
|
import { CancelStayConfirmation } from "./Confirmation"
|
|
import { FinalConfirmation } from "./FinalConfirmation"
|
|
import { formatStayDetails } from "./utils"
|
|
|
|
import type { Hotel } from "@/types/hotel"
|
|
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
|
|
|
export interface CancelStayProps {
|
|
booking: BookingConfirmation["booking"]
|
|
hotel: Hotel
|
|
setBookingStatus: () => void
|
|
handleCloseModal: () => void
|
|
handleBackToManageStay: () => void
|
|
}
|
|
|
|
export default function CancelStay({
|
|
booking,
|
|
hotel,
|
|
setBookingStatus,
|
|
handleCloseModal,
|
|
handleBackToManageStay,
|
|
}: CancelStayProps) {
|
|
const intl = useIntl()
|
|
const lang = useLang()
|
|
const {
|
|
currentStep,
|
|
isLoading,
|
|
handleCancelStay,
|
|
handleCloseCancelStay,
|
|
handleForward,
|
|
} = useCancelStay({
|
|
booking,
|
|
setBookingStatus,
|
|
handleCloseModal,
|
|
handleBackToManageStay,
|
|
})
|
|
|
|
const stayDetails = formatStayDetails({ booking, lang, intl })
|
|
const isFirstStep = currentStep === 1
|
|
|
|
return (
|
|
<>
|
|
<ModalContent
|
|
title={
|
|
isFirstStep
|
|
? intl.formatMessage({ id: "Cancel stay" })
|
|
: intl.formatMessage({ id: "Confirm cancellation" })
|
|
}
|
|
onClose={handleCloseModal}
|
|
content={
|
|
isFirstStep ? (
|
|
<CancelStayConfirmation
|
|
hotel={hotel}
|
|
booking={booking}
|
|
stayDetails={stayDetails}
|
|
/>
|
|
) : (
|
|
<FinalConfirmation booking={booking} stayDetails={stayDetails} />
|
|
)
|
|
}
|
|
primaryAction={{
|
|
label: isFirstStep
|
|
? intl.formatMessage({ id: "Cancel stay" })
|
|
: intl.formatMessage({ id: "Confirm cancellation" }),
|
|
onClick: isFirstStep ? handleForward : handleCancelStay,
|
|
intent: isFirstStep ? "secondary" : "primary",
|
|
isLoading: isLoading,
|
|
}}
|
|
secondaryAction={{
|
|
label: isFirstStep
|
|
? intl.formatMessage({ id: "Back" })
|
|
: intl.formatMessage({ id: "Don't cancel" }),
|
|
onClick: isFirstStep ? handleCloseCancelStay : handleCloseModal,
|
|
intent: "text",
|
|
}}
|
|
/>
|
|
</>
|
|
)
|
|
}
|