update Add development environment configuration, I18n support, route adjustments, and various hooks refactoring
```
This commit is contained in:
2025-05-16 17:47:05 +08:00
parent 6b917c9fb9
commit 49189a532e
28 changed files with 274 additions and 559 deletions

View File

@@ -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;