import React from "react";
import {LucideIcon} from "lucide-react";
import InputField from "@/components/form/InputField";
import ToggleWithConfirmation from "@/components/form/ToggleWithConfirmation";
import {AlertType} from "@/components/ui/AlertBox";

interface ToggleFieldProps {
    icon: LucideIcon;
    label: string;
    checked: boolean;
    onChange: (value: boolean) => void;
    alertTitle: string;
    alertMessage: string;
    alertType: AlertType;
    confirmText?: string;
    cancelText?: string;
}

export default function ToggleField(
    {
        icon,
        label,
        checked,
        onChange,
        alertTitle,
        alertMessage,
        alertType,
        confirmText,
        cancelText,
    }: ToggleFieldProps) {
    return (
        <InputField
            icon={icon}
            fieldName={label}
            centered
            input={
                <ToggleWithConfirmation
                    checked={checked}
                    onChange={onChange}
                    alertTitle={alertTitle}
                    alertMessage={alertMessage}
                    alertType={alertType}
                    confirmText={confirmText}
                    cancelText={cancelText}
                />
            }
        />
    );
}
