import { FC, Fragment } from "react";

import { EColumnFilter } from "shared/model/enums";

import { IProps, label } from "../../model";
import { BooleanInput } from "../BooleanInput";
import { DateBetween } from "../DateBetween";
import { DateInput } from "../DateInput";
import { MultipleSelect } from "../MultipleSelect";
import { NumberBetween } from "../NumberBetween";
import { NumberInput } from "../NumberInput";
import { TextInput } from "../TextInput";

export const InputArea: FC<Props> = ({ filterId, setValue, value }) => {
	return (
		<Fragment>
			{filterId === EColumnFilter.Boolean && (
				<BooleanInput setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.TextEqual && (
				<TextInput setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.TextNotEqual && (
				<TextInput setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.TextContain && (
				<TextInput setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.TextNotContain && (
				<TextInput setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.MultipleSelect && (
				<MultipleSelect setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.NumberEqual && (
				<NumberInput label={label.filter} setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.NumberFrom && (
				<NumberInput label={label.from} setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.NumberTo && (
				<NumberInput label={label.to} setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.NumberBetween && (
				<NumberBetween setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.DateEqual && (
				<DateInput label={label.filter} setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.DateFrom && (
				<DateInput label={label.from} setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.DateTo && (
				<DateInput label={label.to} setValue={setValue} value={value} />
			)}
			{filterId === EColumnFilter.DateBetween && (
				<DateBetween setValue={setValue} value={value} />
			)}
		</Fragment>
	);
};

type Props = Omit<IProps, "label"> & { filterId: EColumnFilter };
