feat(SW-415): Update typings
This commit is contained in:
@@ -1,18 +1,10 @@
|
|||||||
import {
|
import { Button, Dialog, OverlayArrow, Popover } from "react-aria-components"
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
OverlayArrow,
|
|
||||||
Popover,
|
|
||||||
type PopoverProps,
|
|
||||||
} from "react-aria-components"
|
|
||||||
|
|
||||||
import { CloseIcon } from "@/components/Icons"
|
import { CloseIcon } from "@/components/Icons"
|
||||||
|
|
||||||
import styles from "./popover.module.css"
|
import styles from "./popover.module.css"
|
||||||
|
|
||||||
interface PricePopoverProps extends Omit<PopoverProps, "children"> {
|
import { PricePopoverProps } from "@/types/components/hotelReservation/selectRate/pricePopover"
|
||||||
children: React.ReactNode
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function PricePopover({
|
export default function PricePopover({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -4,25 +4,25 @@ import Body from "@/components/TempDesignSystem/Text/Body"
|
|||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||||
|
|
||||||
import styles from "./priceTable.module.css"
|
import styles from "./priceList.module.css"
|
||||||
|
|
||||||
import { PriceTableProps } from "@/types/components/hotelReservation/selectRate/flexibilityOption"
|
import { PriceListProps } from "@/types/components/hotelReservation/selectRate/flexibilityOption"
|
||||||
|
|
||||||
export default function PriceTable({
|
export default function PriceList({
|
||||||
publicPrice,
|
publicPrice = {},
|
||||||
memberPrice,
|
memberPrice = {},
|
||||||
}: PriceTableProps) {
|
}: PriceListProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
|
||||||
const { localPrice: publicLocalPrice, requestedPrice: publicRequestedPrice } =
|
const { localPrice: publicLocalPrice, requestedPrice: publicRequestedPrice } =
|
||||||
publicPrice || {}
|
publicPrice
|
||||||
const { localPrice: memberLocalPrice, requestedPrice: memberRequestedPrice } =
|
const { localPrice: memberLocalPrice, requestedPrice: memberRequestedPrice } =
|
||||||
memberPrice || {}
|
memberPrice
|
||||||
|
|
||||||
const showRequestedPrice = publicRequestedPrice && memberRequestedPrice
|
const showRequestedPrice = publicRequestedPrice && memberRequestedPrice
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dl className={styles.priceTable}>
|
<dl className={styles.priceList}>
|
||||||
<div className={styles.priceRow}>
|
<div className={styles.priceRow}>
|
||||||
<dt>
|
<dt>
|
||||||
<Caption
|
<Caption
|
||||||
@@ -6,7 +6,7 @@ import { CheckCircleIcon, InfoCircleIcon } from "@/components/Icons"
|
|||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
|
|
||||||
import PricePopover from "./Popover"
|
import PricePopover from "./Popover"
|
||||||
import PriceTable from "./PriceTable"
|
import PriceTable from "./PriceList"
|
||||||
|
|
||||||
import styles from "./flexibilityOption.module.css"
|
import styles from "./flexibilityOption.module.css"
|
||||||
|
|
||||||
@@ -40,17 +40,13 @@ export default function FlexibilityOption({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { productType } = product
|
const { public: publicPrice, member: memberPrice } = product.productType
|
||||||
const { public: publicPrice, member: memberPrice } = productType
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="rateCode" value={publicPrice?.rateCode} />
|
<input type="radio" name="rateCode" value={publicPrice?.rateCode} />
|
||||||
<div className={styles.card}>
|
<div className={styles.card}>
|
||||||
<div
|
<div className={styles.header} ref={setRef}>
|
||||||
className={styles.header}
|
|
||||||
ref={(node: Element | null) => setRef(node)}
|
|
||||||
>
|
|
||||||
<DialogTrigger>
|
<DialogTrigger>
|
||||||
<Button
|
<Button
|
||||||
aria-label="Help"
|
aria-label="Help"
|
||||||
@@ -82,7 +78,7 @@ export default function FlexibilityOption({
|
|||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
</Caption>
|
</Caption>
|
||||||
{priceInformation?.map((info: string) => (
|
{priceInformation?.map((info) => (
|
||||||
<Caption
|
<Caption
|
||||||
key={info}
|
key={info}
|
||||||
color="uiTextHighContrast"
|
color="uiTextHighContrast"
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default function RoomCard({
|
|||||||
(rate) => rate.cancellationRule === "CancellableBefore6PM"
|
(rate) => rate.cancellationRule === "CancellableBefore6PM"
|
||||||
)
|
)
|
||||||
|
|
||||||
const findProductForRate = (rate: RateDefinition | undefined) => {
|
function findProductForRate(rate: RateDefinition | undefined) {
|
||||||
return rate
|
return rate
|
||||||
? roomConfiguration.products.find(
|
? roomConfiguration.products.find(
|
||||||
(product) =>
|
(product) =>
|
||||||
@@ -45,9 +45,9 @@ export default function RoomCard({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPriceForRate = (
|
function getPriceForRate(
|
||||||
rate: typeof saveRate | typeof changeRate | typeof flexRate
|
rate: typeof saveRate | typeof changeRate | typeof flexRate
|
||||||
) => {
|
) {
|
||||||
return rateDefinitions.find((def) => def.rateCode === rate?.rateCode)
|
return rateDefinitions.find((def) => def.rateCode === rate?.rateCode)
|
||||||
?.generalTerms
|
?.generalTerms
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,15 +31,12 @@
|
|||||||
|
|
||||||
@media (min-width: 767px) {
|
@media (min-width: 767px) {
|
||||||
.roomList {
|
.roomList {
|
||||||
grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr) minmax(
|
grid-template-columns: repeat(3, minmax(240px, 1fr));
|
||||||
240px,
|
|
||||||
1fr
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1367px) {
|
@media (min-width: 1367px) {
|
||||||
.roomList {
|
.roomList {
|
||||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
grid-template-columns: repeat(4, 1fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -577,26 +577,18 @@ const priceSchema = z.object({
|
|||||||
pricePerStay: z.string(),
|
pricePerStay: z.string(),
|
||||||
currency: z.string(),
|
currency: z.string(),
|
||||||
})
|
})
|
||||||
export type Price = z.infer<typeof priceSchema>
|
|
||||||
|
export const productTypePriceSchema = z.object({
|
||||||
|
rateCode: z.string(),
|
||||||
|
rateType: z.string().optional(),
|
||||||
|
localPrice: priceSchema,
|
||||||
|
requestedPrice: priceSchema.optional(),
|
||||||
|
})
|
||||||
|
|
||||||
const productSchema = z.object({
|
const productSchema = z.object({
|
||||||
productType: z.object({
|
productType: z.object({
|
||||||
public: z
|
public: productTypePriceSchema.optional(),
|
||||||
.object({
|
member: productTypePriceSchema.optional(),
|
||||||
rateCode: z.string(),
|
|
||||||
rateType: z.string().optional(),
|
|
||||||
localPrice: priceSchema,
|
|
||||||
requestedPrice: priceSchema.optional(),
|
|
||||||
})
|
|
||||||
.optional(),
|
|
||||||
member: z
|
|
||||||
.object({
|
|
||||||
rateCode: z.string(),
|
|
||||||
rateType: z.string().optional(),
|
|
||||||
localPrice: priceSchema,
|
|
||||||
requestedPrice: priceSchema.optional(),
|
|
||||||
})
|
|
||||||
.optional(),
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { Price, Product } from "@/server/routers/hotels/output"
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import { Product, productTypePriceSchema } from "@/server/routers/hotels/output"
|
||||||
|
|
||||||
|
type ProductPrice = z.output<typeof productTypePriceSchema>
|
||||||
|
|
||||||
export type FlexibilityOptionProps = {
|
export type FlexibilityOptionProps = {
|
||||||
product: Product | undefined
|
product: Product | undefined
|
||||||
@@ -8,7 +12,7 @@ export type FlexibilityOptionProps = {
|
|||||||
priceInformation?: Array<string>
|
priceInformation?: Array<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PriceTableProps {
|
export interface PriceListProps {
|
||||||
publicPrice?: Product["productType"]["public"]
|
publicPrice?: ProductPrice | Record<string, never>
|
||||||
memberPrice?: Product["productType"]["member"]
|
memberPrice?: ProductPrice | Record<string, never>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import type { PopoverProps } from "react-aria-components"
|
||||||
|
|
||||||
|
export interface PricePopoverProps extends Omit<PopoverProps, "children"> {
|
||||||
|
children: React.ReactNode
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user