Skip to content

Commit

Permalink
Fix: Duplicate entry fix, unqiue donation id everytime + small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 21, 2026
1 parent 4cd19f3 commit 9a608e2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private void handleSendMessage(ActionEvent event) {
DatabaseConnection conn = new DatabaseConnection();
MessageDAO messageDAO = new MessageDAO(conn);
Charity charity = authToken.isCharityUser();
Message message = new Message(title, authToken.isCharityUser(), content);
messageDAO.addMessage(message);
Message messageStaticId = new Message(title, authToken.isCharityUser(), content);
messageDAO.addMessage(messageStaticId);
showAlert(Alert.AlertType.INFORMATION, "Sent!", "Your message has been sent to all donors.");
messageTitleField.clear();
messageContentField.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

public class profileUserHistoryController extends BaseController {
@FXML
Expand Down Expand Up @@ -58,6 +59,8 @@ public void populateFields() {
DatabaseConnection conn = new DatabaseConnection();
DonationSelect donationSelect = new DonationSelect(conn);
DonationRegistry donationRegistry = donationSelect.getDonationForUser(authToken.getCurrentUser().getId().toString());
double ammount = donationRegistry.getAllDonations().stream().mapToDouble(d->d.getAmount()).sum();
totalAmmount.setText(String.valueOf(ammount));
displayDonations(donationRegistry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class MessageDAO {
private final DatabaseConnection connection;
Expand All @@ -32,7 +33,7 @@ public boolean addMessage(Message message){
PreparedStatement stmt = conn.prepareStatement(sql)) {

for (String donorId : donorIds) {
stmt.setString(1, message.getId().toString());
stmt.setString(1, UUID.randomUUID().toString());
stmt.setString(2, message.getTitle());
stmt.setString(3, message.getContent());
stmt.setDate(4, Date.valueOf(message.getTimeAndDate()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<Label prefWidth="265.0" style="-fx-text-fill: #000000;" text="Donation" />
<Label prefWidth="210.0" style="-fx-text-fill: #000000;" text="Purchase number" />
<Label prefWidth="160.0" style="-fx-text-fill: #000000;" text="Date" />
<Label prefWidth="120.0" style="-fx-text-fill: #000000;" text="Item" />
<Label prefWidth="120.0" style="-fx-text-fill: #000000;" text="Anonymous" />
<Label prefWidth="100.0" style="-fx-text-fill: #000000;" text="Total" />
</children>
</HBox>
Expand Down

0 comments on commit 9a608e2

Please sign in to comment.