import React from 'react'; import DefaultValueSummary from "./value"; import Checkbox from "./value/Checkbox"; import FetchOrg from "./value/FetchOrg"; import Sum from "./value/Sum"; import { ErrorMessage } from "../../primitives/Errors"; import Html from "../helper/Html"; import { NodeSummary as StyledNodeSummary } from "../../primitives/Summary"; import ErrorIcon from "../graphics/ErrorIcon"; import SoftError from "./SoftError"; import Information from "./Information"; import { RenderableNode } from "../../index"; import { hasProperty, isOfType } from "../../utils/is-of-type"; import { get } from 'lodash'; const ignoreNodes = ["Text", "Image"]; const overrideValueSummary = { FetchOrg, Sum, Checkbox }; type Props = { node: RenderableNode; value?: any; } export default function NodeSummary({ node }: Props) { if (isOfType(node, ["Error"])) { return ; } if (isOfType(node, ["Information"])) { return ; } if (isOfType(node, ["Group", "ErrorOk"])) { return ( <> {node.children.map((child: any) => ( ))} ); } if (ignoreNodes.includes(node.type) || !hasProperty(node, 'property')) { return null; } const ValueSummary = get(overrideValueSummary, node.type, DefaultValueSummary); const errors = get(node, 'errors') as any const errorDescription = get(node, 'errorDescription') as any return ( {errors.validation.error ? ( {errors.validation.message} ) : null} {errors.disabled.length ? ( {errorDescription} ) : null} ); }