Skip to content

Feat/donation page #67

Merged
merged 3 commits into from
Apr 16, 2026
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/edu/group5/app/control/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import edu.group5.app.model.user.User;
import edu.group5.app.model.user.UserService;
import edu.group5.app.view.loginpage.LoginPageView;
import edu.group5.app.view.loginpage.SignInPageView;
import edu.group5.app.view.loginpage.SignUpPageView;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class LoginController {
Expand All @@ -18,7 +18,7 @@ public LoginController(AppState appState, NavigationController nav, UserService
this.userService = userService;
}

public void handleSignIn(SignInPageView view, String firstName, String lastName, String email, char[] passwordChars) {
public void handleSignUp(SignUpPageView view, String firstName, String lastName, String email, char[] passwordChars) {
if (firstName == null || firstName.trim().isEmpty() ||
lastName == null || lastName.trim().isEmpty() ||
email == null || email.trim().isEmpty() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import edu.group5.app.view.homepage.HomePageView;
import edu.group5.app.view.loginpage.LoginHeader;
import edu.group5.app.view.loginpage.LoginPageView;
import edu.group5.app.view.loginpage.SignInPageView;
import edu.group5.app.view.loginpage.SignUpPageView;
import edu.group5.app.view.organizationpage.OrganizationPageView;
import edu.group5.app.view.userpage.UserPageView;
import javafx.scene.layout.BorderPane;
Expand Down Expand Up @@ -49,9 +49,9 @@ public void showLoginPage() {
root.setCenter(new LoginPageView(appState, this, loginController));
}

public void showSignInPage() {
public void showSignUpPage() {
root.setTop(loginHeader);
root.setCenter(new SignInPageView(appState, this, loginController));
root.setCenter(new SignUpPageView(appState, this, loginController));
}

public void showPaymentCompletePage() {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/edu/group5/app/view/Header.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;

/**
* A main header for the app.
*
* <p>The header consists of a logo button to homepage,
* a navigation bar with buttons to home page, causes page,
* and about us page. The header also has a profile button
* in the upper right corner.</p>
*/
public class Header extends BorderPane {
private final NavigationController controller;

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/edu/group5/app/view/causespage/CausesPageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
import java.util.Map;
import java.util.stream.Collectors;

/**
* A view for the causes page.
*
* <p>This page allows users to browse and search
* for organizations they may want to donate to.
* Organizations are displayed in a grid layout,
* with four organizations per row. Each organization
* is represented as a clickable card containing its name and logo,
* which navigates to the organization's detail page. </p>
*
* <p>The page includes a search field that filters the
* displayed organizations based on user input.</p>
*
* <p>Logos are fetched asynchronously, and a loading indicator
* is shown while the data is being retrieved. If a logo cannot be loaded,
* a fallback "no image" is displayed.</p>
*/
public class CausesPageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/edu/group5/app/view/causespage/OrganizationCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

/**
* OrganizationCard represent a single organization card
* in the causes page.
*
* <p>The card displays the organization's logo, name, and verification
* checkmark. If no logo is available, a fallback text ("No image") is shown.</p>
*
* <p>The card is clickable. When pressed it navigates
* to the organization's detail page.</p>
*/
public class OrganizationCard extends VBox {
private final AppState appState;
private final Organization organization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
import java.math.BigDecimal;
import java.util.*;

/**
* A view for the Donation Page.
* In the donation page a user can donate a chosen amount
* to the organization they have chosen to donate to.
*
* <p>The donation page consists of payment amount buttons,
* payment method buttons, donation button, and a back to organization page button. </p>
*/
public class DonationPageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

import java.util.Objects;

/**
* A view for the payment complete page.
* When a user have donated an amount, this page opens up.
*
* <P>The page consist of an image that says "Tank You For The Donation",
* and a "back to home" button at the bottom center.</P>
*/
public class PaymentCompletePageView extends BorderPane {
private final NavigationController nav;

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/edu/group5/app/view/homepage/HomePageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

/**
* A view for the homepage.
* In the home page a user can navigate to pages in the heading,
* and they can press the "donate to a cause" button or the "about us" button.
*
* <p>The homepage includes a heading, a "donate to a cause" button,
* and an about us button. The page also has a charity image at the bottom.</p>
*/
public class HomePageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/edu/group5/app/view/loginpage/LoginHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;

/**
* A header for the login page and for the SignIn page.
* <p>The header includes a logo of the Help Me Help app.</p>
*/
public class LoginHeader extends BorderPane {

public LoginHeader() {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/edu/group5/app/view/loginpage/LoginPageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@

import java.util.Objects;

/**
* A view for the login page.
* A user can login with email and password.
* If the user does not have an account they can
* press the register button to the SignUp page.
* <p>This page involves a {@code LoginHeader}, an image at the right,
* a login box, an email box, a login button, and a register button.</p>
*/
public class LoginPageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
Expand Down Expand Up @@ -106,9 +114,9 @@ private Button getLoginBtn() {
}

public Button getRegisterBtn() {
Button registerBtn = new Button("Don't have an account? Sign In");
Button registerBtn = new Button("Don't have an account? Sign Up");
registerBtn.setMaxWidth(300);
registerBtn.setOnMouseClicked(e -> nav.showSignInPage());
registerBtn.setOnMouseClicked(e -> nav.showSignUpPage());
registerBtn.setId("register-btn");
return registerBtn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@

import java.util.Objects;


public class SignInPageView extends BorderPane {
/**
* A view for the SignUp page.
* In this page a user can create an account by writing in first and last name,
* and by adding email and password. If the user already have an account,
* they can press the back to login button to login.
*
* <P>This view contains a first name field, a surname field, a email field,
* a password field, a sign up button, and an back to login button.</P>
*/
public class SignUpPageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
private final LoginController loginController;
Expand All @@ -24,7 +32,7 @@ public class SignInPageView extends BorderPane {
private PasswordField passwordField;
private Label errorLabel;

public SignInPageView(AppState appState, NavigationController nav, LoginController loginController) {
public SignUpPageView(AppState appState, NavigationController nav, LoginController loginController) {
this.appState = appState;
this.nav = nav;
this.loginController = loginController;
Expand All @@ -36,7 +44,7 @@ public SignInPageView(AppState appState, NavigationController nav, LoginControll
content.getChildren().addAll(getOuterSection(), getImageSection());

String css = Objects.requireNonNull(
getClass().getResource("/loginpage/signin.css")).toExternalForm();
getClass().getResource("/loginpage/signup.css")).toExternalForm();
content.getStylesheets().add(css);

setCenter(content);
Expand Down Expand Up @@ -68,16 +76,16 @@ private VBox getOuterSection() {
VBox outerSection = new VBox(12);
outerSection.setAlignment(Pos.CENTER);
HBox.setHgrow(outerSection, Priority.ALWAYS);
outerSection.getChildren().addAll(getSignInBox(), getBackToLoginBtn());
outerSection.getChildren().addAll(getSignUpBox(), getBackToLoginBtn());
return outerSection;
}

private VBox getSignInBox() {
VBox signInSection = new VBox(12);
signInSection.setAlignment(Pos.CENTER);
signInSection.setId("login-box");
signInSection.getChildren().addAll(getErrorLabel(), getNameRow(), getEmailBox(), getPasswordBox(), getSignInBtn());
return signInSection;
private VBox getSignUpBox() {
VBox signUpSection = new VBox(12);
signUpSection.setAlignment(Pos.CENTER);
signUpSection.setId("login-box");
signUpSection.getChildren().addAll(getErrorLabel(), getNameRow(), getEmailBox(), getPasswordBox(), getSignUpBtn());
return signUpSection;
}

private Label getErrorLabel() {
Expand Down Expand Up @@ -126,18 +134,18 @@ private VBox getPasswordBox() {
return passwordBox;
}

private Button getSignInBtn() {
Button signInBtn = new Button("Sign In");
signInBtn.setMaxWidth(300);
signInBtn.setId("login-btn");
signInBtn.setOnMouseClicked(e -> loginController.handleSignIn(
private Button getSignUpBtn() {
Button signUpBtn = new Button("Sign Up");
signUpBtn.setMaxWidth(300);
signUpBtn.setId("login-btn");
signUpBtn.setOnMouseClicked(e -> loginController.handleSignUp(
this,
getFirstName(),
getLastName(),
getEmail(),
getPassword()
));
return signInBtn;
return signUpBtn;
}

public Button getBackToLoginBtn() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@

import java.util.Objects;

/**
* A view for displaying information about a selected organization.
*
* <p>The page shows the organization's logo, name, and description.
* If no logo is available, a fallback "No image" is displayed.</p>
*
* <p>The page also includes a donate button that navigates to the
* donation page, and a back button to return to the causes page.</p>
*/
public class OrganizationPageView extends BorderPane {
private final AppState appState;
private final NavigationController nav;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#image-section {
-fx-background-image: url("/loginpage/signin-image.png");
-fx-background-image: url("/loginpage/signup-image.png");
-fx-background-size: auto;
-fx-background-position: right center;
-fx-background-repeat: no-repeat;
Expand Down