Modified HBForm & HBContest Page

This commit is contained in:
ZacTohZY
2024-07-29 21:26:34 +08:00
parent 34a96a8445
commit a76ec634ca
6 changed files with 203 additions and 129 deletions

View File

@@ -10,16 +10,28 @@ interface NextUIFormikInputProps {
placeholder: string;
labelPlacement?: "inside" | "outside";
startContent?: JSX.Element;
readOnly?: boolean;
setFieldValue?: (field: string, value: any, shouldValidate?: boolean) => void;
}
const NextUIFormikInput = ({
label,
startContent,
readOnly = false,
setFieldValue,
...props
}: NextUIFormikInputProps) => {
const [field, meta] = useField(props.name);
const [inputType, setInputType] = useState(props.type);
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { value } = e.target;
field.onChange(e);
if (setFieldValue) {
setFieldValue(props.name, value);
}
};
return (
<Input
{...field}
@@ -43,6 +55,8 @@ const NextUIFormikInput = ({
</>
) : null
}
readOnly={readOnly}
onChange={handleChange}
/>
);
};