import { createUID, DateInput, FileInput, Input, Option, Select, TextArea } from '@pega/cosmos-react-core';
export const fieldGroupReducer = (groupMeta, FieldRenderer) => (items, payload) => {
    switch (payload.action) {
        case 'add':
            return [
                ...items,
                {
                    name: `${groupMeta.label} ${items.length + 1}`,
                    headingTag: 'h3',
                    id: createUID(),
                    children: groupMeta.fields.map(props => <FieldRenderer {...props} key={props.label}/>)
                }
            ];
        case 'delete':
            return items
                .filter(group => group.id !== payload.id)
                .map((group, i) => ({
                ...group,
                name: `${groupMeta.label} ${i + 1}`,
                headingTag: 'h3'
            }));
        default:
            return items;
    }
};
export const DemoFieldRenderer = ({ label, type }) => {
    if (type === 'text') {
        return <Input label={label} key={label}/>;
    }
    return null;
};
export const demoGroupMeta = {
    label: 'Applicant',
    fields: [
        {
            type: 'text',
            label: 'Applicant name'
        }
    ]
};
export const ExpensesFieldRenderer = ({ label, type }) => {
    if (type === 'text') {
        return <Input label={label}/>;
    }
    if (type === 'select') {
        return (<Select label={label}>
        <Option>Select</Option>
        <Option>Advertising</Option>
        <Option>Car and truck expenses</Option>
        <Option>Commissions and fees</Option>
        <Option>Contract labor</Option>
        <Option>Legal and professional services</Option>
        <Option>Office expense</Option>
        <Option>Rent or lease</Option>
        <Option>Vehicles, machinery, and equipment</Option>
        <Option>Repairs and maintenance</Option>
        <Option>Travel and meals</Option>
        <Option>Deductible meals</Option>
        <Option>Utilities</Option>
        <Option>Other</Option>
      </Select>);
    }
    if (type === 'file') {
        return <FileInput label={label} multiple/>;
    }
    if (type === 'textarea') {
        return <TextArea label={label}/>;
    }
    if (type === 'date') {
        return <DateInput label={label}/>;
    }
    return null;
};
export const expensesGroupMeta = {
    label: 'Expense',
    fields: [
        { type: 'select', label: 'Type of expense' },
        { type: 'date', label: 'Date of expense' },
        { type: 'file', label: 'Receipts' },
        { type: 'textarea', label: 'Notes' }
    ]
};
export const InsuranceFieldRenderer = ({ label, type }) => {
    if (type === 'text') {
        return <Input label={label}/>;
    }
    if (type === 'select') {
        return (<Select label={label}>
        <Option>Select</Option>
        <Option>Mother</Option>
        <Option>Father</Option>
        <Option>Guardian</Option>
        <Option>Child</Option>
        <Option>Spouse</Option>
        <Option>Sibling</Option>
        <Option>Other</Option>
      </Select>);
    }
    return null;
};
export const insuranceGroupMeta = {
    label: 'Entry',
    fields: [
        { type: 'text', label: 'First name' },
        { type: 'text', label: 'Last name' },
        { type: 'select', label: 'Relationship' }
    ]
};
//# sourceMappingURL=FieldGroupList.mocks.jsx.map