Skip to content

Commit

Permalink
Feat: One singular name field.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 20, 2026
1 parent 9e37945 commit 3e298b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class CreateUserPageController extends BaseController {
private FooterController footerController;

@FXML private TextField firstNameField;
@FXML private TextField lastNameField;
@FXML private TextField emailField;
@FXML private PasswordField passwordField;
@FXML private PasswordField confirmPasswordField;
Expand All @@ -36,13 +35,12 @@ protected void authTokenisSet() {

@FXML
private void handleCreateAccount(ActionEvent event){
String firstNameText = firstNameField.getText();
String lastNameText = lastNameField.getText();
String nameText = firstNameField.getText();
String emailText = emailField.getText();
String password = passwordField.getText();
String confirmPassword = confirmPasswordField.getText();

if (firstNameText.isBlank() || lastNameText.isBlank() || emailText.isBlank() || password.isBlank() || confirmPassword.isBlank()) {
if (nameText.isBlank() || emailText.isBlank() || password.isBlank() || confirmPassword.isBlank()) {
showAlert(Alert.AlertType.ERROR, "Empty input", "Please fill out all fields");
return;
}
Expand All @@ -60,8 +58,7 @@ private void handleCreateAccount(ActionEvent event){
// login
boolean registerSuccess;
try {
String username = firstNameText + " " + lastNameText;
registerSuccess = authToken.register(username,emailText, confirmPassword);
registerSuccess = authToken.register(nameText,emailText, confirmPassword);
} catch (IllegalArgumentException e) {
showAlert(Alert.AlertType.ERROR, "Email already taken", "Email already taken by another user.");
return;
Expand All @@ -76,7 +73,7 @@ private void handleCreateAccount(ActionEvent event){
Alert.AlertType.INFORMATION,
"Sign up sucsess",
"You have registered a new account! Please login with same credentials");
LoaderScene.LoadScene("loginSite", event, null, null, authToken);
LoaderScene.LoadScene("profile_user_settings", event, null, null, authToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
Expand All @@ -20,11 +17,7 @@
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>

<GridPane maxHeight="Infinity" maxWidth="Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="800.0" prefWidth="1200.0"
xmlns="http://javafx.com/javafx/25"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="ntnu.systemutvikling.team6.controller.CreateUserPageController">
<GridPane maxHeight="Infinity" maxWidth="Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.CreateUserPageController">

<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
Expand All @@ -40,13 +33,10 @@

<!-- NAVBAR -->
<!-- Pull in the navbar from components with its own controller -->
<fx:include fx:id="navbar" source="components/navbar.fxml"/>
<fx:include fx:id="navbar" source="components/navbar.fxml" />

<!-- MAIN CONTENT -->
<HBox prefHeight="100.0"
prefWidth="200.0"
style="-fx-background-color: #FFFFFF;"
GridPane.rowIndex="1">
<HBox prefHeight="100.0" prefWidth="200.0" style="-fx-background-color: #FFFFFF;" GridPane.rowIndex="1">
<children>
<GridPane alignment="CENTER" HBox.hgrow="ALWAYS">
<columnConstraints>
Expand All @@ -64,14 +54,7 @@
<StackPane prefHeight="420.0" prefWidth="500.0">
<children>

<Rectangle arcHeight="5.0"
arcWidth="5.0"
fill="WHITE"
height="410.0"
stroke="BLACK"
strokeLineCap="ROUND"
strokeType="OUTSIDE"
width="420.0">
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="410.0" stroke="BLACK" strokeLineCap="ROUND" strokeType="OUTSIDE" width="420.0">
<effect>
<DropShadow height="2.28" offsetY="2.0" radius="5.32">
<color>
Expand All @@ -83,7 +66,7 @@

<VBox alignment="TOP_LEFT" maxWidth="320.0" prefWidth="320.0" spacing="10.0">
<padding>
<Insets top="22.0" right="0.0" bottom="20.0" left="0.0" />
<Insets bottom="20.0" left="0.0" right="0.0" top="22.0" />
</padding>

<children>
Expand All @@ -97,31 +80,14 @@

<HBox spacing="12.0">
<children>
<VBox alignment="CENTER_LEFT" prefWidth="154.0" spacing="5.0">
<VBox alignment="CENTER_LEFT" prefHeight="45.0" prefWidth="556.0" spacing="5.0">
<children>
<Label text="First Name" textFill="#333333">
<Label text="Name" textFill="#333333">
<font>
<Font size="12.0" />
</font>
</Label>
<TextField fx:id="firstNameField"
prefWidth="154.0"
prefHeight="30.0"
style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
</children>
</VBox>

<VBox alignment="CENTER_LEFT" prefWidth="154.0" spacing="5.0">
<children>
<Label text="Last Name" textFill="#333333">
<font>
<Font size="12.0" />
</font>
</Label>
<TextField fx:id="lastNameField"
prefWidth="154.0"
prefHeight="30.0"
style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
<TextField fx:id="firstNameField" prefHeight="29.0" prefWidth="265.0" style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
</children>
</VBox>
</children>
Expand All @@ -134,11 +100,7 @@
<Font size="12.0" />
</font>
</Label>
<TextField fx:id="emailField"
maxWidth="320.0"
prefWidth="320.0"
prefHeight="30.0"
style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
<TextField fx:id="emailField" maxWidth="320.0" prefHeight="30.0" prefWidth="320.0" style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
</children>
</VBox>

Expand All @@ -149,11 +111,7 @@
<Font size="12.0" />
</font>
</Label>
<PasswordField fx:id="passwordField"
maxWidth="320.0"
prefWidth="320.0"
prefHeight="30.0"
style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
<PasswordField fx:id="passwordField" maxWidth="320.0" prefHeight="30.0" prefWidth="320.0" style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
</children>
</VBox>

Expand All @@ -164,23 +122,13 @@
<Font size="12.0" />
</font>
</Label>
<PasswordField fx:id="confirmPasswordField"
maxWidth="320.0"
prefWidth="320.0"
prefHeight="30.0"
style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
<PasswordField fx:id="confirmPasswordField" maxWidth="320.0" prefHeight="30.0" prefWidth="320.0" style="-fx-background-color: #F2F2F2; -fx-background-radius: 4; -fx-border-radius: 4; -fx-padding: 0 0 0 8; -fx-font-size: 10px;" />
</children>
</VBox>

<Region prefHeight="6.0" />

<Button mnemonicParsing="false"
onAction="#handleCreateAccount"
prefHeight="34.0"
prefWidth="320.0"
maxWidth="320.0"
style="-fx-background-color: #1F4FD8; -fx-text-fill: white; -fx-background-radius: 18; -fx-font-size: 12px;"
text="Create Account" />
<Button maxWidth="320.0" mnemonicParsing="false" onAction="#handleCreateAccount" prefHeight="34.0" prefWidth="320.0" style="-fx-background-color: #1F4FD8; -fx-text-fill: white; -fx-background-radius: 18; -fx-font-size: 12px;" text="Create Account" />

<HBox alignment="CENTER" spacing="6.0">
<children>
Expand All @@ -189,10 +137,7 @@
<Font size="10.0" />
</font>
</Label>
<Button mnemonicParsing="false"
onAction="#switchToLoginPage"
style="-fx-background-color: transparent; -fx-text-fill: #1F4FD8; -fx-padding: 0;"
text="Login">
<Button mnemonicParsing="false" onAction="#switchToLoginPage" style="-fx-background-color: transparent; -fx-text-fill: #1F4FD8; -fx-padding: 0;" text="Login">
<font>
<Font size="10.0" />
</font>
Expand All @@ -212,6 +157,6 @@

<!-- FOOTER -->
<!-- Pull in the navbar from components with its own controller -->
<fx:include fx:id="footer" source="components/footer.fxml"/>
<fx:include fx:id="footer" source="components/footer.fxml" />
</children>
</GridPane>
</GridPane>

0 comments on commit 3e298b9

Please sign in to comment.