import useSWR from "swr";
import { Field, reduxForm } from "redux-form";
import { useRouter } from "next/router";
import DatePicker from "react-datepicker";
import React, { useState } from "react";
import "react-datepicker/dist/react-datepicker.css";
import moment from "moment";
import jsonpath from "jsonpath";
import fieldLookup from "../../data/crmfieldlookuptranslations.json";
import pickListLookup from "../../data/picklistLookups.json";
import useTranslation from "next-translate/useTranslation";
const RenderTextfield = ({
id,
className,
rows,
datafieldname,
name,
label,
input,
errorMsg,
meta: { touched, error },
...custom
}) => {
return (
<>
{touched && error && (
Error:{" "}
{errorMsg}
)}
>
);
};
export function Textfield(props) {
const { name, label, validate, ticketnumber } = props;
const required = (value) => (value ? undefined : "Required");
if (name == "pinswg_name") {
return (
);
} else {
return (
);
}
}
const RenderMultiline = ({
className,
rows,
datafieldname,
name,
label,
input,
meta: { touched, error },
...custom
}) => {
return (
<>
>
);
};
export function MultiLinefield(props) {
const { name, label } = props;
return (
Do not include personal or financial information, like your
National Insurance number or credit card details.
);
}
const RenderDatePicker = ({
datafieldname,
name,
label,
id,
errorMsg,
input: { onChange, value },
meta: { touched, error },
...custom
}) => {
return (
<>
>
);
};
export function DateFieldPicker(props) {
const { name, label } = props;
const required = (value) => (value ? undefined : "Required");
return (
);
}
export function DateField(props) {
const { name, label } = props;
return (
);
}
const RenderYesNo = ({
datafieldname,
name,
label,
id,
errorMsg,
options,
input: { onChange, value },
meta: { touched, error },
...custom
}) => {
return (
<>
>
);
};
export function YesNofield(props) {
const router = useRouter();
const { name, label } = props;
const yesNo = router.locale == "cy" ? ["Ydw", "Na"] : ["Yes", "No"];
const required = (value) => (value ? undefined : "Required");
return (
);
}
const RenderPickList = ({
datafieldname,
picklistData,
name,
label,
input,
meta: { touched, errorStr },
}) => {
let { t } = useTranslation();
var dropdownObj = jsonpath.query(
picklistData,
"$..value[?(@.LogicalName=='" + datafieldname + "')]..Options"
);
dropdownObj = dropdownObj[0];
return (
{touched && errorStr && {errorStr}}
);
};
export function PickList(props) {
const { name, label, datafieldname } = props;
return (
);
}
export function NumericField(props) {
const { name, label } = props;
return (
);
}
export function DecimalField(props) {
const { name, label } = props;
return (
);
}
const RenderCaseID = {};
export function ReadOnlyfield(props) {
const { name, label, value } = props;
//console.log(props.value.refno);
return (
);
}
const FieldsTranslations = (label) => {
const router = useRouter();
const { locale } = router;
const { appealtypes } = router.query;
let formObj = jsonpath.query(fieldLookup, "$['" + appealtypes + "']");
let labelTrans =
router.locale == "cy"
? jsonpath.query(
formObj,
"$..[?(@.value=='" + label + "')].value_cy"
)
: label;
return labelTrans;
};
const PickListTranslations = (optionValue) => {
const router = useRouter();
const { locale } = router;
const { appealtypes } = router.query;
//console.log(optionValue);
let optionTrans =
router.locale == "cy"
? jsonpath.query(
pickListLookup,
'$..[?(@.value=="' + optionValue + '")].value_cy'
)
: optionValue;
//console.log(optionTrans, optionValue);
return optionTrans;
};