import { useSettings } from "@/hooks/useSettings";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { useTranslation } from "react-i18next";

export function TelemetrySwitch() {
  const { settings, updateSettings } = useSettings();
  const { t } = useTranslation("settings");
  return (
    <div className="flex items-center space-x-2">
      <Switch
        id="telemetry-switch"
        aria-label="Telemetry"
        checked={settings?.telemetryConsent === "opted_in"}
        onCheckedChange={() => {
          updateSettings({
            telemetryConsent:
              settings?.telemetryConsent === "opted_in"
                ? "opted_out"
                : "opted_in",
          });
        }}
      />
      <Label htmlFor="telemetry-switch">{t("telemetry.enable")}</Label>
    </div>
  );
}
