diff --git a/src/main/java/edu/group5/app/control/DonationController.java b/src/main/java/edu/group5/app/control/DonationController.java index 9118c7e..5c700b0 100644 --- a/src/main/java/edu/group5/app/control/DonationController.java +++ b/src/main/java/edu/group5/app/control/DonationController.java @@ -12,6 +12,10 @@ import java.util.Map; import java.util.Set; +/** + * A controller that handles the logic pertaining to + * making donations and getting data via {@link DonationService}. + */ public class DonationController { private final AppState appState; private final NavigationController nav; @@ -27,17 +31,21 @@ public Map getUserDonations(int userId) { return service.getDonationRepository().filterByUser(userId); } - public Set getUniqueOrgs() { + public Set getUniqueOrganizations() { Map userDonations = getUserDonations(appState.getCurrentUser().getUserId()); - Set uniqueOrgs = new HashSet<>(); + Set uniqueOrganizations = new HashSet<>(); for (Donation donation : userDonations.values()) { - uniqueOrgs.add(donation.organizationId()); + uniqueOrganizations.add(donation.organizationId()); } - return uniqueOrgs; + return uniqueOrganizations; } + /** + * Handles the creation of a new donation via {@link DonationService} + * and {@link AppState}. + */ public void handleDonate() { // Get session data from MainController User currentUser = appState.getCurrentUser(); diff --git a/src/main/java/edu/group5/app/control/LoginController.java b/src/main/java/edu/group5/app/control/LoginController.java index cdd5b5f..d9cb35e 100644 --- a/src/main/java/edu/group5/app/control/LoginController.java +++ b/src/main/java/edu/group5/app/control/LoginController.java @@ -7,6 +7,10 @@ import edu.group5.app.view.loginpage.SignInPageView; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +/** + * A controller that handles the logic pertaining to {@link User} + * sign in, login and logout via {@link UserService}. + */ public class LoginController { private final AppState appState; private final NavigationController nav; @@ -18,6 +22,15 @@ public LoginController(AppState appState, NavigationController nav, UserService this.userService = userService; } + /** + * Handles the sign in of a new {@link User}. + * + * @param view view connected to the sign in. + * @param firstName first name of the {@link User}. + * @param lastName last name of the {@link User}. + * @param email email of the {@link User}. + * @param passwordChars password of the {@link User}. + */ public void handleSignIn(SignInPageView view, String firstName, String lastName, String email, char[] passwordChars) { if (firstName == null || firstName.trim().isEmpty() || lastName == null || lastName.trim().isEmpty() || @@ -44,6 +57,13 @@ public void handleSignIn(SignInPageView view, String firstName, String lastName, } } + /** + * Handles the login of a {@link User}. + * + * @param view view connected to the login. + * @param email email of the {@link User}. + * @param passwordChars password of the {@link User}. + */ public void handleLogin(LoginPageView view, String email, char[] passwordChars) { if (email == null || email.trim().isEmpty() || passwordChars == null || passwordChars.length == 0) { view.showError("Email and password are required"); @@ -60,6 +80,9 @@ public void handleLogin(LoginPageView view, String email, char[] passwordChars) } } + /** + * Handles the logout of a {@link User}. + */ public void handleLogout() { appState.setCurrentUser(null); appState.setCurrentOrganization(null); diff --git a/src/main/java/edu/group5/app/control/NavigationController.java b/src/main/java/edu/group5/app/control/NavigationController.java index ddab7e2..db16c95 100644 --- a/src/main/java/edu/group5/app/control/NavigationController.java +++ b/src/main/java/edu/group5/app/control/NavigationController.java @@ -16,6 +16,9 @@ import edu.group5.app.view.userpage.UserPageView; import javafx.scene.layout.BorderPane; +/** + * A controller that handles the switching of views in the root node. + */ public class NavigationController { private final BorderPane root; private final Header header; diff --git a/src/main/java/edu/group5/app/control/OrganizationController.java b/src/main/java/edu/group5/app/control/OrganizationController.java index 499b7c9..62a787c 100644 --- a/src/main/java/edu/group5/app/control/OrganizationController.java +++ b/src/main/java/edu/group5/app/control/OrganizationController.java @@ -7,6 +7,10 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; +/** + * A controller that handles the data being passed to + * the view via the {@link OrganizationService}. + */ public class OrganizationController { private final AppState appState; private final NavigationController nav; diff --git a/src/main/java/edu/group5/app/view/userpage/UserPageView.java b/src/main/java/edu/group5/app/view/userpage/UserPageView.java index b410761..d416916 100644 --- a/src/main/java/edu/group5/app/view/userpage/UserPageView.java +++ b/src/main/java/edu/group5/app/view/userpage/UserPageView.java @@ -85,7 +85,7 @@ private VBox createCausesSection() { User currentUser = appState.getCurrentUser(); - Set uniqueOrgs = donationController.getUniqueOrgs(); + Set uniqueOrgs = donationController.getUniqueOrganizations(); if (uniqueOrgs.isEmpty()) { Label noCauses = new Label("No causes supported yet");