debian-image-builder-frontend/src/Components/CreateImageWizard/steps/Hostname/components/HostnameInput.tsx
Michal Gold 12aa5cdf52 Wizard: Refactor hostname and blueprint name inputs
This commit Implement refactor of HookValidatedInput for hostname and blueprint name
fields, addressing the following bugs:

1) Fixes a bug where the validation symbol persisted after a user deleted the value in the hostname field.
2) Fixes a bug where the validation symbol persisted after a user deleted the value in the blueprint name field.

These changes improve code maintainability and provide a more consistent user experience.
2025-03-11 14:42:50 -05:00

37 lines
1,007 B
TypeScript

import React from 'react';
import { FormGroup } from '@patternfly/react-core';
import { useAppDispatch, useAppSelector } from '../../../../../store/hooks';
import {
changeHostname,
selectHostname,
} from '../../../../../store/wizardSlice';
import { useHostnameValidation } from '../../../utilities/useValidation';
import { ValidatedInputAndTextArea } from '../../../ValidatedInput';
const HostnameInput = () => {
const dispatch = useAppDispatch();
const hostname = useAppSelector(selectHostname);
const stepValidation = useHostnameValidation();
const handleChange = (e: React.FormEvent, value: string) => {
dispatch(changeHostname(value));
};
return (
<FormGroup label="Hostname">
<ValidatedInputAndTextArea
ariaLabel="hostname input"
value={hostname}
onChange={handleChange}
placeholder="Add a hostname"
stepValidation={stepValidation}
fieldName="hostname"
/>
</FormGroup>
);
};
export default HostnameInput;