Feat/SW-1276 implement design * 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): Removed console log * feat(SW-1276) fixed translations * feat(SW-1276): Added translations * feat(SW-1276) fix dynamic ID:s * feat(SW-1276) removed createElement * feat(SW-1276): Fixed build errors * feat(SW-1276): Updated label * feat(SW-1276): Rewrite SummaryCard Approved-by: Niclas Edenvin
131 lines
4.2 KiB
TypeScript
131 lines
4.2 KiB
TypeScript
import { dt } from "@/lib/dt"
|
|
|
|
import {
|
|
CheckCircleIcon,
|
|
DirectionsIcon,
|
|
EmailIcon,
|
|
LinkIcon,
|
|
} from "@/components/Icons"
|
|
import CrossCircleIcon from "@/components/Icons/CrossCircle"
|
|
import IconChip from "@/components/TempDesignSystem/IconChip"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import { Toast } from "@/components/TempDesignSystem/Toasts"
|
|
import { getIntl } from "@/i18n"
|
|
import { getLang } from "@/i18n/serverContext"
|
|
import { formatPrice } from "@/utils/numberFormatting"
|
|
|
|
import SummaryCard from "./SummaryCard"
|
|
|
|
import styles from "./bookingSummary.module.css"
|
|
|
|
import type { Hotel } from "@/types/hotel"
|
|
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
|
|
|
interface BookingSummaryProps {
|
|
booking: BookingConfirmation["booking"]
|
|
hotel: Hotel
|
|
}
|
|
|
|
export default async function BookingSummary({
|
|
booking,
|
|
hotel,
|
|
}: BookingSummaryProps) {
|
|
const intl = await getIntl()
|
|
const lang = getLang()
|
|
|
|
const directionsUrl = `https://www.google.com/maps/dir/?api=1&destination=${hotel.location.latitude},${hotel.location.longitude}`
|
|
const isPaid =
|
|
booking.rateDefinition.cancellationRule !== "CancellableBefore6PM"
|
|
const bookingDate = dt(booking.createDateTime)
|
|
.locale(lang)
|
|
.format("D MMMM YYYY")
|
|
|
|
return (
|
|
<div className={styles.bookingSummary}>
|
|
<Subtitle textTransform="uppercase" color="burgundy">
|
|
{intl.formatMessage({ id: "Booking summary" })}
|
|
</Subtitle>
|
|
<div className={styles.bookingSummaryContent}>
|
|
<SummaryCard
|
|
title={formatPrice(intl, booking.totalPrice, booking.currencyCode)}
|
|
image={{
|
|
src: "/_static/img/scandic-coin.svg",
|
|
alt: "Scandic coin",
|
|
}}
|
|
texts={[`${intl.formatMessage({ id: "Payment" })}: N/A`]}
|
|
supportingText={bookingDate}
|
|
chip={
|
|
<IconChip
|
|
color={isPaid ? "green" : "red"}
|
|
icon={
|
|
isPaid ? (
|
|
<CheckCircleIcon width={20} height={20} color="green" />
|
|
) : (
|
|
<CrossCircleIcon width={20} height={20} color="red" />
|
|
)
|
|
}
|
|
>
|
|
<Caption color={isPaid ? "green" : "red"}>
|
|
<strong>{intl.formatMessage({ id: "Status" })}:</strong>{" "}
|
|
{isPaid
|
|
? intl.formatMessage({ id: "Paid" })
|
|
: intl.formatMessage({ id: "Unpaid" })}
|
|
</Caption>
|
|
</IconChip>
|
|
}
|
|
/>
|
|
<SummaryCard
|
|
title={hotel.name}
|
|
image={{
|
|
src: "/_static/img/scandic-service.svg",
|
|
alt: "Scandic service",
|
|
}}
|
|
texts={[
|
|
hotel.address.streetAddress,
|
|
`${hotel.address.zipCode} ${hotel.address.city}`,
|
|
]}
|
|
supportingText={intl.formatMessage(
|
|
{ id: "Long {long} ∙ Lat {lat}" },
|
|
{
|
|
lat: hotel.location.latitude,
|
|
long: hotel.location.longitude,
|
|
}
|
|
)}
|
|
links={[
|
|
{
|
|
href: directionsUrl,
|
|
text: intl.formatMessage({ id: "Directions" }),
|
|
icon: <DirectionsIcon width={20} height={20} color="burgundy" />,
|
|
},
|
|
{
|
|
href: `mailto:${hotel.contactInformation.email}`,
|
|
text: intl.formatMessage({ id: "Email" }),
|
|
icon: <EmailIcon width={20} height={20} color="burgundy" />,
|
|
},
|
|
{
|
|
href: hotel.contactInformation.websiteUrl,
|
|
text: intl.formatMessage({ id: "Homepage" }),
|
|
icon: <LinkIcon width={20} height={20} color="burgundy" />,
|
|
},
|
|
]}
|
|
/>
|
|
</div>
|
|
{hotel.specialAlerts.length > 0 && (
|
|
<div className={styles.toast}>
|
|
<Toast variant="info">
|
|
<ul className={styles.list}>
|
|
{hotel.specialAlerts.map((alert) => (
|
|
<li key={alert.id}>
|
|
<Body color="uiTextHighContrast">{alert.text}</Body>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</Toast>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|