Skip to content
Snippets Groups Projects
Commit 3fd429a1 authored by deep1401's avatar deep1401
Browse files

Remove redundant code

parent 881822fa
No related branches found
No related tags found
No related merge requests found
...@@ -461,153 +461,6 @@ function CustomAutocompleteWidget<T = any, S extends StrictRJSFSchema = RJSFSche ...@@ -461,153 +461,6 @@ function CustomAutocompleteWidget<T = any, S extends StrictRJSFSchema = RJSFSche
); );
} }
// type EvaluationField = {
// name: string;
// expression: string;
// return_type: 'boolean' | 'number';
// };
// const CustomEvaluationWidget = (props: WidgetProps<any>) => {
// const { id, value, onChange, disabled, readonly } = props;
// const valueSent = value;
// console.log("Value", valueSent);
// const parseValue = (val: any): EvaluationField[] => {
// if (Array.isArray(val)) {
// if (val.every(item => typeof item === "string")) {
// // If every element is a string: join them and parse the result.
// try {
// const joined = val.join(',');
// console.log("Joined", joined);
// console.log("TYPE", typeof joined);
// const parsed = JSON.parse(joined);
// console.log("PARSED HERE", parsed);
// return Array.isArray(parsed) ? parsed : [];
// } catch (err) {
// console.error("Error parsing evaluation widget value:", err);
// return [];
// }
// } else {
// // If not all elements are strings, assume it's already an array of EvaluationField.
// return val;
// }
// } else if (typeof val === "string") {
// try {
// return JSON.parse(val);
// } catch (err) {
// console.error("Error parsing evaluation widget value string:", err);
// return [];
// }
// }
// return [];
// };
// // const parsed = parseValue(value);
// // Initialize state by parsing the incoming value
// const [evalMetrics, setEvalMetrics] = React.useState<EvaluationField[]>(parseValue(valueSent));
// // Update state if a new default value is provided
// React.useEffect(() => {
// const parsed = parseValue(valueSent);
// if (JSON.stringify(parsed) !== JSON.stringify(evalMetrics)) {
// setEvalMetrics(parsed);
// }
// }, [value]);
// // Propagate state changes upstream.
// React.useEffect(() => {
// onChange(evalMetrics);
// }, [evalMetrics]);
// const handleAddField = () => {
// setEvalMetrics([
// ...evalMetrics,
// { name: '', expression: '', return_type: 'boolean' }
// ]);
// };
// const handleFieldChange = (
// index: number,
// field: keyof EvaluationField,
// newValue: string
// ) => {
// const updated = evalMetrics.map((evaluation, i) =>
// i === index ? { ...evaluation, [field]: newValue } : evaluation
// );
// setEvalMetrics(updated);
// };
// const handleRemoveField = (index: number) => {
// const updated = evalMetrics.filter((_, i) => i !== index);
// setEvalMetrics(updated);
// };
// return (
// <div id={id}>
// {evalMetrics.map((evaluation, index) => (
// <div
// key={index}
// style={{
// marginBottom: '1rem',
// border: '1px solid #ccc',
// padding: '0.5rem'
// }}
// >
// <Input
// placeholder="Evaluation Name"
// value={evaluation.name}
// onChange={(e) =>
// handleFieldChange(index, 'name', e.target.value)
// }
// disabled={disabled || readonly}
// style={{ marginBottom: '0.5rem' }}
// />
// <Textarea
// placeholder="Regular Expression"
// value={evaluation.expression}
// onChange={(e) =>
// handleFieldChange(index, 'expression', e.target.value)
// }
// disabled={disabled || readonly}
// style={{ marginBottom: '0.5rem' }}
// />
// <Select
// placeholder="Output Type"
// value={evaluation.return_type}
// onChange={(e, newValue) =>
// handleFieldChange(index, 'return_type', newValue as string)
// }
// disabled={disabled || readonly}
// style={{ marginBottom: '0.5rem' }}
// >
// <Option value="boolean">Boolean</Option>
// <Option value="number">Number</Option>
// </Select>
// <Button
// onClick={() => handleRemoveField(index)}
// disabled={disabled || readonly}
// size="sm"
// variant="outlined"
// >
// Remove Field
// </Button>
// </div>
// ))}
// <Button
// onClick={handleAddField}
// disabled={disabled || readonly}
// variant="solid"
// >
// Add Field
// </Button>
// {/* Hidden input to capture the JSON result on form submission */}
// <input type="hidden" id={id} name={id} value={JSON.stringify(evalMetrics)} />
// </div>
// );
// };
function CustomFieldTemplate(props: FieldTemplateProps) { function CustomFieldTemplate(props: FieldTemplateProps) {
const { const {
id, id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment