Fix bug with importing single item from groups

This commit is contained in:
Mitchell McCaffrey 2021-06-15 08:45:08 +10:00
parent 63a809592e
commit 6b927b4456

View File

@ -249,15 +249,17 @@ function SelectDataModal({
); );
} }
} else { } else {
if (group.items.every((item) => item.id in maps)) { if (group.items.some((item) => item.id in maps)) {
return renderGroupContainer( return renderGroupContainer(
group, group,
group.items.some((item) => maps[item.id].checked), group.items.some((item) => maps[item.id]?.checked),
renderMapGroup, renderMapGroup,
(e, group) => (e, group) =>
handleMapsChanged( handleMapsChanged(
e, e,
group.items.map((group) => maps[group.id]) group.items
.filter((group) => group.id in maps)
.map((group) => maps[group.id])
) )
); );
} }
@ -290,10 +292,10 @@ function SelectDataModal({
); );
} }
} else { } else {
if (group.items.every((item) => item.id in tokens)) { if (group.items.some((item) => item.id in tokens)) {
const checked = const checked =
group.items.some( group.items.some(
(item) => !(item.id in tokenUsedCount) && tokens[item.id].checked (item) => !(item.id in tokenUsedCount) && tokens[item.id]?.checked
) || group.items.every((item) => item.id in tokenUsedCount); ) || group.items.every((item) => item.id in tokenUsedCount);
return renderGroupContainer( return renderGroupContainer(
group, group,
@ -302,7 +304,9 @@ function SelectDataModal({
(e, group) => (e, group) =>
handleTokensChanged( handleTokensChanged(
e, e,
group.items.map((group) => tokens[group.id]) group.items
.filter((group) => group.id in tokens)
.map((group) => tokens[group.id])
) )
); );
} }