"use client"; import type { CheckboxRendererProps } from "./types"; export function CheckboxRenderer({ component, getQueryResult }: CheckboxRendererProps) { const checkboxSize = component.checkboxSize || 18; const checkboxColor = component.checkboxColor || "#2563eb"; const checkboxBorderColor = component.checkboxBorderColor || "#6b7280"; const checkboxLabelPosition = component.checkboxLabelPosition || "right"; const checkboxLabel = component.checkboxLabel || ""; const getCheckboxValue = (): boolean => { if (component.checkboxFieldName && component.queryId) { const queryResult = getQueryResult(component.queryId); if (queryResult && queryResult.rows && queryResult.rows.length > 0) { const row = queryResult.rows[0]; const val = row[component.checkboxFieldName]; if (val === true || val === "true" || val === "Y" || val === 1 || val === "1") return true; return false; } return false; } return component.checkboxChecked === true; }; const isChecked = getCheckboxValue(); return (
{isChecked && ( )}
{checkboxLabel && ( {checkboxLabel} )}
); }