import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import { Field, formValueSelector, reduxForm } from "redux-form"; let AboutYou = (props) => { let { t } = useTranslation(); const router = useRouter(); const { locale } = router; const { onSubmit, handleSubmit, appellantAgentValue } = props; const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"]; const appellantAgent = router.locale == "cy" ? ["Apelydd", "Asiant"] : ["Appellant", "Agent"]; const contactPref = router.locale == "cy" ? ["Ebost", "Post"] : ["Email", "Post"]; const required = (value) => (value ? undefined : "Is required"); const emailRegex = /(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/gi; const email = (value) => value && !emailRegex.test(value) ? "Invalid email address" : undefined; const phoneNumber = (value) => value && !/^(?:(?:\(?(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?(?:\(?0\)?[\s-]?)?)|(?:\(?0))(?:(?:\d{5}\)?[\s-]?\d{4,5})|(?:\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3}))|(?:\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4})|(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}))(?:[\s-]?(?:x|ext\.?|\#)\d{3,4})?$/i.test( value ) ? "Invalid phone number" : undefined; const RenderTextfield = ({ id, className, rows, datafieldname, name, label, input, type, errorMsg, disabled, meta: { touched, error }, ...custom }) => { return ( <>
{touched && error && ( Error: {" "} {touched && ((error && ( {errorMsg ? errorMsg : error} )) || (warning && {warning}))} )}
); }; const RenderYesNo = ({ datafieldname, name, label, id, errorMsg, options, input: { onChange, value }, meta: { touched, error }, ...custom }) => { return ( <>
{touched && error && ( Error: {" "} {errorMsg} )}
{Object.keys(options).map((key, index) => (
))}
); }; const onHandleSubmit = (values) => { event.preventDefault(); console.log(values); router.replace("/newappeal"); }; return (
Who can appeal?
Only those named as an applicant on the original application form can submit an appeal. if you are submitting an appeal on behalf of a company state the name of the company you are representing,
{(appellantAgentValue == "Appellant" || appellantAgentValue == "Apelydd") && ( <>

{t("newappeal:about-you-appellant-contact-details")}

{" "} )} {(appellantAgentValue == "Agent" || appellantAgentValue == "Asiant") && ( <>

{t("newappeal:about-you-appellant-contact-details")}

{" "}

{t("newappeal:about-you-agent-contact-details")}

{" "} {" "} )} ); }; const mapStateToProps = (state) => { return { search: state.search, searchResultsObj: state.searchResultsObj, formData: state.formData, appealType: state.appealType, //form: state.form, }; }; const mapDispatchToProps = (dispatch) => { return {}; }; AboutYou = reduxForm({ form: "caseForm", // a unique identifier for this form destroyOnUnmount: false, })(AboutYou); const selector = formValueSelector("caseForm"); // <-- same as form name AboutYou = connect((state) => { // can select values individually const appellantAgentValue = selector(state, "appellantAgent"); return { appellantAgentValue, }; })(AboutYou); export default AboutYou; // export default connect( // mapStateToProps, // mapDispatchToProps // )( // reduxForm({ // form: "caseForm", // destroyOnUnmount: false, // })(AboutYou) // );