"use client";

import { Checkbox } from "@/components/atoms/checkbox";
import { Label } from "@/components/atoms";

interface TermsCheckboxProps {
  checked: boolean;
  onChange: (checked: boolean) => void;
  disabled?: boolean | undefined;
  error?: string | undefined;
}

export function TermsCheckbox({ checked, onChange, disabled, error }: TermsCheckboxProps) {
  return (
    <div className="space-y-1">
      <div className="flex items-start gap-2">
        <Checkbox
          id="acceptTerms"
          checked={checked}
          onChange={e => onChange(e.target.checked)}
          disabled={disabled}
        />
        <Label htmlFor="acceptTerms" className="text-sm font-normal leading-tight cursor-pointer">
          I accept the{" "}
          <a
            href="/terms"
            target="_blank"
            rel="noopener noreferrer"
            className="text-primary hover:underline"
          >
            Terms of Service
          </a>{" "}
          and{" "}
          <a
            href="/privacy"
            target="_blank"
            rel="noopener noreferrer"
            className="text-primary hover:underline"
          >
            Privacy Policy
          </a>{" "}
          <span className="text-danger">*</span>
        </Label>
      </div>
      {error && <p className="text-sm text-danger ml-6">{error}</p>}
    </div>
  );
}
