Skip to content

Commit

Permalink
Feat: FrontPage donate button works
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 21, 2026
1 parent e64128b commit 020742f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class FrontpageController extends BaseController{
protected void authTokenisSet(){
navbarController.setAuthToken(authToken);
footerController.setAuthToken(authToken);
loadPage();
}

/**
Expand All @@ -66,6 +67,10 @@ protected void authTokenisSet(){
*/
@FXML
public void initialize() {

}

private void loadPage(){
try {
DatabaseConnection conn = new DatabaseConnection();
CharitySelect cdb = new CharitySelect(conn);
Expand All @@ -87,15 +92,15 @@ public void initialize() {

Total_Orgnisasjon.setText(Integer.toString(charitiesSize));
Total_Donations.setText(
Double.toString(
donations.getAllDonations().stream().mapToDouble(Donation::getAmount).sum()));
Double.toString(
donations.getAllDonations().stream().mapToDouble(Donation::getAmount).sum()));
PreApproved_Percentage.setText(
String.format(
"%.2f",
charities.getAllCharities().stream().filter(Charity::getPreApproved).count()
* 100.0
/ charitiesSize)
+ "%");
String.format(
"%.2f",
charities.getAllCharities().stream().filter(Charity::getPreApproved).count()
* 100.0
/ charitiesSize)
+ "%");
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* looped upon in FronpageController. It is used to display the name and description of a charity,
* and to switch to the charity page or donation page when the user clicks on the card.
*/
public class OrganizationCardController extends BaseController{
public class OrganizationCardController extends BaseController {

@FXML private Label organizationName;

Expand All @@ -36,6 +36,7 @@ public void switchToCharityPage(ActionEvent event) {
}

public void switchToDonationPage(ActionEvent event) {
System.out.println(authToken.getCurrentUser().getId().toString());
LoaderScene.LoadScene("DonationPage", event, charity, null, authToken);
}

Expand Down

0 comments on commit 020742f

Please sign in to comment.