Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
56 changes: 2 additions & 54 deletions src/main/java/app/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import application.security.PasswordHasher;
import application.user.UserRegister;
import domain.donation.Donation;
import domain.organization.Organization;
import domain.user.User;
import integration.InnsamlingskontrollenClient;
import integration.security.Sha256PasswordHasher;
import java.math.BigDecimal;
import java.util.List;
Expand All @@ -21,59 +19,11 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import persistence.OrganizationDao;
import persistence.db.Database;

public class Main extends Application {

import javax.xml.crypto.Data;
import java.io.IOException;
import java.util.List;

public class Main extends Application{
public static void main(String[] args) {
try {
Database.getConnection();
System.out.println("Database connected");

UserDao userDao = new UserDao();
OrganizationDao orgDao = new OrganizationDao();
DonationDao donationDao = new DonationDao();

PasswordHasher hasher = new Sha256PasswordHasher();
UserRepository userRepo = new UserDao();
UserRegister userReg = new UserRegister(hasher, userRepo);

// Test brukerregistrering
userReg.execute("testuser", "12345678", "passord123", "test@example.com");
System.out.println("Inserted user!");

User user = userDao.findByEmail("test@example.com").orElseThrow();
System.out.println("Hentet bruker: " + user.getUsername() + ", id=" + user.getID());

// Hent og lagre organisasjoner fra Innsamlingskontrollen
System.out.println("Henter organisasjoner fra Innsamlingskontrollen...");
Organization[] fetchedOrgs = InnsamlingskontrollenClient.fetchOrganizations();
for (Organization org : fetchedOrgs) {
orgDao.insert(org);
}
System.out.println("Lastet inn " + fetchedOrgs.length + " organisasjoner");

List<Organization> orgs = orgDao.getAll();
System.out.println("Organisasjoner i DB: " + orgs.size());
System.out.println("Første org: " + orgs.get(0).getName() + ", org_number=" + orgs.get(0).getOrgNumber());

// Test donasjon med første org fra DB
Donation donation = new Donation(new BigDecimal("100.00"), user, orgs.get(0));
donationDao.insert(donation);
System.out.println("Inserted donation, id=" + donation.getId());

List<Donation> donations = donationDao.findByUser(user.getID());
System.out.println("Antall donasjoner for bruker: " + donations.size());

} catch (Exception e) {
e.printStackTrace();
}
launch(args);
}

@Override
public void start(Stage stage) throws Exception {
Expand All @@ -85,8 +35,6 @@ public void start(Stage stage) throws Exception {
orgDao.insert(org);
}

SceneManager.setStage(stage);

Parent root = FXMLLoader.load(getClass().getResource("/view/MainView.fxml"));
Scene scene = new Scene(root, 1275, 725);

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public User(String userName, String phoneNumber, String password, String eMail)
this.phoneNumber = phoneNumber;
this.eMail = eMail.trim();
this.password = password;
this.id = id;
}

public String getUsername() {
Expand Down Expand Up @@ -62,14 +61,12 @@ public void setPhonenumber (String phoneNumber) {
this.phoneNumber = phoneNumber;
}


public void setId(Long id) {
if (this.id != null) throw new IllegalStateException("ID already set");
this.id = id;
}

private static boolean isValidEmail(String email) {
if (email == null || email.isBlank()) return false;
return email.matches("^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$");

}
}
1 change: 0 additions & 1 deletion src/main/java/persistence/DonationDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ private Donation mapRow(ResultSet rs) throws SQLException {
rs.getString("password_hash"),
rs.getString("e_mail")
);
user.setId(rs.getLong("user_id"));

Organization org = new Organization();
org.setOrgNumber(rs.getString("org_number"));
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ui/controller/HomeController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ui.controller;

import app.SceneManager;
import application.security.PasswordHasher;
import application.user.UserSignIn;
import integration.security.Sha256PasswordHasher;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ui/controller/OrganizationController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ui.controller;

import app.SceneManager;
import application.security.PasswordHasher;
import application.user.UserSignIn;
import domain.organization.Organization;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ui/controller/RegisterController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ui.controller;

import app.SceneManager;
import application.security.PasswordHasher;
import application.user.UserRegister;
import application.user.UserSignIn;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ui/controller/SignInController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ui.controller;

import app.SceneManager;
import application.security.PasswordHasher;
import application.user.UserRegister;
import application.user.UserSignIn;
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/css/Global.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
.scroll-pane {
-fx-background-color: transparent;
-fx-border-color: transparent;
-fx-border-width: 0;
-fx-padding: 0;
}

.scroll-pane > .viewport {
Expand Down Expand Up @@ -123,4 +125,5 @@
-fx-font-family: "Times New Roman";
-fx-text-fill: white;
-fx-font-weight: bold;
}
}

121 changes: 121 additions & 0 deletions src/main/resources/css/Home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
.hero-section {
-fx-background-color: #1e3a8a;
-fx-padding: 56 48 48 48;
}

.hero-tag {
-fx-background-color: rgba(255,255,255,0.15);
-fx-text-fill: white;
-fx-font-size: 12px;
-fx-background-radius: 20;
-fx-padding: 4 12 4 12;
}

.hero-title {
-fx-font-size: 28px;
-fx-text-fill: white;
-fx-font-weight: bold;
}

.hero-subtitle {
-fx-font-size: 16px;
-fx-text-fill: white;
-fx-wrap-text: true;
-fx-max-width: 440;
}

.hero-button-primary {
-fx-background-color: white;
-fx-text-fill: #1e3a8a;
-fx-font-weight: bold;
-fx-background-radius: 6;
-fx-padding: 10 22 10 22;
-fx-cursor: hand;
}

.hero-button-secondary {
-fx-background-color: transparent;
-fx-text-fill: white;
-fx-border-color: rgba(255,255,255,0.6);
-fx-border-radius: 6;
-fx-background-radius: 6;
-fx-padding: 10 22 10 22;
-fx-cursor: hand;
}

.hero-button-primary:hover {
-fx-background-color: #f0f0f0;
-fx-scale-x: 1.03;
-fx-scale-y: 1.03;
}

.hero-button-primary:pressed {
-fx-background-color: #e0e0e0;
-fx-scale-x: 0.97;
-fx-scale-y: 0.97;
}

.hero-button-secondary:hover {
-fx-background-color: rgba(255,255,255,0.15);
-fx-scale-x: 1.03;
-fx-scale-y: 1.03;
}

.hero-button-secondary:pressed {
-fx-scale-x: 0.97;
-fx-scale-y: 0.97;
}

.stats-stripe {
-fx-background-color: #162d6e;
-fx-padding: 20 48 20 48;
}

.stats-number {
-fx-font-size: 24px;
-fx-font-weight: bold;
-fx-text-fill: white;
}

.stats-label {
-fx-font-size: 14px;
-fx-text-fill: rgba(255,255,255,0.7);
}

.features-section {
-fx-background-color: #f8faff;
-fx-padding: 32 48 48 48;
}

.features-title {
-fx-font-size: 18px;
-fx-font-weight: bold;
-fx-text-fill: #1a1a2e;
}

.features-grid {
-fx-spacing: 16;
}

.feature-card {
-fx-background-color: white;
-fx-border-color: #dde3f0;
-fx-border-width: 1;
-fx-border-radius: 10;
-fx-background-radius: 10;
-fx-min-height: 120;
-fx-padding: 20;
-fx-spacing: 8;
}

.feature-card-title {
-fx-font-size: 14px;
-fx-font-weight: bold;
-fx-text-fill: #1a1a2e;
}

.feature-card-desc {
-fx-font-size: 13px;
-fx-text-fill: #666666;
-fx-wrap-text: true;
}
Loading