|
|
|
@ -2,7 +2,7 @@ import { FunctionComponent, ReactElement, useCallback } from "react";
|
|
|
|
import { styled } from "@mui/joy";
|
|
|
|
import { styled } from "@mui/joy";
|
|
|
|
import IconButton from "@mui/joy/IconButton";
|
|
|
|
import IconButton from "@mui/joy/IconButton";
|
|
|
|
import { MinusSmIcon } from "@heroicons/react/solid";
|
|
|
|
import { MinusSmIcon } from "@heroicons/react/solid";
|
|
|
|
import lodash from "lodash";
|
|
|
|
import TextField from "./global/FormElements/InputField";
|
|
|
|
|
|
|
|
|
|
|
|
export interface IFieldType {
|
|
|
|
export interface IFieldType {
|
|
|
|
name: string;
|
|
|
|
name: string;
|
|
|
|
@ -11,7 +11,6 @@ export interface IFieldType {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface IRecordProps {
|
|
|
|
export interface IRecordProps {
|
|
|
|
formik: any;
|
|
|
|
|
|
|
|
fields: IFieldType[];
|
|
|
|
fields: IFieldType[];
|
|
|
|
index: number;
|
|
|
|
index: number;
|
|
|
|
onRemove: (index: number) => void;
|
|
|
|
onRemove: (index: number) => void;
|
|
|
|
@ -30,7 +29,7 @@ const RemoveButton = styled(IconButton)``;
|
|
|
|
const Record: FunctionComponent<IRecordProps> = (
|
|
|
|
const Record: FunctionComponent<IRecordProps> = (
|
|
|
|
props: IRecordProps
|
|
|
|
props: IRecordProps
|
|
|
|
): ReactElement => {
|
|
|
|
): ReactElement => {
|
|
|
|
const { formik, fields, index, onRemove } = props;
|
|
|
|
const { fields, index, onRemove } = props;
|
|
|
|
|
|
|
|
|
|
|
|
const handleRemove = useCallback(() => {
|
|
|
|
const handleRemove = useCallback(() => {
|
|
|
|
onRemove(index);
|
|
|
|
onRemove(index);
|
|
|
|
@ -39,17 +38,12 @@ const Record: FunctionComponent<IRecordProps> = (
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Root>
|
|
|
|
<Root>
|
|
|
|
{fields.map(({ name, placeholder, required }) => (
|
|
|
|
{fields.map(({ name, placeholder, required }) => (
|
|
|
|
<input
|
|
|
|
<TextField
|
|
|
|
key={name}
|
|
|
|
key={name}
|
|
|
|
id={name}
|
|
|
|
id={name}
|
|
|
|
name={name}
|
|
|
|
name={name}
|
|
|
|
type="text"
|
|
|
|
|
|
|
|
placeholder={placeholder + (required ? "*" : "")}
|
|
|
|
placeholder={placeholder + (required ? "*" : "")}
|
|
|
|
autoComplete="none"
|
|
|
|
|
|
|
|
className="input-util"
|
|
|
|
|
|
|
|
required={required}
|
|
|
|
required={required}
|
|
|
|
onChange={formik.handleChange}
|
|
|
|
|
|
|
|
value={lodash.get(formik.values, name)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
<RemoveButton
|
|
|
|
<RemoveButton
|
|
|
|
|