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
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user