parent
c8b2c35e78
commit
82e513c890
5 changed files with 66 additions and 58 deletions
@ -1,6 +1,6 @@ |
|||||||
import React from "react"; |
import React from "react"; |
||||||
|
|
||||||
export const ColumnFilter = ({ column }) => { |
export const ColumnSearch = ({ column }) => { |
||||||
const { filterValue, setFilter } = column; |
const { filterValue, setFilter } = column; |
||||||
|
|
||||||
return ( |
return ( |
@ -0,0 +1,46 @@ |
|||||||
|
import React from "react"; |
||||||
|
|
||||||
|
export const SelectColumnFilter = ({ |
||||||
|
column: { filterValue, setFilter, preFilteredRows, id, render }, |
||||||
|
}) => { |
||||||
|
const options = React.useMemo(() => { |
||||||
|
const options = new Set(); |
||||||
|
preFilteredRows.forEach((row) => { |
||||||
|
options.add(row.values[id]); |
||||||
|
}); |
||||||
|
return [...options.values()]; |
||||||
|
}, [id, preFilteredRows]); |
||||||
|
|
||||||
|
return ( |
||||||
|
<select |
||||||
|
className="rounded-md border-gray-300 shadow-sm text-xs focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" |
||||||
|
name={id} |
||||||
|
id={id} |
||||||
|
value={filterValue} |
||||||
|
onChange={(e) => { |
||||||
|
setFilter(e.target.value || undefined); |
||||||
|
}} |
||||||
|
> |
||||||
|
<option className="text-xs" value=""> |
||||||
|
همه |
||||||
|
</option> |
||||||
|
{options.map((option, i) => ( |
||||||
|
<option key={i} value={option} className="text-xs"> |
||||||
|
{(() => { |
||||||
|
if (option === 1) { |
||||||
|
return "وضعیت عادی"; |
||||||
|
} else if (option === 2) { |
||||||
|
return "اعلان سطح هشدار"; |
||||||
|
} else if (option === 3) { |
||||||
|
return "بررسی و پیگیری"; |
||||||
|
} else if (option === 4) { |
||||||
|
return "وضعیت بحرانی"; |
||||||
|
} else { |
||||||
|
return " وضعیت پایدار"; |
||||||
|
} |
||||||
|
})()}{" "} |
||||||
|
</option> |
||||||
|
))} |
||||||
|
</select> |
||||||
|
); |
||||||
|
}; |
Loading…
Reference in new issue