68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { Form, Input } from "antd";
|
|
import React from "react";
|
|
import useFormField from "../../../Hooks/useFormField";
|
|
import { MdOutlineEdit } from "react-icons/md";
|
|
import { Field } from "formik";
|
|
import { ValidationFieldPropsInput } from "../utils/types";
|
|
|
|
const Default = ({
|
|
name,
|
|
label,
|
|
placeholder,
|
|
isDisabled,
|
|
onChange,
|
|
type,
|
|
no_label,
|
|
label_icon,
|
|
label2,
|
|
...props
|
|
}: ValidationFieldPropsInput) => {
|
|
const { errorMsg, isError, t } = useFormField(name, props);
|
|
|
|
return (
|
|
<div className="ValidationField w-100">
|
|
{label2 ? (
|
|
<label htmlFor={name} className="text">
|
|
{label2}
|
|
</label>
|
|
) : no_label ? (
|
|
<label htmlFor={name} className="text">
|
|
<span>empty</span>
|
|
</label>
|
|
) : label_icon ? (
|
|
<div className="LabelWithIcon">
|
|
<label htmlFor={name} className="text">
|
|
{t(`input.${label ? label : name}`)}
|
|
</label>
|
|
<MdOutlineEdit size={22} style={{ color: "#A098AE" }} />
|
|
</div>
|
|
) : (
|
|
<label htmlFor={name} className="text">
|
|
{t(`input.${label ? label : placeholder ? placeholder : name}`)}
|
|
</label>
|
|
)}
|
|
|
|
<Form.Item
|
|
hasFeedback
|
|
validateStatus={isError ? "error" : ""}
|
|
help={isError ? errorMsg : ""}
|
|
>
|
|
<Field
|
|
as={Input}
|
|
type={type ?? "text"}
|
|
placeholder={t(
|
|
`input.${placeholder ? placeholder : label ? label : name}`,
|
|
)}
|
|
name={name}
|
|
disabled={isDisabled}
|
|
size="large"
|
|
{...(type === "number" && { min: 0 })}
|
|
{...props}
|
|
/>
|
|
</Form.Item>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default React.memo(Default);
|