Skip to content

Commit

Permalink
Show total number of credits
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Sep 11, 2021
1 parent eebca71 commit e4c3e2e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/basket/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ const BodyWithData = observer(({onClose, isForCapture}: BasketTableProps) => {
</Tr>
))
}

<Tr fontWeight="bold">
<Td>Total:</Td>
{/* eslint-disable-next-line react/no-array-index-key */}
{Array.from({length: 5}).map((_, i) => (<Td key={i}/>))}
<Td isNumeric>{basketState.totalCredits}</Td>
<Td/>
<Td/>
<Td/>
</Tr>
</>
);
});
Expand Down
10 changes: 10 additions & 0 deletions src/lib/basket-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ export class BasketState {
}, []);
}

get totalCredits() {
let credits = 0;

for (const section of this.sections) {
credits += (section.minCredits + section.maxCredits) / 2;
}

return credits;
}

get isSectionScheduleCompatibleMap() {
const map = new Map<ISectionFromAPI['id'], boolean>();

Expand Down

0 comments on commit e4c3e2e

Please sign in to comment.