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:
Pontus Dreij
2025-02-14 15:43:14 +00:00
parent 21d06e2d84
commit ed9dbded5d
12 changed files with 93 additions and 48 deletions

View File

@@ -0,0 +1,3 @@
.ancillaryChoiceCard:hover {
cursor: pointer;
}

View File

@@ -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>
)
}