Skip to content

Commit

Permalink
Add total reps to the finish day screen
Browse files Browse the repository at this point in the history
  • Loading branch information
astashov committed Mar 16, 2022
1 parent c623327 commit 1bff424
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/screenFinishDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function ScreenFinishDay(props: IProps): JSX.Element {
const prs = History.findAllPersonalRecords(record, props.history);
const [isShareShown, setIsShareShown] = useState<boolean>(false);
const totalWeight = History.totalRecordWeight(record, props.settings.units);
const totalReps = History.totalRecordReps(record);

return (
<section className="h-full">
Expand All @@ -42,6 +43,9 @@ export function ScreenFinishDay(props: IProps): JSX.Element {
<div>
Total weight lifted: <strong>{Weight.display(totalWeight)}</strong>
</div>
<div>
Total reps: <strong>{totalReps}</strong>
</div>
</section>
{prs.size > 0 ? (
<section className="px-4 py-8">
Expand Down
4 changes: 4 additions & 0 deletions src/models/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export namespace History {
return record.entries.reduce((memo, e) => Weight.add(memo, totalEntryWeight(e, unit)), Weight.build(0, unit));
}

export function totalRecordReps(record: IHistoryRecord): number {
return record.entries.reduce((memo, e) => memo + totalEntryReps(e), 0);
}

export function totalEntryWeight(entry: IHistoryEntry, unit: IUnit): IWeight {
return entry.sets
.filter((s) => (s.completedReps || 0) > 0)
Expand Down

0 comments on commit 1bff424

Please sign in to comment.