import { FormControlLabel, Checkbox, Box, Typography } from "@mui/material"; import type { CompanySettingsCustomField } from "../../lib/queries/settings"; interface Props { /** Company custom field definitions, in positional order (index = print key). */ fields: CompanySettingsCustomField[]; /** Currently selected positional indices. */ selected: number[]; /** Read-only (document not editable / locked by another user). */ disabled?: boolean; onChange: (next: number[]) => void; } /** * Per-document picker: choose which COMPANY custom fields print on this * document's PDF. Selection is positional (matches the PDF `custom_` keys). * Renders nothing when the company has defined no printable custom fields. */ export default function CustomFieldsPrintPicker({ fields, selected, disabled = false, onChange, }: Props) { const printable = fields.filter((f) => (f.value || "").trim()); if (printable.length === 0) return null; const toggle = (idx: number, checked: boolean) => { const set = new Set(selected); if (checked) set.add(idx); else set.delete(idx); onChange([...set].sort((a, b) => a - b)); }; return ( VlastnĂ­ pole na PDF {fields.map((f, idx) => { if (!(f.value || "").trim()) return null; const label = (f.name || "").trim() ? `${f.name}: ${f.value}` : f.value; return ( toggle(idx, e.target.checked)} /> } label={{label}} /> ); })} ); }