Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 5efe558

Browse files
author
Dmitry Yadrikhinsky
committed
Key
1 parent d56ab75 commit 5efe558

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/helpers/IterateLastCurrent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type Callback<T, R> = (last: T | undefined, cur: T) => R;
1+
type Callback<T, R> = (last: T | undefined, cur: T, index: number) => R;
22

33
export function mapLastCurrent<T, R = any>(
44
items: T[],
@@ -7,9 +7,9 @@ export function mapLastCurrent<T, R = any>(
77
const result: R[] = [];
88
for (let i = 0; i < items.length; i++) {
99
if (i === 0) {
10-
result.push(callback(undefined, items[i]));
10+
result.push(callback(undefined, items[i], i));
1111
} else {
12-
result.push(callback(items[i - 1], items[i]));
12+
result.push(callback(items[i - 1], items[i], i));
1313
}
1414
}
1515
return result;

src/screens/projects/components/HoursByTask/HoursByTask.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ export default function HoursByTask({ task }: HoursByTaskProps) {
2727
<BellFilled style={{ color: 'white' }} />
2828
</IconTile>
2929
{task?.time.length === 0 && <div>No billed hours</div>}
30-
{mapLastCurrent(task?.time || [], (last, range) => {
30+
{mapLastCurrent(task?.time || [], (last, range, index) => {
3131
if (!last || !isSameDay(last[0], range[0])) {
3232
return (
33-
<div>
33+
<div key={index}>
3434
<div className="date">{dateFormat(range[0])}</div>
3535
<HoursItem range={range} />
3636
</div>
3737
);
3838
}
39-
return <HoursItem range={range} />;
39+
return <HoursItem key={index} range={range} />;
4040
})}
4141
</Space>
4242
</Card>

0 commit comments

Comments
 (0)