import type { FormEventHandler } from 'react'; import theme from 'themes/theme'; import { ConfigButtons, DescriptionContainer, NameContainer, StyledForm, StyledHeader, StyledInput, TopGrid, LimitContainer, FormActions, IconWrapper, } from './DialogFormTemplate.styles'; import { Button } from '@mui/material'; import { CreateButton } from 'component/common/CreateButton/CreateButton'; import type { IPermissionButtonProps } from 'component/common/PermissionButton/PermissionButton'; import { NamingPatternInfo } from './NamingPatternInfo'; import type { CreateFeatureNamingPatternSchema } from 'openapi'; type FormProps = { createButtonProps: IPermissionButtonProps; description: string; errors: { [key: string]: string }; handleSubmit: FormEventHandler; Icon: React.ReactNode; Limit?: React.ReactNode; name: string; onClose: () => void; configButtons: React.ReactNode; resource: string; setDescription: (newDescription: string) => void; setName: (newName: string) => void; validateName?: () => void; namingPattern?: CreateFeatureNamingPatternSchema; }; export const DialogFormTemplate: React.FC = ({ Limit, handleSubmit, name, namingPattern, setName, description, setDescription, errors, Icon, resource, onClose, configButtons, createButtonProps, validateName = () => {}, }) => { return ( {Icon} Create {resource} setName(e.target.value)} error={Boolean(errors.name)} errorText={errors.name} onBlur={validateName} onFocus={() => { delete errors.name; }} autoFocus InputProps={{ style: { fontSize: theme.typography.h1.fontSize }, }} InputLabelProps={{ style: { fontSize: theme.typography.h1.fontSize }, }} data-testid='FORM_NAME_INPUT' size='medium' /> {namingPattern?.pattern ? ( ) : null} setDescription(e.target.value)} InputProps={{ style: { fontSize: theme.typography.h2.fontSize }, }} InputLabelProps={{ style: { fontSize: theme.typography.h2.fontSize }, }} data-testid='FORM_DESCRIPTION_INPUT' /> {configButtons} {Limit} ); };