fix potential issue with grouping
This commit is contained in:
@@ -66,9 +66,9 @@ const filteredItems = props.items.filter(r => r.type.name.toLowerCase().includes
|
|||||||
}
|
}
|
||||||
|
|
||||||
const list: Result[] = [];
|
const list: Result[] = [];
|
||||||
const groups = Map.groupBy(filteredItems, r => r.type);
|
const groups = Map.groupBy(filteredItems, r => r.type.id);
|
||||||
|
|
||||||
groups.forEach((group, type) => {
|
groups.forEach((group, typeID) => {
|
||||||
const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined);
|
const oldest = group.reduce((acc: AcquiredType | undefined, r: AcquiredType) => (acc && acc.date < r.date) ? acc : r, undefined);
|
||||||
|
|
||||||
if (!oldest) {
|
if (!oldest) {
|
||||||
@@ -82,8 +82,8 @@ const filteredItems = props.items.filter(r => r.type.name.toLowerCase().includes
|
|||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
type: oldest,
|
type: oldest,
|
||||||
typeID: type.id,
|
typeID,
|
||||||
name: type.name,
|
name: oldest.type.name,
|
||||||
buy: oldest.buy,
|
buy: oldest.buy,
|
||||||
sell: oldest.sell,
|
sell: oldest.sell,
|
||||||
price: price,
|
price: price,
|
||||||
|
|||||||
Reference in New Issue
Block a user