UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

31 lines (30 loc) 1.93 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import Input from '../../../components/Input'; import { Tag } from '../../../components/Tag'; import { useOnePageAdaptableWizardContext } from '../../Wizard/OnePageAdaptableWizard'; import { Box, Flex } from '../../../components/Flex'; import { Card } from '../../../components/Card'; export const renderReportNameSummary = (report) => { return (_jsxs(Box, { className: "twa:text-2", children: [' ', "Report Name: ", _jsx(Tag, { children: report.Name })] })); }; export const isValidReportName = (report, api) => { if (!report.Name) { return 'Report name cannot be empty'; } const reportsWithSameNameCount = api.exportApi .getAllReports() .filter((r) => report.Name === r.Name).length; const hasAlreadyExistingName = report.Uuid ? reportsWithSameNameCount > 1 : reportsWithSameNameCount > 0; return hasAlreadyExistingName ? 'A Report already exists with that name' : true; }; export const ReportNameWizardSection = (props) => { const { data } = useOnePageAdaptableWizardContext(); return (_jsx(Flex, { flexDirection: "column", className: "twa:gap-3 twa:p-3", children: _jsxs(Card, { shadow: false, children: [_jsxs(Card.Title, { children: [_jsx(Box, { className: "twa:font-medium", children: "Name" }), _jsx(Box, { className: "twa:text-xs twa:opacity-70 twa:font-normal twa:max-w-[520px]", children: "Provide a unique name for the Report" })] }), _jsx(Card.Body, { className: "twa:p-1", children: _jsx(Input, { "data-name": "export-name", className: "twa:max-w-[300px] twa:w-full", type: "text", autoFocus: true, placeholder: "Enter Name", value: data.Name, onChange: (e) => { props.onChange({ ...data, Name: e.target.value, }); } }) })] }) })); };