import { FC } from "react";
import { IconLock, IconLockOpen } from "@tabler/icons-react";
import { CheckboxProps } from "@mantine/core";
import ActionIconWithTip from "@/components/ui/ActionIconWithTip/ActionIconWithTip";

type RestProps = {
    value: boolean;
    onChange: (value: boolean) => void;
};

type Props = Omit<CheckboxProps, "value" | "onChange"> & RestProps;

const LockCheckbox: FC<Props> = props => {
    const getIcon = () => (props.value ? <IconLock /> : <IconLockOpen />);

    const handleChange = () => props.onChange(!props.value);

    return (
        <ActionIconWithTip
            onClick={handleChange}
            variant={props.variant}>
            {getIcon()}
        </ActionIconWithTip>
    );
};

export default LockCheckbox;
