@@ -255,42 +257,47 @@ export function LyricSearchInputField({ id, placeholder, setShowLyrics }) {
}
-export const UICheckbox = forwardRef(function UICheckbox(opts = {}, ref) {
+export const UICheckbox = forwardRef(function UICheckbox(props = {}, ref) {
const [checked, setChecked] = useState(false);
- const [showAlert, setShowAlert] = useState(false);
- let valid_exclusions = true;
+
useImperativeHandle(ref, () => ({
setChecked: (val) => setChecked(val),
checked,
}));
-
- const verifyExclusions = (e) => {
- let exclude_error = false;
- if (($("#exclude-checkboxes").find("input:checkbox").filter(":checked").length == 3)){
- $("#exclude-checkboxes").find("input:checkbox").each(function () {
- exclude_error = true;
+
+ const verifyExclusions = () => {
+ const checkedCount = $("#exclude-checkboxes input:checkbox:checked").length;
+ if (checkedCount === 3) {
+ $("#exclude-checkboxes input:checkbox").each(function () {
this.click();
});
- if (exclude_error) {
- toast.error("All sources were excluded; exclusions have been reset.",
- { style: { backgroundColor: "rgba(255, 0, 0, 0.5)", color: 'inherit' } },
- );
- }
+ toast.error(
+ "All sources were excluded; exclusions have been reset.",
+ { style: { backgroundColor: "rgba(255, 0, 0, 0.5)", color: "inherit" } }
+ );
}
};
- return (
-
-
{
- setChecked(e.target.checked);
- verifyExclusions();
- }}
- />
+
+ const handleChange = (e) => {
+ const newChecked = e.target.checked;
+ setChecked(newChecked);
+ if (props.onToggle) {
+ const source = props.label; // Use label as source identifier
+ props.onToggle(source);
+ }
+ verifyExclusions();
+ };
+
+ return (
+
+
);
});