import Link from "next/link";
import { connect } from "react-redux";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { Field, reduxForm, change } from "redux-form";
import {
RenderPickList,
RenderTextfield,
RenderRadioList,
RenderMultiline,
RenderRichMultiline,
RenderCondtionalRadioList,
FileUploadField,
} from "./representationElements";
import {
getFormCollectionByID,
getThumbnailIconByExtension,
bytesToSize,
} from "../../utils";
import { useDropzone } from "react-dropzone";
const RepAgent = (props) => {
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
const {
formObj,
appellantApplicantRepresentationArr,
setRepresentationCapacity,
setRepresentationSubmit,
currentView,
setRepFileName,
} = props;
const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
setRepFileName(formObj.representationForm.values);
const files = acceptedFiles.map((file) => (
{file.path} - {file.size} bytes
));
const required = (value) => (value ? undefined : "Required");
return (
<>
{typeof formObj.representationForm.values
.representationType == "undefined" &&
props.representationType != "Select..." ? (
<>
{t(
"myrepresentations:representation-from-an-agent-heading"
)}
>
) : (
)}
{(typeof props.representationType != "undefined" ||
typeof formObj.representationForm.values.representationType !=
"undefined") && (
<>
{t("myrepresentations:enter-comment-label")}
{" "}
>
)}
{typeof formObj.representationForm.values.representationType !=
"undefined" && (
)}
>
);
};
const mapDispatchToProps = (dispatch) => ({
updateField: (form, field, newValue) =>
dispatch(change(form, field, newValue)),
});
export default connect(
null,
mapDispatchToProps
)(
reduxForm({
form: "representationForm",
enableReinitialize: true,
destroyOnUnmount: false,
})(RepAgent)
);