import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import {
InputText,
InputDateRange,
InputMultiSelect,
InputLabelWrapper,
} from '@ohif/ui';
const InputGroup = ({
inputMeta,
values,
onValuesChange,
sorting,
onSortingChange,
isSortingEnable,
}) => {
const { sortBy, sortDirection } = sorting;
const handleFilterLabelClick = name => {
if (isSortingEnable) {
let _sortDirection = 'ascending';
if (sortBy === name) {
if (sortDirection === 'ascending') {
_sortDirection = 'descending';
} else if (sortDirection === 'descending') {
_sortDirection = 'none';
}
}
onSortingChange({
sortBy: _sortDirection !== 'none' ? name : '',
sortDirection: _sortDirection,
});
}
};
const renderFieldInputComponent = ({
name,
displayName,
inputProps,
isSortable,
inputType,
}) => {
const _isSortable = isSortable && isSortingEnable;
const _sortDirection = sortBy !== name ? 'none' : sortDirection;
const onLabelClick = () => {
handleFilterLabelClick(name);
};
const handleFieldChange = newValue => {
onValuesChange({
...values,
[name]: newValue,
});
};
const handleDateRangeFieldChange = ({ startDate, endDate }) => {
onValuesChange({
...values,
[name]: {
startDate: startDate,
endDate: endDate,
},
});
};
switch (inputType) {
case 'Text':
return (