import * as React from "react";

import {TextInputElement} from "./text-input";
import {DateInputElement} from "./date-input";
import {DropdownSingleInputElement} from "./dropdown-single";

export interface IProps {
    type: string,
    definition: any
}

export const InputElementTypes: {
    Text: string,
    Date: string,
    DropdownSingle: string
} = {
    Text: 'text',
    Date: 'date',
    DropdownSingle: 'dropdown-single'
};

export function InputElement(props: IProps) {
    const {type, definition} = props;
    switch (type) {
        case InputElementTypes.Text:
            return <TextInputElement definition={definition}/>;
        case InputElementTypes.Date:
            return <DateInputElement definition={definition}/>;
        case InputElementTypes.DropdownSingle:
            return <DropdownSingleInputElement definition={definition}/>;
    }
    return <div>Not yet supported: {definition.label}</div>;
}