Merged in feat/SW-459-payment-flow-ui-ux (pull request #657)
Feat/SW-459 payment flow ui ux * feat(SW-431): List payment methods and handle booking status and redirection * feat(SW-431): small fix * fix(SW-431): Added intl string and sorted dictionaries * fix(SW-431): add todo comments * feat(SW-459): Added payment method icons * feat(SW-459): refactored into new component and added form * feat(SW-459): Localized strings * feat(SW-459): added checkbox * feat(SW-459): Refactored payment options and updated payment form * feat(SW-459): update input bg color * feat(SW-459): add current web links and style fixes * fix(SW-459): fix issue with booking confirmation not being accessible * feat(SW-459): style changes * feat(SW-459): update max width of payment container * feat(SW-459): update create booking schema * feat(SW-459): fixes from PR Approved-by: Arvid Norlin
This commit is contained in:
49
components/TempDesignSystem/Checkbox/index.tsx
Normal file
49
components/TempDesignSystem/Checkbox/index.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Checkbox as AriaCheckbox } from "react-aria-components"
|
||||
import { useController, useFormContext } from "react-hook-form"
|
||||
|
||||
import { InfoCircleIcon } from "@/components/Icons"
|
||||
import CheckIcon from "@/components/Icons/Check"
|
||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||
|
||||
import { CheckboxProps } from "./checkbox"
|
||||
|
||||
import styles from "./checkbox.module.css"
|
||||
|
||||
export default function Checkbox({
|
||||
name,
|
||||
children,
|
||||
registerOptions,
|
||||
}: React.PropsWithChildren<CheckboxProps>) {
|
||||
const { control } = useFormContext()
|
||||
const { field, fieldState } = useController({
|
||||
control,
|
||||
name,
|
||||
rules: registerOptions,
|
||||
})
|
||||
|
||||
return (
|
||||
<AriaCheckbox
|
||||
className={styles.container}
|
||||
isSelected={field.value}
|
||||
onChange={field.onChange}
|
||||
data-testid={name}
|
||||
>
|
||||
{({ isSelected }) => (
|
||||
<>
|
||||
<div className={styles.checkboxContainer}>
|
||||
<div className={styles.checkbox}>
|
||||
{isSelected && <CheckIcon color="white" />}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
{children && fieldState.error ? (
|
||||
<Caption className={styles.error}>
|
||||
<InfoCircleIcon color="red" />
|
||||
{fieldState.error.message}
|
||||
</Caption>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</AriaCheckbox>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user