import useSWR from "swr"; import { Field, reduxForm } from "redux-form"; import router from "next/router"; import DatePicker from "react-datepicker"; import React, { useState } from "react"; import "react-datepicker/dist/react-datepicker.css"; import moment from "moment"; 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 } = props; const required = (value) => (value ? undefined : "Required"); 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 ( <>
{touched && error && ( Error: {" "} {errorMsg} )}
); }; 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 ( <>
{touched && error && ( Error: {" "} {errorMsg} )}
{Object.keys(options).map((key, index) => (
))}
); }; export function YesNofield(props) { const { name, label } = props; const yesNo = ["Yes", "No"]; const required = (value) => (value ? undefined : "Required"); return ( ); } const RenderPickList = ({ datafieldname, name, label, input, meta: { touched, errorStr }, }) => { const fetcher = (url) => fetch(url).then((res) => res.json()); const { data, error } = useSWR("/api/lookups/" + datafieldname, fetcher); if (error) return (
); if (!data) return (
{label} loading...
); //console.log(JSON.stringify(data.GlobalOptionSet.Options)); const dropdownObj = data.GlobalOptionSet.Options; 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 (
); }