Skip to content

Commit

Permalink
fix a bug in progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
simbafs committed Mar 2, 2024
1 parent 941474c commit eb5fc7e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/app/(game)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ const menus = [
},
];

function sum(a: number, b: ActivityType) {
return a + b.piece;
}

export default function Home() {
const [active, setActive] = useState(0);
const [filter, setFilter] = useState<Filter>("all");
Expand All @@ -107,10 +111,12 @@ export default function Home() {
...item,
}));

const totalN = data.filter((item) => item.isFinished || !item.hide).length;
const finishedN = data.filter((item, index) =>
isActivityFinished(item, index),
).length;
const totalN = data
.filter((item) => item.isFinished || !item.hide)
.reduce(sum, 0);
const finishedN = data
.filter((item, index) => isActivityFinished(item, index))
.reduce(sum, 0);

return (
<div>
Expand Down

0 comments on commit eb5fc7e

Please sign in to comment.