Files
web/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/index.tsx
Pontus Dreij ed9dbded5d Merged in feat/SW-1504-UI-update-breakfast-component (pull request #1284)
feat(SW-1504): Used AncillaryCard and added to breakfast choice

* feat(SW-1504): Craeted AncillaryCard and added to breakfast choice

* feat(SW-1504): Using of AncillaryCard

* feat(SW-1504) Removed unused imports

* feat(SW-1504): Added price text

* feat(SW-1504): added /night per adult

* feat(SW-1504) Removed type prop


Approved-by: Arvid Norlin
2025-02-14 15:43:14 +00:00

40 lines
983 B
TypeScript

import { useFormContext } from "react-hook-form"
import { AncillaryCard } from "@/components/TempDesignSystem/AncillaryCard"
import styles from "./ancillaryChoiceCard.module.css"
import type { BreakfastChoiceCardProps } from "@/types/components/ancillaryCard"
export default function BreakfastChoiceCard({
name,
id,
value,
ancillary,
}: BreakfastChoiceCardProps) {
const { register, setValue } = useFormContext()
function onLabelClick(event: React.MouseEvent) {
// Preventing click event on label elements firing twice: https://github.com/facebook/react/issues/14295
event.preventDefault()
setValue(name, value)
}
return (
<label
onClick={onLabelClick}
tabIndex={0}
className={styles.ancillaryChoiceCard}
>
<AncillaryCard ancillary={ancillary} />
<input
{...register(name)}
aria-hidden
id={id || name}
hidden
type="radio"
value={value}
/>
</label>
)
}