Skip to content

Commit

Permalink
Merge pull request #22 from Michigan-Tech-Courses/max/mic-89-show-tot…
Browse files Browse the repository at this point in the history
…al-credits-for-basket

Show total number of credits
  • Loading branch information
codetheweb authored Sep 11, 2021
2 parents eebca71 + e4c3e2e commit 2c028fc
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 2c028fc

Please sign in to comment.