```
update Add development environment configuration, I18n support, route adjustments, and various hooks refactoring ```
This commit is contained in:
@@ -3,23 +3,23 @@ import { useState } from 'react';
|
||||
export const useFormInput = (initialValue = '') => {
|
||||
const [value, setValue] = useState(initialValue);
|
||||
|
||||
const handleChange = async (e) => {
|
||||
const handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const tempValue = await e.currentTarget.value;
|
||||
setValue(tempValue);
|
||||
};
|
||||
|
||||
return {
|
||||
value,
|
||||
reset: (newValue) => setValue(newValue),
|
||||
reset: (newValue: string) => setValue(newValue),
|
||||
onIonChange: handleChange,
|
||||
onKeyUp: handleChange,
|
||||
};
|
||||
};
|
||||
|
||||
export const validateForm = (fields) => {
|
||||
let errors = [];
|
||||
export const validateForm = (fields: { required: boolean; id: string; input: { state: { value: string } } }[]) => {
|
||||
let errors: { id: string; message: string }[] = [];
|
||||
|
||||
fields.forEach((field) => {
|
||||
fields.forEach((field: { required: boolean; id: string; input: { state: { value: string } } }) => {
|
||||
if (field.required) {
|
||||
const fieldValue = field.input.state.value;
|
||||
|
||||
|
Reference in New Issue
Block a user