fix: persist selection of bed and breakfast if same room

This commit is contained in:
Christel Westerberg
2024-12-04 16:16:32 +01:00
parent f075521421
commit 4210218852
11 changed files with 410 additions and 439 deletions

View File

@@ -12,7 +12,6 @@ interface BaseCardProps
title: React.ReactNode
type: "checkbox" | "radio"
value?: string
handleSelectedOnClick?: () => void
}
interface ListCardProps extends BaseCardProps {

View File

@@ -24,21 +24,20 @@ export default function Card({
title,
type,
value,
handleSelectedOnClick,
}: CardProps) {
const { register } = useFormContext()
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()
handleSelectedOnClick?.()
setValue(name, value)
}
return (
<label
className={styles.label}
data-declined={declined}
onClick={onLabelClick}
tabIndex={0}
onClick={handleSelectedOnClick ? onLabelClick : undefined}
>
<Caption className={styles.title} color="burgundy" type="label" uppercase>
{title}