diff --git a/src/components/LabTest/TableFilter.tsx b/src/components/LabTest/TableFilter.tsx index 712728a9aa7..1a3dab1a24b 100644 --- a/src/components/LabTest/TableFilter.tsx +++ b/src/components/LabTest/TableFilter.tsx @@ -68,154 +68,159 @@ const TableFilter: React.FC = ({ keys, onFiltersChange }) => {
{/* Display Applied Filters */}
- {filters.map((filter, index) => ( -
- filter - {/* Column Label */} - - {keys.find((key) => key.key === filter.column)?.label} - + {filters.map((filter, index) => { + const commonInputProps = { + value: filter.value, + onChange: (e: React.ChangeEvent) => + updateFilter(index, "value", e.target.value), + }; - {/* Separator */} - - - {/* Operator */} - - - - - -
    - {keys - .find((key) => key.key === filter.column) - ?.operators.map((op) => ( -
  • - -
  • - ))} -
-
-
+ return ( +
+ filter + {/* Column Label */} + + {keys.find((key) => key.key === filter.column)?.label} + - {/* Separator */} - + {/* Separator */} + - {/* Value */} - - - - - - {keys.find((key) => key.key === filter.column)?.type === - "checkbox" ? ( -
+ {/* Operator */} + + + + + +
    {keys .find((key) => key.key === filter.column) - ?.options?.map((option) => ( -
    - { - let newValues = Array.isArray(filter.value) - ? [...filter.value] - : []; - if (checked) { - newValues.push(option); - } else { - newValues = newValues.filter( - (val) => val !== option, - ); - } - updateFilter(index, "value", newValues); - }} - /> - -
    + ?.operators.map((op) => ( +
  • + +
  • ))} -
- ) : keys.find((key) => key.key === filter.column)?.type === - "radio" ? ( - updateFilter(index, "value", val)} + +
+
+ + {/* Separator */} + + + {/* Value */} + + + + + + {keys.find((key) => key.key === filter.column)?.type === + "checkbox" ? (
{keys .find((key) => key.key === filter.column) - ?.options?.map((option, idx) => { - const optionId = `${filter.column}-${idx}`; - return ( -
- - -
- ); - })} + ?.options?.map((option) => ( +
+ { + let newValues = Array.isArray(filter.value) + ? [...filter.value] + : []; + if (checked) { + newValues.push(option); + } else { + newValues = newValues.filter( + (val) => val !== option, + ); + } + updateFilter(index, "value", newValues); + }} + /> + +
+ ))}
- - ) : ( - - updateFilter(index, "value", e.target.value) - } - placeholder="Enter value" - className="text-sm" - /> - )} -
-
+ ) : keys.find((key) => key.key === filter.column)?.type === + "radio" ? ( + updateFilter(index, "value", val)} + > +
+ {keys + .find((key) => key.key === filter.column) + ?.options?.map((option, idx) => { + const optionId = `${filter.column}-${idx}`; + return ( +
+ + +
+ ); + })} +
+
+ ) : ( + + )} + + - + - {/* Remove Button */} - -
- ))} + {/* Remove Button */} + +
+ ); + })}
{/* Add Filter Button */}