import React from 'react';
import FormLayout, { FormRow } from '../../../../components/FormLayout';
import AdaptableInput from '../../../Components/AdaptableInput';
export const isSettingsValid = (chartDefinition, api) => {
    if (!chartDefinition.Name) {
        return 'A name is required.';
    }
    const allChartDefinitions = api.chartingApi.getExternalChartDefinitions();
    if (allChartDefinitions.some((chartDefinitionLoopItem) => chartDefinitionLoopItem.Uuid !== chartDefinition.Uuid &&
        chartDefinitionLoopItem.Name === chartDefinition.Name)) {
        return 'A Chart with this name already exists.';
    }
    return true;
};
export const SettingsSection = (props) => {
    return (React.createElement(FormLayout, null,
        React.createElement(FormRow, { label: "Name" },
            React.createElement(AdaptableInput, { value: props.chartDefinition.Name, onChange: (e) => props.onChange({
                    ...props.chartDefinition,
                    Name: e.target.value,
                }) }))));
};
