diff --git a/src/admin/components/FormField.jsx b/src/admin/components/FormField.jsx new file mode 100644 index 0000000..59597bf --- /dev/null +++ b/src/admin/components/FormField.jsx @@ -0,0 +1,23 @@ +/** + * Formularovy wrapper pro label + input + error. + * Nahrazuje opakovany pattern admin-form-group + has-error + admin-form-error. + * + * @param {string} label - Text labelu + * @param {string} [error] - Chybova zprava (zobrazi se pod inputem) + * @param {boolean} [required] - Zobrazi cervenu hvezdicku + * @param {string} [className] - Extra CSS trida na wrapperu + * @param {React.ReactNode} children - Input/select/textarea element + */ +export default function FormField({ label, error, required, className, children }) { + const groupClass = `admin-form-group${error ? ' has-error' : ''}${className ? ` ${className}` : ''}` + + return ( +
+ + {children} + {error && {error}} +
+ ) +} diff --git a/src/admin/pages/Vehicles.jsx b/src/admin/pages/Vehicles.jsx index 8fcd1bd..9730b5a 100644 --- a/src/admin/pages/Vehicles.jsx +++ b/src/admin/pages/Vehicles.jsx @@ -8,6 +8,7 @@ import useModalLock from '../hooks/useModalLock' import { formatKm } from '../utils/formatters' import apiFetch from '../utils/api' +import FormField from '../components/FormField' const API_BASE = '/api/admin' export default function Vehicles() { @@ -338,8 +339,7 @@ export default function Vehicles() {
-
- + - {errors.spz && {errors.spz}} -
+ -
- + - {errors.name && {errors.name}} -
+
-
- + -
+ -
- + -
+