You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
504 B
25 lines
504 B
import { reduce } from 'lodash';
|
|
import { SelectedState } from 'Helpers/Hooks/useSelectState';
|
|
|
|
// TODO: This needs to handle string IDs as well
|
|
function getSelectedIds(
|
|
selectedState: SelectedState,
|
|
{ parseIds = true } = {}
|
|
): number[] {
|
|
return reduce(
|
|
selectedState,
|
|
(result: any[], value, id) => {
|
|
if (value) {
|
|
const parsedId = parseIds ? parseInt(id) : id;
|
|
|
|
result.push(parsedId);
|
|
}
|
|
|
|
return result;
|
|
},
|
|
[]
|
|
);
|
|
}
|
|
|
|
export default getSelectedIds;
|