-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Getting donations from doners ad charityUser working
- Loading branch information
AdrianBalunan
committed
Apr 21, 2026
1 parent
020742f
commit a5fdf85
Showing
10 changed files
with
265 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...main/java/ntnu/systemutvikling/team6/controller/components/OrgDonationCardController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package ntnu.systemutvikling.team6.controller.components; | ||
|
|
||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Label; | ||
| import ntnu.systemutvikling.team6.models.Donation; | ||
|
|
||
| public class OrgDonationCardController extends BaseController{ | ||
| @FXML private Label donerNameLabel; | ||
| @FXML private Label purchaseIDLabel; | ||
| @FXML private Label dateLabel; | ||
| @FXML private Label totalLabel; | ||
|
|
||
| private Donation donation; | ||
|
|
||
| @Override | ||
| protected void authTokenisSet() { | ||
|
|
||
| } | ||
|
|
||
| public void setDonation(Donation donation) { | ||
| this.donation = donation; | ||
|
|
||
| donerNameLabel.setText(donation.isAnonymous() ? "Anonymous Doner" : donation.getCharity().getName()); | ||
| purchaseIDLabel.setText(donation.getDonationID().toString()); | ||
| dateLabel.setText(donation.getDate().toString()); | ||
| totalLabel.setText(String.valueOf(donation.getAmount())); | ||
| } | ||
| } |
105 changes: 105 additions & 0 deletions
105
...va/ntnu/systemutvikling/team6/controller/profileCharity/profileOrgPaymentsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| package ntnu.systemutvikling.team6.controller.profileCharity; | ||
|
|
||
| import javafx.application.Platform; | ||
| import javafx.event.ActionEvent; | ||
| import javafx.fxml.FXML; | ||
| import javafx.fxml.FXMLLoader; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.control.Alert; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.layout.VBox; | ||
| import javafx.stage.Stage; | ||
| import ntnu.systemutvikling.team6.controller.components.*; | ||
| import ntnu.systemutvikling.team6.database.DatabaseConnection; | ||
| import ntnu.systemutvikling.team6.database.Readers.DonationSelect; | ||
| import ntnu.systemutvikling.team6.models.Charity; | ||
| import ntnu.systemutvikling.team6.models.Donation; | ||
| import ntnu.systemutvikling.team6.models.registry.DonationRegistry; | ||
| import ntnu.systemutvikling.team6.models.user.User; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| public class profileOrgPaymentsController extends BaseController { | ||
| @FXML | ||
| private NavbarController navbarController; | ||
| @FXML private VBox cardsContainer; | ||
| @FXML private Label charityNameLabel; | ||
|
|
||
|
|
||
| @Override | ||
| protected void authTokenisSet() { | ||
| if (!isLoggedin() || authToken.isCharityUser() == null){ | ||
| showAlert(Alert.AlertType.ERROR, "Not logged inn", "You need to be logged inn to donate."); | ||
| Platform.runLater(() -> { | ||
| Stage stage = (Stage) Stage.getWindows().stream() | ||
| .filter(w -> w.isShowing()) | ||
| .findFirst() | ||
| .orElse(null); | ||
| if (stage != null) { | ||
| LoaderScene.LoadScene("loginSite", stage, null, null, authToken); | ||
| } | ||
| }); | ||
| } | ||
| navbarController.setAuthToken(authToken); | ||
| populateFields(); | ||
| } | ||
|
|
||
| public void populateFields() { | ||
| Charity usersCharity = authToken.isCharityUser(); | ||
| charityNameLabel.setText(usersCharity.getName()); | ||
|
|
||
| // DonationHistory | ||
| DatabaseConnection conn = new DatabaseConnection(); | ||
| DonationSelect donationSelect = new DonationSelect(conn); | ||
| DonationRegistry donationRegistry = donationSelect.getDonationForCharity(authToken.isCharityUser().getUUID().toString()); | ||
| displayDonations(donationRegistry); | ||
| } | ||
|
|
||
| private void displayDonations(DonationRegistry donationRegistry) { | ||
| cardsContainer.getChildren().clear(); | ||
| List<Donation> donations = donationRegistry.getAllDonations(); | ||
| if(donations.isEmpty()){ | ||
| Label empty = new Label("You have no Donations"); | ||
| empty.setStyle("-fx-text-fill: #777777; -fx-font-size: 14;"); | ||
| cardsContainer.getChildren().add(empty); | ||
| } | ||
|
|
||
| for (Donation donation : donations) { | ||
| try { | ||
| FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/components/profileOrgDonationCard.fxml")); | ||
| Parent card = loader.load(); | ||
| OrgDonationCardController cardController = loader.getController(); | ||
| cardController.setDonation(donation); | ||
| cardController.setAuthToken(authToken); | ||
| cardsContainer.getChildren().add(card); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException("Could not load organization card.", e); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Sidebar Methods | ||
| @FXML | ||
| private void switchToEditPage(ActionEvent event){ | ||
| LoaderScene.LoadScene("profile_org_edit", event, null, null, authToken); | ||
| } | ||
|
|
||
| @FXML | ||
| private void switchToFeedbackPage(ActionEvent event){ | ||
| LoaderScene.LoadScene("profile_org_Inbox", event, null, null, authToken); | ||
| } | ||
|
|
||
| @FXML | ||
| private void switchToSettingsPage(ActionEvent event){ | ||
| LoaderScene.LoadScene("profile_user_Settings", event, null, null, authToken); | ||
| } | ||
|
|
||
|
|
||
| @FXML | ||
| private void handleLogout(ActionEvent event){ | ||
| authToken.logout(); | ||
| showAlert(Alert.AlertType.INFORMATION, "Logging out", "Logging out..."); | ||
| LoaderScene.LoadScene("FrontPage", event, null, null, authToken); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 10 additions & 14 deletions
24
helpmehelpapplication/src/main/resources/fxml/components/profileDonationCard.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,25 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <?import javafx.scene.control.*?> | ||
| <?import javafx.scene.layout.*?> | ||
| <?import javafx.scene.text.*?> | ||
| <?import javafx.scene.control.Label?> | ||
| <?import javafx.scene.layout.HBox?> | ||
| <?import javafx.scene.text.Font?> | ||
|
|
||
| <HBox spacing="20.0" | ||
| style="-fx-background-color: #FFFFFF; -fx-border-color: transparent transparent #EEEEEE transparent; -fx-border-width: 1; -fx-padding: 0 20 0 20;" | ||
| xmlns="http://javafx.com/javafx/25" | ||
| xmlns:fx="http://javafx.com/fxml/1" | ||
| fx:controller="ntnu.systemutvikling.team6.controller.components.DonationCardController"> | ||
| <HBox spacing="20.0" style="-fx-background-color: #FFFFFF; -fx-border-color: transparent transparent #EEEEEE transparent; -fx-border-width: 1; -fx-padding: 0 20 0 20;" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.components.DonationCardController"> | ||
| <children> | ||
| <Label fx:id="charityNameLabel" prefWidth="265.0" style="-fx-text-fill: #111111; -fx-padding: 10 0 14 0;"> | ||
| <Label fx:id="charityNameLabel" prefWidth="265.0" style="-fx-text-fill: #111111; -fx-padding: 10 0 14 0;" text="Name"> | ||
| <font><Font name="System Bold" size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="purchaseIDLabel" prefWidth="210.0" style="-fx-text-fill: #777777; -fx-padding: 10 0 14 0;"> | ||
| <Label fx:id="purchaseIDLabel" prefWidth="210.0" style="-fx-text-fill: #777777; -fx-padding: 10 0 14 0;" text="#id"> | ||
| <font><Font size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="dateLabel" prefWidth="160.0" style="-fx-text-fill: #777777; -fx-padding: 10 0 14 0;"> | ||
| <Label fx:id="dateLabel" prefWidth="160.0" style="-fx-text-fill: #777777; -fx-padding: 10 0 14 0;" text="00-12-2026"> | ||
| <font><Font size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="AnonymousLabel" prefWidth="120.0" style="-fx-text-fill: #777777; -fx-padding: 10 0 14 0;"> | ||
| <Label fx:id="AnonymousLabel" prefWidth="120.0" style="-fx-text-fill: #777777; -fx-padding: 10 0 14 0;" text="Anoynomous"> | ||
| <font><Font size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="totalLabel" prefWidth="100.0" style="-fx-text-fill: #2f8f8b; -fx-padding: 10 0 14 0;"> | ||
| <Label fx:id="totalLabel" prefWidth="100.0" style="-fx-text-fill: #2f8f8b; -fx-padding: 10 0 14 0;" text="1000kr"> | ||
| <font><Font name="System Bold" size="12.0" /></font> | ||
| </Label> | ||
| </children> | ||
| </HBox> | ||
| </HBox> |
35 changes: 35 additions & 0 deletions
35
helpmehelpapplication/src/main/resources/fxml/components/profileOrgDonationCard.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <?import javafx.scene.control.*?> | ||
| <?import javafx.scene.layout.*?> | ||
| <?import javafx.scene.text.*?> | ||
|
|
||
| <GridPane | ||
| style="-fx-background-color: #FFFFFF; -fx-border-color: transparent transparent #EEEEEE transparent; -fx-border-width: 1; -fx-padding: 10 20 14 20;" | ||
| xmlns="http://javafx.com/javafx/25" | ||
| xmlns:fx="http://javafx.com/fxml/1" | ||
| fx:controller="ntnu.systemutvikling.team6.controller.components.OrgDonationCardController"> | ||
| <columnConstraints> | ||
| <ColumnConstraints percentWidth="25" /> | ||
| <ColumnConstraints percentWidth="20" /> | ||
| <ColumnConstraints percentWidth="20" /> | ||
| <ColumnConstraints percentWidth="35" /> | ||
| </columnConstraints> | ||
| <rowConstraints> | ||
| <RowConstraints /> | ||
| </rowConstraints> | ||
| <children> | ||
| <Label fx:id="purchaseIDLabel" style="-fx-text-fill: #777777;" GridPane.columnIndex="0" GridPane.halignment="CENTER"> | ||
| <font><Font size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="donerNameLabel" style="-fx-text-fill: #2f8f8b;" GridPane.columnIndex="1" GridPane.halignment="CENTER"> | ||
| <font><Font name="System Bold" size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="totalLabel" style="-fx-text-fill: #111111;" GridPane.columnIndex="2" GridPane.halignment="CENTER"> | ||
| <font><Font name="System Bold" size="12.0" /></font> | ||
| </Label> | ||
| <Label fx:id="dateLabel" style="-fx-text-fill: #777777;" GridPane.columnIndex="3" GridPane.halignment="CENTER"> | ||
| <font><Font size="12.0" /></font> | ||
| </Label> | ||
| </children> | ||
| </GridPane> |
Oops, something went wrong.