From 03559170c08d1feb819149a19fccdeee7a23a669 Mon Sep 17 00:00:00 2001 From: Marius Klepp Date: Tue, 21 Apr 2026 14:11:19 +0200 Subject: [PATCH 1/7] fix: fix all tests --- src/main/java/domain/user/User.java | 43 +++- .../java/application/user/UserLoginTest.java | 4 +- .../application/user/UserRegisterTest.java | 6 +- .../application/user/UserStatisticsTest.java | 46 ++-- src/test/java/domain/DonationTest.java | 85 +++----- src/test/java/domain/OrganizationTest.java | 198 ++---------------- src/test/java/domain/UserTest.java | 19 +- 7 files changed, 126 insertions(+), 275 deletions(-) diff --git a/src/main/java/domain/user/User.java b/src/main/java/domain/user/User.java index 5d471cc..e423710 100644 --- a/src/main/java/domain/user/User.java +++ b/src/main/java/domain/user/User.java @@ -7,7 +7,7 @@ public class User { private String userName; private String phoneNumber; - private final String eMail; + private String eMail; private String password; private Long id; @@ -87,6 +87,47 @@ public String getPassword() { */ public long getID() { return id; } + /** + * Sets the username of this user. + * @param userName the new username; must not be null or blank + */ + public void setUsername(String userName) { + if (userName == null || userName.isBlank()) { + throw new IllegalArgumentException("Username has to be filled in"); + } + this.userName = userName; + } + + /** + * Sets the phone number of this user. + * @param phoneNumber the new phone number; must be exactly 8 digits + */ + public void setPhoneNumber(String phoneNumber) { + if (phoneNumber == null || phoneNumber.isBlank() || phoneNumber.length() != 8) { + throw new IllegalArgumentException("Fill in a phonenumber with 8 digits"); + } + this.phoneNumber = phoneNumber; + } + + /** + * Sets the email address of this user. + * @param eMail the new email address; must be a valid email format + */ + public void setEmail(String eMail) { + if (!isValidEmail(eMail)) { + throw new IllegalArgumentException("Invalid email address: " + eMail); + } + this.eMail = eMail.trim(); + } + + /** + * Sets the password hash of this user. + * @param password the new hashed password + */ + public void setPassword(String password) { + this.password = password; + } + /** * Sets the ID for this user. * diff --git a/src/test/java/application/user/UserLoginTest.java b/src/test/java/application/user/UserLoginTest.java index 4bd8312..20caec1 100644 --- a/src/test/java/application/user/UserLoginTest.java +++ b/src/test/java/application/user/UserLoginTest.java @@ -3,7 +3,7 @@ import application.security.PasswordHasher; import domain.user.User; import org.junit.jupiter.api.Test; -import persistence.UserRepository; +import persistence.dao.UserRepository; import java.util.Optional; @@ -155,6 +155,8 @@ public boolean existsByUsername(String username) { @Override public void insert(User user) { } + + } diff --git a/src/test/java/application/user/UserRegisterTest.java b/src/test/java/application/user/UserRegisterTest.java index c5296cd..a4807cd 100644 --- a/src/test/java/application/user/UserRegisterTest.java +++ b/src/test/java/application/user/UserRegisterTest.java @@ -3,7 +3,7 @@ import application.security.PasswordHasher; import domain.user.User; import org.junit.jupiter.api.Test; -import persistence.UserRepository; +import persistence.dao.UserRepository; import java.util.Optional; @@ -23,7 +23,7 @@ void executeInsertsUserWhenInputIsValid() { assertEquals("testuser", repo.insertedUser.getUsername()); assertEquals("12345678", repo.insertedUser.getPhoneNumber()); assertEquals("hashed-password", repo.insertedUser.getPassword()); - assertEquals("test@example.com", repo.insertedUser.getEMail()); + assertEquals("test@example.com", repo.insertedUser.getEmail()); } @@ -38,7 +38,7 @@ void executeNormalizesUsernameEmailAndPhoneBeforeInsert() { assertNotNull(repo.insertedUser); assertEquals("testuser", repo.insertedUser.getUsername()); assertEquals("12345678", repo.insertedUser.getPhoneNumber()); - assertEquals("test@example.com", repo.insertedUser.getEMail()); + assertEquals("test@example.com", repo.insertedUser.getEmail()); } diff --git a/src/test/java/application/user/UserStatisticsTest.java b/src/test/java/application/user/UserStatisticsTest.java index da904cb..492ac43 100644 --- a/src/test/java/application/user/UserStatisticsTest.java +++ b/src/test/java/application/user/UserStatisticsTest.java @@ -2,7 +2,7 @@ import domain.user.User; import org.junit.jupiter.api.Test; -import persistence.DonationDao; +import persistence.dao.DonationDao; import java.lang.reflect.Field; import java.util.List; @@ -12,28 +12,28 @@ public class UserStatisticsTest { @Test - void userFavoriteOrganizationsReturnsListFromDonationDao() throws Exception { + void userFavoriteOrganization_returnsListFromDonationDao() throws Exception { FakeDonationDao fakeDao = new FakeDonationDao(); fakeDao.favoriteOrganizationsToReturn = List.of( - "Org1 (3 donasjoner)", - "Org2 (2 donasjoner)" + "Org1 (3 donasjoner)", + "Org2 (2 donasjoner)" ); UserStatistics statistics = createStatisticsWithFakeDao(fakeDao); User user = createUserWithId(42L); - List result = statistics.userFavoriteOrganizations(user); + List result = statistics.userFavoriteOrganization(user); assertEquals(List.of("Org1 (3 donasjoner)", "Org2 (2 donasjoner)"), result); assertEquals(42L, fakeDao.lastUserIdForFavorites); } @Test - void userDonationsReturnsListFromDonationDao() throws Exception { + void userDonations_returnsListFromDonationDao() throws Exception { FakeDonationDao fakeDao = new FakeDonationDao(); fakeDao.userDonationsToReturn = List.of( - "Amount: 100, Date: 2026-04-15, Organization: Org1", - "Amount: 50, Date: 2026-04-16, Organization: Org2" + "Amount: 100, Date: 2026-04-15, Organization: Org1", + "Amount: 50, Date: 2026-04-16, Organization: Org2" ); UserStatistics statistics = createStatisticsWithFakeDao(fakeDao); @@ -42,14 +42,14 @@ void userDonationsReturnsListFromDonationDao() throws Exception { List result = statistics.userDonations(user); assertEquals(List.of( - "Amount: 100, Date: 2026-04-15, Organization: Org1", - "Amount: 50, Date: 2026-04-16, Organization: Org2" + "Amount: 100, Date: 2026-04-15, Organization: Org1", + "Amount: 50, Date: 2026-04-16, Organization: Org2" ), result); assertEquals(7L, fakeDao.lastUserIdForDonations); } @Test - void userTotalDonationAmountReturnsValueFromDonationDao() throws Exception { + void userTotalDonationAmount_returnsValueFromDonationDao() throws Exception { FakeDonationDao fakeDao = new FakeDonationDao(); fakeDao.totalDonationAmountToReturn = "250.00"; @@ -63,7 +63,7 @@ void userTotalDonationAmountReturnsValueFromDonationDao() throws Exception { } @Test - void getTotalDonationsMadeReturnsValueFromDonationDao() throws Exception { + void getTotalDonationsMade_returnsValueFromDonationDao() throws Exception { FakeDonationDao fakeDao = new FakeDonationDao(); fakeDao.totalDonationsMadeToReturn = "5"; @@ -76,15 +76,11 @@ void getTotalDonationsMadeReturnsValueFromDonationDao() throws Exception { assertEquals(99L, fakeDao.lastUserIdForTotalCount); } - - private UserStatistics createStatisticsWithFakeDao(FakeDonationDao fakeDao) throws Exception { UserStatistics statistics = new UserStatistics(); - Field field = UserStatistics.class.getDeclaredField("donationDao"); field.setAccessible(true); field.set(statistics, fakeDao); - return statistics; } @@ -95,18 +91,18 @@ private User createUserWithId(long id) { } private static class FakeDonationDao extends DonationDao { - private List favoriteOrganizationsToReturn = List.of(); - private List userDonationsToReturn = List.of(); - private String totalDonationAmountToReturn = "0"; - private String totalDonationsMadeToReturn = "0"; + List favoriteOrganizationsToReturn = List.of(); + List userDonationsToReturn = List.of(); + String totalDonationAmountToReturn = "0"; + String totalDonationsMadeToReturn = "0"; - private long lastUserIdForFavorites; - private long lastUserIdForDonations; - private long lastUserIdForTotalAmount; - private long lastUserIdForTotalCount; + long lastUserIdForFavorites; + long lastUserIdForDonations; + long lastUserIdForTotalAmount; + long lastUserIdForTotalCount; @Override - public List getFavoriteOrganizations(long userId) { + public List getFavoriteOrganization(long userId) { lastUserIdForFavorites = userId; return favoriteOrganizationsToReturn; } diff --git a/src/test/java/domain/DonationTest.java b/src/test/java/domain/DonationTest.java index ea73049..57c5be1 100644 --- a/src/test/java/domain/DonationTest.java +++ b/src/test/java/domain/DonationTest.java @@ -1,6 +1,5 @@ package domain; -import domain.donation.Cause; import domain.donation.Donation; import domain.organization.Organization; import domain.user.User; @@ -17,104 +16,68 @@ class DonationTest { - //User Variables - private final String testUserName = "testUser"; - private final String testPhoneNumber = "90909090"; - private final String testEmail = "test@email.com"; - private final String testPassword = "password"; - - //Organization Variables - private final String testName = "Name"; - private final String testOrgNr = "123456789"; - private final Cause testCause = Cause.HEALTH; - private final String testDescription = "Description"; - private final String testContactEmail = "test@mail.com"; - private final String testWebsite = "https://test.com"; - private final boolean testVerified = true; - - //Donation Variables - private Long testID = 123L; - private BigDecimal testAmount = new BigDecimal("1500"); - private LocalDateTime testDateTime = LocalDateTime.of(2026, 3, 5, 8, 30, 0); private User testUser; private Organization testOrganization; + private BigDecimal testAmount = new BigDecimal("1500"); @BeforeEach public void init() { - testUser = new User(testUserName, testPhoneNumber, testPassword, testEmail); - testOrganization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); + testUser = new User("testUser", "90909090", "password", "test@email.com"); + testOrganization = new Organization(); + testOrganization.setOrgNumber("123456789"); + testOrganization.setName("Test Organization"); + testOrganization.setStatus("approved"); + testOrganization.setUrl("https://test.com"); } - @Test - public void DonationTestPositive(){ + public void validDonation_createsSuccessfully() { Donation donation = new Donation(testAmount, testUser, testOrganization); } @Test - public void DonationTestUserNull(){ - testUser = null; - NullPointerException Exception = assertThrows(NullPointerException.class, - () -> new Donation (testAmount, testUser, testOrganization)); - - assertEquals("User cannot be null", Exception.getMessage()); - } - - @Test - public void DonationOrganizationNull(){ - testOrganization = null; - NullPointerException Exception = assertThrows(NullPointerException.class, - () -> new Donation (testAmount, testUser, testOrganization)); - - assertEquals("Organization cannot be null", Exception.getMessage()); + public void nullUser_throwsNullPointerException() { + NullPointerException exception = assertThrows(NullPointerException.class, + () -> new Donation(testAmount, null, testOrganization)); + assertEquals("User cannot be null", exception.getMessage()); } @Test - public void DonationTestAmountNegative(){ - testAmount = new BigDecimal("-23"); - IllegalArgumentException Exception = assertThrows(IllegalArgumentException.class, - () -> new Donation (testAmount, testUser, testOrganization)); - - assertEquals("Amount must be greater than 0", Exception.getMessage()); + public void nullOrganization_throwsNullPointerException() { + NullPointerException exception = assertThrows(NullPointerException.class, + () -> new Donation(testAmount, testUser, null)); + assertEquals("Organization cannot be null", exception.getMessage()); } - //Getter tests - /* id is never set, getter makes a NullPointerException @Test - public void DonationTestIdGet(){ - Donation donation = new Donation(testAmount, testUser, testOrganization); - assertEquals(0L, donation.getId()); - + public void negativeAmount_throwsIllegalArgumentException() { + IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, + () -> new Donation(new BigDecimal("-23"), testUser, testOrganization)); + assertEquals("Amount must be greater than 0", exception.getMessage()); } - */ @Test - public void DonationTestAmountGet(){ + public void getAmount_returnsCorrectValue() { Donation donation = new Donation(testAmount, testUser, testOrganization); assertEquals(testAmount, donation.getAmount()); - } @Test - public void DonationTestDateTimeGet(){ + public void getDateTime_returnsCurrentTime() { LocalDateTime now = LocalDateTime.now(); Donation donation = new Donation(testAmount, testUser, testOrganization); - assertTrue(Duration.between(now, donation.getDateTime()).abs().toMillis() < 1000); - } @Test - public void DonationTestUserGet(){ + public void getUser_returnsCorrectUser() { Donation donation = new Donation(testAmount, testUser, testOrganization); assertEquals(testUser, donation.getUser()); - } @Test - public void DonationTestOrganizationGet(){ + public void getOrganization_returnsCorrectOrganization() { Donation donation = new Donation(testAmount, testUser, testOrganization); assertEquals(testOrganization, donation.getOrganization()); - } } \ No newline at end of file diff --git a/src/test/java/domain/OrganizationTest.java b/src/test/java/domain/OrganizationTest.java index 47c8024..b15d2da 100644 --- a/src/test/java/domain/OrganizationTest.java +++ b/src/test/java/domain/OrganizationTest.java @@ -1,207 +1,51 @@ package domain; -import domain.donation.Cause; import domain.organization.Organization; import domain.user.User; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; class OrganizationTest { - private String testName = "Name"; - private String testOrgNr = "123456789"; - private Cause testCause = Cause.HEALTH; - private String testDescription = "Description"; - private String testContactEmail = "test@mail.com"; - private String testWebsite = "https://test.com"; - private boolean testVerified = true; - //Positive tests - @Test - public void organizationTestPositive(){ - Organization organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - } + private Organization organization; - //Negative tests - @Test - public void organizationTestNameBlank(){ - testName = ""; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization("", testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Name cannot be null or blank", exception.getMessage()); + @BeforeEach + public void init() { + organization = new Organization(); + organization.setOrgNumber("123456789"); + organization.setName("Test Organization"); + organization.setStatus("approved"); + organization.setUrl("https://test.com"); + organization.setPreApproved(true); } @Test - public void organizationTestNameNull(){ - testName = null; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Name cannot be null or blank", exception.getMessage()); + public void getOrgNumber_returnsCorrectValue() { + assertEquals("123456789", organization.getOrgNumber()); } @Test - public void organizationTestOrgNrNull(){ - testOrgNr = null; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Organization number must be 9 digits", exception.getMessage()); + public void getName_returnsCorrectValue() { + assertEquals("Test Organization", organization.getName()); } @Test - public void organizationTestOrgNrLetters(){ - testOrgNr = "12345678a"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Organization number must be 9 digits", exception.getMessage()); + public void getStatus_returnsCorrectValue() { + assertEquals("approved", organization.getStatus()); } @Test - public void organizationTestOrgNrShort(){ - testOrgNr = "12345"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Organization number must be 9 digits", exception.getMessage()); + public void getUrl_returnsCorrectValue() { + assertEquals("https://test.com", organization.getUrl()); } - /* Mangler exception for når email er null @Test - public void organizationTestContactEmailNull(){ - testContactEmail = null; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); + public void isPreApproved_returnsTrue() { + assertTrue(organization.isPreApproved()); } - */ - - @Test - public void organizationTestContactEmailTrim(){ - testContactEmail = "test@mail.com "; - Organization organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - } - - @Test - public void organizationTestContactEmailBlank(){ - testContactEmail = ""; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Email cannot be blank", exception.getMessage()); - } - - @Test - public void organizationTestContactEmailMissingAt(){ - testContactEmail = "test.com"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Invalid email format", exception.getMessage()); - } - - @Test - public void organizationTestContactEmailDoubleAt(){ - testContactEmail = "test@@mail.com"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Invalid email format", exception.getMessage()); - } - - @Test - public void organizationTestContactEmailMisplacedAt(){ - testContactEmail = "@testmail.com"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Invalid email format", exception.getMessage()); - } - - @Test - public void organizationTestContactEmailMissingDot(){ - testContactEmail = "test@mailcom"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Invalid email format", exception.getMessage()); - } - - @Test - public void organizationTestWebsiteMissingHttps(){ - testWebsite = "test.com"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - assertEquals("Website must start with http:// or https://", exception.getMessage()); - } - - /* Mangler exception når url mangler domain extension (.com f.eks) - @Test - public void organizationTestWebsiteMissingDot(){ - testWebsite = "https://testcom"; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Website must start with http:// or https://", exception.getMessage()); - } - */ - - /* Mangler exception når website er null - @Test - public void organizationTestWebsiteMissingDot(){ - testWebsite = null; - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, - () -> new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified)); - - assertEquals("Website must start with http:// or https://", exception.getMessage()); - } - */ - - - - //Getter tests - @Test - public void organizationTestNameGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testName, Organization.getName()); - } - - @Test - public void organizationTestOrgNrGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testOrgNr, Organization.getOrgNr()); - } - - @Test - public void organizationTestCauseGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testCause, Organization.getCause()); - } - - @Test - public void organizationDescriptionGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testDescription, Organization.getDescription()); - } - - @Test - public void organizationTestContactEmailGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testContactEmail, Organization.getContactEmail()); - } - - @Test - public void organizationTestWebsiteGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testWebsite, Organization.getWebsite()); - } - - @Test - public void organizationTestIsVerifiedGet(){ - Organization Organization = new Organization(testName, testOrgNr, testCause, testDescription, testContactEmail, testWebsite, testVerified); - assertEquals(testVerified, Organization.isVerified()); - } } \ No newline at end of file diff --git a/src/test/java/domain/UserTest.java b/src/test/java/domain/UserTest.java index b1c8f14..2aa440c 100644 --- a/src/test/java/domain/UserTest.java +++ b/src/test/java/domain/UserTest.java @@ -70,7 +70,7 @@ public void userTestEmailBlank(){ IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new User(testUserName, testPhoneNumber, testPassword, testEmail)); - assertEquals("E-mail has to be filled in", exception.getMessage()); + assertEquals("Invalid email address: ", exception.getMessage()); } @Test @@ -79,7 +79,7 @@ public void userTestEmailNull(){ IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new User(testUserName, testPhoneNumber, testPassword, testEmail)); - assertEquals("E-mail has to be filled in", exception.getMessage()); + assertEquals("Invalid email address: null", exception.getMessage()); } //Getter tests @@ -98,7 +98,7 @@ public void userTestPhoneNumberGet(){ @Test public void userTestEmailGet(){ User User = new User(testUserName, testPhoneNumber, testPassword, testEmail); - assertEquals(User.getEMail(), testEmail); + assertEquals(User.getEmail(), testEmail); } @Test @@ -127,11 +127,16 @@ public void userTestUserNameSet(){ @Test public void userTestPhoneNumberSet(){ User User = new User(testUserName, testPhoneNumber, testPassword, testEmail); - String newPhoneNumber = "123456asdsad7"; //Trenger input validering - User.setPhonenumber(newPhoneNumber); + String newPhoneNumber = "12345678"; + User.setPhoneNumber(newPhoneNumber); assertEquals(newPhoneNumber, User.getPhoneNumber()); } - - + @Test + public void userTestEmailSet() { + User user = new User(testUserName, testPhoneNumber, testPassword, testEmail); + String newEmail = "new@email.com"; + user.setEmail(newEmail); + assertEquals(newEmail, user.getEmail()); + } } \ No newline at end of file From a05b1f22ba0abdaf3f40d63bc9963ccc55a512cc Mon Sep 17 00:00:00 2001 From: Marius Klepp Date: Tue, 21 Apr 2026 14:33:47 +0200 Subject: [PATCH 2/7] feat: logo is bigger and takes you to homepage on interaction --- .../java/ui/controller/NavbarController.java | 15 +++ src/main/resources/css/Global.css | 2 +- src/main/resources/view/MyProfile.fxml | 114 ++++++++++++++++-- src/main/resources/view/Navbar.fxml | 2 +- 4 files changed, 120 insertions(+), 13 deletions(-) diff --git a/src/main/java/ui/controller/NavbarController.java b/src/main/java/ui/controller/NavbarController.java index 0be90c5..af0d65f 100644 --- a/src/main/java/ui/controller/NavbarController.java +++ b/src/main/java/ui/controller/NavbarController.java @@ -4,6 +4,7 @@ import javafx.fxml.FXML; import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.layout.HBox; import ui.Page; import util.SessionManager; @@ -23,6 +24,8 @@ public class NavbarController { private Button orgBtn; @FXML private Button signInBtn; + @FXML + private Label logoLabel; /** * Sets the navigation callback. @@ -56,6 +59,7 @@ public void setActivePage(Page page) { /** * Navigates to the home page. */ + @FXML public void goHome() { onNavigate.accept(Page.HOME); } @@ -63,6 +67,7 @@ public void goHome() { /** * Navigates to the sign in page or profile page depending on authentication state. */ + @FXML public void goToSignIn() { if (SessionManager.isSignedIn()) { onNavigate.accept(Page.PROFILE); @@ -74,10 +79,12 @@ public void goToSignIn() { /** * Navigates to the organizations page. */ + @FXML public void goToOrganizations() { onNavigate.accept(Page.ORGANIZATIONS); } + /** * Updates the sign in button text based on the user's authentication state. * Shows "My Profile" if signed in, "Sign In" otherwise. @@ -90,6 +97,14 @@ public void updateAuthButton() { } } + /** + * Navigates to the home page. + */ + @FXML + private void handleLogoClick() { + onNavigate.accept(Page.HOME); + } + /** * Hides the navbar. */ diff --git a/src/main/resources/css/Global.css b/src/main/resources/css/Global.css index 7a2eeac..e0253c6 100644 --- a/src/main/resources/css/Global.css +++ b/src/main/resources/css/Global.css @@ -121,7 +121,7 @@ } .logo-label { - -fx-font-size: 22px; + -fx-font-size: 32px; -fx-font-family: "Times New Roman"; -fx-text-fill: white; -fx-font-weight: bold; diff --git a/src/main/resources/view/MyProfile.fxml b/src/main/resources/view/MyProfile.fxml index 40ec2de..7ae4bde 100644 --- a/src/main/resources/view/MyProfile.fxml +++ b/src/main/resources/view/MyProfile.fxml @@ -4,34 +4,123 @@ + + +
- +