diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java index aa86e27..c9f968f 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java @@ -3,6 +3,7 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Label; +import javafx.scene.control.TextField; import ntnu.systemutvikling.team6.models.Charity; /** @@ -10,6 +11,7 @@ * to donate to it. It also has a button to return to the front page. */ public class CharityPageController { + @FXML private TextField charitySearchField; @FXML private Label CharityDescription; @@ -59,4 +61,15 @@ public void switchToDonationPage(ActionEvent event) { System.out.println("Click"); LoaderScene.LoadScene("donationPage", event, charity, null); } + + @FXML + public void handleSearch(ActionEvent event) { + String query = charitySearchField.getText().trim(); + + if (query.isEmpty()) { + return; + } + + LoaderScene.LoadScene("availableOrganization", event, null, query); + } } diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java index 5c00988..4187cec 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java @@ -21,6 +21,8 @@ public class DonationPageController { @FXML private Label CharityName; + @FXML private TextField donationSearchField; + /** * Initialize method for the donation page. Sets the charity name label to the name of the charity * that is being donated to. The charity is set from the original page it was called from when the @@ -130,4 +132,15 @@ private void showAlert(Alert.AlertType type, String title, String message) { alert.setContentText(message); alert.showAndWait(); } + + @FXML + public void handleSearch(ActionEvent event) { + String query = donationSearchField.getText().trim(); + + if (query.isEmpty()) { + return; + } + + LoaderScene.LoadScene("availableOrganization", event, null, query); + } } diff --git a/helpmehelpapplication/src/main/resources/fxml/charityPage.fxml b/helpmehelpapplication/src/main/resources/fxml/charityPage.fxml index 041b51b..ce647b6 100644 --- a/helpmehelpapplication/src/main/resources/fxml/charityPage.fxml +++ b/helpmehelpapplication/src/main/resources/fxml/charityPage.fxml @@ -91,7 +91,7 @@ - + diff --git a/helpmehelpapplication/src/main/resources/fxml/donationPage.fxml b/helpmehelpapplication/src/main/resources/fxml/donationPage.fxml index 845ec84..8daa36e 100644 --- a/helpmehelpapplication/src/main/resources/fxml/donationPage.fxml +++ b/helpmehelpapplication/src/main/resources/fxml/donationPage.fxml @@ -57,7 +57,7 @@ - +