import {
	Body,
	Container,
	Head,
	Heading,
	Hr,
	Html,
	Preview,
	Section,
	Tailwind,
	Text,
} from "@react-email/components";

interface TwoFactorOtpEmailProps {
	username?: string;
	otp?: string;
}

export const TwoFactorOtpEmail = ({ username, otp }: TwoFactorOtpEmailProps) => {
	return (
		<Html>
			<Head />
			<Preview>Your Better Auth verification code</Preview>
			<Tailwind>
				<Body className="bg-white my-auto mx-auto font-sans px-2">
					<Container className="border border-solid border-[#eaeaea] rounded my-[40px] mx-auto p-[20px] max-w-[465px]">
						<Heading className="text-black text-[24px] font-normal text-center p-0 my-[30px] mx-0">
							Your <strong>Better Auth</strong> verification code
						</Heading>
						<Text className="text-black text-[14px] leading-[24px]">
							Hello {username},
						</Text>
						<Text className="text-black text-[14px] leading-[24px]">
							Use the code below to finish signing in. It expires shortly.
						</Text>
						<Section className="text-center mt-[32px] mb-[32px]">
							<Text className="text-black text-[32px] font-mono tracking-[0.3em] font-semibold">
								{otp}
							</Text>
						</Section>
						<Hr className="border border-solid border-[#eaeaea] my-[26px] mx-0 w-full" />
						<Text className="text-[#666666] text-[12px] leading-[24px]">
							If you didn't try to sign in, change your password and contact
							support.
						</Text>
					</Container>
				</Body>
			</Tailwind>
		</Html>
	);
};

export function reactTwoFactorOtpEmail(props: TwoFactorOtpEmailProps) {
	return <TwoFactorOtpEmail {...props} />;
}
