import React from "react"; import { useRouter } from "next/router"; import { Field } from "redux-form"; import fieldLookup from "../../../data/crmfieldlookuptranslations.json"; import { getFieldTranslation } from "../helpers/translationHelpers"; export const RenderYesNo = ({ datafieldname, name, label, id, errorMsg, options, input: { onChange, value }, meta: { touched, error }, ...custom }) => { const router = useRouter(); const { locale } = router; const { appealtypes } = router.query; const translatedLabel = getFieldTranslation({ label, locale, appealtypes, fieldLookup }); return ( <>
{touched && error && ( Error: {" "} {errorMsg} )}
{Object.keys(options).map((key, index) => (
{ let docListObj = custom.documentList; if ( custom.requiredDocumentValue == "Yes" || custom.requiredDocumentValue == "Ydw" || custom.requiredDocumentValue == "true" ) { e.target.value == "Ydw" || e.target.value == "Yes" || e.target.value == "true" ? (docListObj = Object.assign( docListObj, { ["documentCheckList_" + id]: custom.requiredDocumentLabel } )) : delete docListObj[ "documentCheckList_" + id ]; custom.setDocumentsList(docListObj); } }} />
))}
); };