mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-26 07:05:21 -04:00
28 lines
796 B
TypeScript
28 lines
796 B
TypeScript
import Turnstile from "react-turnstile";
|
|
import useHasMounted from "../../hooks/useHasMounted";
|
|
import useTheme from "../../hooks/useTheme";
|
|
import type { ComponentPropsWithoutRef } from "react";
|
|
|
|
export type CaptchaProps = Omit<ComponentPropsWithoutRef<typeof Turnstile>, "sitekey"> & {
|
|
className?: string;
|
|
};
|
|
|
|
const Captcha = ({ theme, className, ...rest }: CaptchaProps) => {
|
|
const hasMounted = useHasMounted();
|
|
const { activeTheme } = useTheme();
|
|
|
|
return (
|
|
<div className={className}>
|
|
{hasMounted && (
|
|
<Turnstile
|
|
sitekey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY || "1x00000000000000000000AA"}
|
|
theme={theme || (activeTheme === "dark" ? activeTheme : "light")}
|
|
{...rest}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Captcha;
|