Skip to content

Commit

Permalink
Merge branch 'release/v2.0.0' into update/organization/description
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrjm authored Apr 14, 2026
2 parents b1a1fb8 + a26914e commit 40b3ba9
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/main/java/edu/group5/app/App.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package edu.group5.app;

import edu.group5.app.control.NavigationController;
import edu.group5.app.control.wrapper.DbWrapper;
import edu.group5.app.control.wrapper.OrgApiWrapper;
import edu.group5.app.model.AppState;
import edu.group5.app.model.donation.DonationRepository;
import edu.group5.app.model.donation.DonationService;
Expand All @@ -11,6 +9,8 @@
import edu.group5.app.model.organization.OrganizationService;
import edu.group5.app.model.user.UserRepository;
import edu.group5.app.model.user.UserService;
import edu.group5.app.model.wrapper.DbWrapper;
import edu.group5.app.model.wrapper.OrgApiWrapper;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/edu/group5/app/control/DonationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void requestDonationConfirmation() {
User currentUser = appState.getCurrentUser();
Organization currentOrg = appState.getCurrentOrganization();
BigDecimal amount = appState.getCurrentDonationAmount();
String paymentMethod = appState.getCurrentPaymentMethod();

// Validate before showing dialog
if (currentUser == null) {
Expand Down Expand Up @@ -92,17 +93,21 @@ private void handleDonate() {
System.err.println("Error: Only customers can donate");
return;
}
if (paymentMethod == null) {
System.out.println("Error: Invalid payment method");
return;
}

// Create donation via service
boolean success = service.donate(
customer,
currentOrg.orgNumber(),
amount,
"Online"
paymentMethod
);

if (success) {
System.out.println("Donation created: " + amount + " kr to " + currentOrg.name());
System.out.println("Donation created: " + amount + " kr to " + currentOrg.name() + ", with payment method: " + paymentMethod);
} else {
System.err.println("Failed to create donation");
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/edu/group5/app/model/AppState.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class AppState {
private User currentUser;
private BigDecimal currentDonationAmount;
private Organization currentOrganization;
private String currentDonation;

public User getCurrentUser() {
return this.currentUser;
Expand All @@ -33,4 +34,12 @@ public BigDecimal getCurrentDonationAmount() {
public void setCurrentDonationAmount(BigDecimal amount) {
this.currentDonationAmount = amount;
}

public String getCurrentPaymentMethod() {
return this.currentDonation;
}

public void setCurrentPaymentMethod(String paymentMethod){
this.currentDonation = paymentMethod;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.group5.app.control.wrapper;
package edu.group5.app.model.wrapper;

import java.math.BigDecimal;
import java.sql.Connection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.group5.app.control.wrapper;
package edu.group5.app.model.wrapper;

import java.io.IOException;
import java.net.URI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.group5.app.control.wrapper;
package edu.group5.app.model.wrapper;

/**
* An abstract class for all Wrappers of datasets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import edu.group5.app.control.NavigationController;
import edu.group5.app.model.AppState;
import edu.group5.app.model.organization.Organization;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
Expand All @@ -17,6 +18,8 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

import java.util.Objects;

public class OrganizationPageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
Expand All @@ -27,24 +30,34 @@ public OrganizationPageView(AppState appState, NavigationController nav, Donatio
this.nav = nav;
this.donationController = donationController;

getStylesheets().add(getClass().getResource("/organizationpage/organizationpage.css").toExternalForm());
setCenter(createBody());
getStylesheets().add(Objects.requireNonNull(getClass().getResource("/organizationpage/organizationpage.css")).toExternalForm());

VBox content = new VBox();
content.getChildren().addAll(createBackButton(), createBody());
setCenter(content);
}

private ScrollPane createBody() {
ScrollPane body = new ScrollPane();
body.setFitToWidth(true);
body.setFitToHeight(true)
;
body.setFitToHeight(true);

VBox vBox = new VBox();
vBox.setId("main-container");

vBox.getChildren().addAll(
createOrgSection()
);
vBox.getChildren().addAll(createOrgSection());
body.setContent(vBox);
return body;
}
private HBox createBackButton() {
Button backBtn = new Button("←");
backBtn.getStyleClass().add("back-button");
backBtn.setOnAction(e -> nav.showCausesPage());

HBox container = new HBox(backBtn);
container.setPadding(new Insets(10, 0, 0, 10));
return container;
}

private HBox createOrgSection() {
HBox orgSection = new HBox();
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/edu/group5/app/view/userpage/UserPageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javafx.scene.text.Text;
import java.text.SimpleDateFormat;

import java.math.RoundingMode;
import java.util.*;


Expand Down Expand Up @@ -78,7 +79,6 @@ private HBox createProfileSection() {
profile.setAlignment(Pos.CENTER_LEFT);
return profile;
}

private VBox createCausesSection() {
Text title = new Text("YOUR SUPPORTED CAUSES");
title.getStyleClass().add("section-title");
Expand All @@ -101,12 +101,15 @@ private VBox createCausesSection() {
for (int orgId : uniqueOrgs) {
Organization org = organizationController.getOrgById(orgId);
if (org != null) {
causesFlow.getChildren().add(createCauseChip(org)); // SRP: delegate to helper
causesFlow.getChildren().add(createCauseChip(org));
}
}
}

ScrollPane scrollPane = new ScrollPane(causesBox);
scrollPane.setFitToWidth(true);
scrollPane.setPrefHeight(150);
scrollPane.setContent(causesFlow);

return new VBox(10, title, scrollPane);
}

Expand Down Expand Up @@ -175,11 +178,15 @@ private VBox createDonationsSection() {
} else {
for (Donation donation : userDonations.values()) {
donationsBox.getChildren().add(createDonationCard(donation));

}
}

ScrollPane scrollPane = new ScrollPane(donationsBox);
scrollPane.setFitToWidth(true);
scrollPane.setPrefHeight(200);
scrollPane.setContent(donationsBox);
return new VBox(10, title, searchBox, scrollPane);

}


Expand Down
53 changes: 53 additions & 0 deletions src/main/resources/donationpage/donation.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,26 @@
-fx-border-color: #111;
}

.donation-button-selected:hover {
-fx-background-color: #222;
-fx-border-color: #222;
}

.donation-button-selected Text,
.donation-button-selected .donation-input {
-fx-fill: white;
-fx-border-color: transparent transparent white transparent;
-fx-text-fill: white;
-fx-prompt-text-fill: #ccc;
}

.donation-title {
-fx-font-size: 18px;
-fx-font-weight: bold;
-fx-fill: #111;
}


.donation-amount {
-fx-font-size: 18px;
-fx-fill: #111;
Expand Down Expand Up @@ -90,7 +104,46 @@
-fx-text-fill: white;
}


.donation-button-selected .donation-input:focused {
-fx-text-fill: white;
-fx-border-color: transparent transparent white transparent;

.payment-method-button {
-fx-background-color: #111;
-fx-text-fill: white;
-fx-font-size: 16px;
-fx-font-weight: bold;
-fx-pref-width: 180px;
-fx-pref-height: 45px;
-fx-background-radius: 6;
-fx-border-radius: 6;
-fx-cursor: hand;
}
.payment-method-button:hover {
-fx-background-color: #222;
}
.payment-method-selected,
.payment-method-selected:hover {
-fx-background-color: #e03030;
}
.donation-button-selected .donation-title,
.donation-button-selected .donation-amount {
-fx-fill: white;
}
.back-button {
-fx-background-color: white;
-fx-text-fill: black;
-fx-font-weight: bold;
-fx-font-size: 20px;
-fx-background-radius: 50;
-fx-padding: 4px 10px;
-fx-cursor: hand;
-fx-border-radius: 50;
-fx-border-color: black;
-fx-border-width: 2px;
}
.back-button:hover {
-fx-background-color: #333;
-fx-border-color:#333;
}
16 changes: 16 additions & 0 deletions src/main/resources/organizationpage/organizationpage.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,20 @@

#description-scroll .scroll-bar:vertical .thumb:hover {
-fx-background-color: #999999;
}
.back-button {
-fx-background-color: white;
-fx-text-fill: black;
-fx-font-weight: bold;
-fx-font-size: 20px;
-fx-background-radius: 50;
-fx-padding: 4px 10px;
-fx-cursor: hand;
-fx-border-radius: 50;
-fx-border-color: black;
-fx-border-width: 2px;
}
.back-button:hover {
-fx-background-color: #333;
-fx-border-color:#333;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.group5.app.control.wrapper;
package edu.group5.app.model.wrapper;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -16,6 +16,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import edu.group5.app.model.wrapper.DbWrapper;

public class DbWrapperDonationsTest {
private Object[] johnDonation;
private List<Object[]> users;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.group5.app.control.wrapper;
package edu.group5.app.model.wrapper;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -20,6 +20,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

import edu.group5.app.model.wrapper.DbWrapper;
import javafx.util.converter.BigDecimalStringConverter;

public class DbWrapperUserTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.group5.app.control.wrapper;
package edu.group5.app.model.wrapper;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -9,6 +9,8 @@
import java.lang.IllegalArgumentException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import edu.group5.app.model.wrapper.OrgApiWrapper;
import tools.jackson.core.exc.StreamReadException;

/**
Expand Down

0 comments on commit 40b3ba9

Please sign in to comment.