erp-platform/ui/src/components/shared/Captcha.tsx
2025-05-14 10:41:56 +03:00

29 lines
704 B
TypeScript

import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
import { Ref, forwardRef } from 'react'
export interface CaptchaProps {
className?: string
onError: () => void
onExpire: () => void
onSuccess: (token: string) => void
}
const Captcha = forwardRef((props: CaptchaProps, ref: Ref<TurnstileInstance>) => {
const { className, onError, onExpire, onSuccess } = props
return (
<>
<Turnstile
ref={ref}
className={className ?? 'mb-4 mx-auto'}
siteKey="0x4AAAAAABdEjmiXxcl0j7jp"
onError={onError}
onExpire={onExpire}
onSuccess={onSuccess}
/>
</>
)
})
Captcha.displayName = 'Captcha'
export default Captcha