Skip to content

Commit

Permalink
Add a default filter type
Browse files Browse the repository at this point in the history
  • Loading branch information
nlinnanen committed Sep 3, 2024
1 parent 220df96 commit 2053459
Showing 1 changed file with 33 additions and 35 deletions.
68 changes: 33 additions & 35 deletions src/app/components/ui/MultifunctionTable/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,6 @@ export const Filter = ({ column, table, setDisplayState }: Props) => {

const columnFilterValue = column.getFilterValue();

if (typeof firstValue === "number") {
return (
<div className="flex w-full justify-between divide-[1px] divide-neutral-700 overflow-hidden">
<input
type="number"
inputMode="numeric"
value={(columnFilterValue as [number, number])?.[0] ?? ""}
onChange={(e) => {
column.setFilterValue((old: [number, number]) => [
e.target.value,
old?.[1],
]);
setDisplayState(1);
}}
placeholder="Min"
className="w-full grow border border-neutral-700 bg-neutral-600 p-3 text-lg font-normal text-neutral-200 outline-none placeholder:text-neutral-800 "
/>
<input
type="number"
inputMode="numeric"
value={(columnFilterValue as [number, number])?.[1] ?? ""}
onChange={(e) => {
column.setFilterValue((old: [number, number]) => [
old?.[0],
e.target.value,
]);
setDisplayState(1);
}}
placeholder="Max"
className="w-full grow border border-neutral-700 bg-neutral-600 p-3 text-lg font-normal text-neutral-200 outline-none placeholder:text-neutral-800 "
/>
</div>
);
}
if (typeof firstValue === "string" && ["💩", " "].includes(firstValue)) {
return <SelectFilter column={column} setDisplayState={setDisplayState} />;
}
Expand All @@ -68,5 +34,37 @@ export const Filter = ({ column, table, setDisplayState }: Props) => {
/>
);
}
return null;

return (
<div className="flex w-full justify-between divide-[1px] divide-neutral-700 overflow-hidden">
<input
type="number"
inputMode="numeric"
value={(columnFilterValue as [number, number])?.[0] ?? ""}
onChange={(e) => {
column.setFilterValue((old: [number, number]) => [
e.target.value,
old?.[1],
]);
setDisplayState(1);
}}
placeholder="Min"
className="w-full grow border border-neutral-700 bg-neutral-600 p-3 text-lg font-normal text-neutral-200 outline-none placeholder:text-neutral-800 "
/>
<input
type="number"
inputMode="numeric"
value={(columnFilterValue as [number, number])?.[1] ?? ""}
onChange={(e) => {
column.setFilterValue((old: [number, number]) => [
old?.[0],
e.target.value,
]);
setDisplayState(1);
}}
placeholder="Max"
className="w-full grow border border-neutral-700 bg-neutral-600 p-3 text-lg font-normal text-neutral-200 outline-none placeholder:text-neutral-800 "
/>
</div>
);
};

0 comments on commit 2053459

Please sign in to comment.