Skip to content

update the view of the registration #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,16 @@
<scope>test</scope>
</dependency>


<!--<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>-->
</dependencies>



<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.csaba79coder.littersnap.model.user.dto.UserRegistrationModel;
import com.csaba79coder.littersnap.model.user.service.UserService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
Expand All @@ -21,15 +20,18 @@ public class RegistrationViewController {

@GetMapping("/registration")
public String showRegistrationForm(Model model) {
model.addAttribute("userRegistrationModel", new UserRegistrationModel());
return "registration";
UserRegistrationModel tempModel = new UserRegistrationModel();
model.addAttribute("userRegistrationModel", tempModel );
model.addAttribute("view","signUp_form");
return "index";
}

@PostMapping("/registration")
public String registerUser(@ModelAttribute("userRegistrationModel") @Valid UserRegistrationModel registrationModel,
public String registerUser(@ModelAttribute("userRegistrationModel") UserRegistrationModel registrationModel,
BindingResult bindingResult) {

if (bindingResult.hasErrors()) {
return "registration";
return "signUp_form";
}

// Create a User object from the registration model and save it using the UserService
Expand All @@ -38,3 +40,5 @@ public String registerUser(@ModelAttribute("userRegistrationModel") @Valid UserR
return "redirect:/index"; // Redirect to the index page after successful registration
}
}


4 changes: 4 additions & 0 deletions src/main/resources/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ body {
z-index: 999;
}

/*SignUp form*/
.signup-form-container{
max-width: 600px;
}
/*Image redendering size controll*/
.image-container {
max-width: 350px; /* Set the maximum width for the image container */
Expand Down
24 changes: 18 additions & 6 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,27 @@
data-bs-target="#signInModal">
SignIn
</button>
<button class="btn btn-warning btn-sm btn-block m-1" data-bs-toggle="modal"
data-bs-target="#signUpModal">
SignUp
</button>
<a th:href="@{/thy/security/registration}" class="btn btn-warning btn-sm btn-block m-1" >SignUp</a>
</div>
</div>

<div th:replace="~{signIn_form}"></div>
<!-- Modal -->
<!-- Container for dynamic content -->
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-6">
<!-- Dynamic content placeholder -->
<div th:if="~{${view}}" class="row m-4">
<div class="col">
<!-- Dynamic Content Placeholder -->
<div th:insert="~{${view}}"></div>
</div>
</div>
</div>
</div>
</div>

<div th:replace="~{signIn_form}"></div>
<div th:replace="~{signUp_form}"></div>

<!-- Middle Part -->
<div class="row justify-content-center align-items-center min-vh-100">
Expand Down
32 changes: 0 additions & 32 deletions src/main/resources/templates/registration.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/templates/signIn_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h5 class="modal-title" id="signInModalLabel">Sign In</h5>
<a th:href="@{/thy/auth/admin/litters}" class="btn btn-primary mt-3">SignIn</a>
</form>
<div class="text-center mt-3">
<p>Don't have an account? <a href="#signUpModal" data-bs-toggle="modal"
<p>Don't have an account? <a th:href="@{/thy/security/registration}" data-bs-toggle="modal"
data-bs-dismiss="modal">Sign Up</a></p>
</div>
</div>
Expand Down
65 changes: 32 additions & 33 deletions src/main/resources/templates/signUp_form.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
<div class="modal fade" id="signUpModal" tabindex="-1" aria-labelledby="signUpModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal header -->
<div class="modal-header">
<h5 class="modal-title" id="signUpModalLabel">Sign Up</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<div class="container mt-4 bg-white ">
<div class="row">
<div class="col">
<div class="my-3">
<h3>Registration Form</h3>
<p>Please fill out the following information:</p>
</div>
<form th:action="@{/thy/security/registration}" method="post" th:object="${userRegistrationModel}">
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
<span th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></span>
</div>
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" class="form-control" id="firstName" name="firstName" required>
<span th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}"></span>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
<span th:if="${#fields.hasErrors('password')}" th:errors="*{password}"></span>
</div>
<div class="form-group">
<label for="confirmPassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
<span th:if="${#fields.hasErrors('passwordConfirmation')}" th:errors="*{passwordConfirmation}"></span>
</div>
<button type="submit" class="btn btn-primary m-3">Sign Up</button>

</form>

<!-- Modal body -->
<div class="modal-body">
<div class="d-flex justify-content-center">
<div class="sign-up-container">
<form th:action="@{/thy/security/signup}" method="post">
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" class="form-control" id="firstName" name="firstName" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="form-group">
<label for="confirmPassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
</div>
<button type="submit" class="btn btn-primary mt-3">Sign Up</button>
</form>

</div>
</div>
</div>
</div>
</div>
</div>


43 changes: 0 additions & 43 deletions src/main/resources/templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,6 @@
</div>
</nav>







<!-- Hamburger button-->
<!-- <div class="row justify-content-end m-3">-->
<!-- <div class="btn-group col-12 col-md-4 col-lg-2 fixed-buttons">-->
<!-- <div class="d-flex align-items-center">-->
<!-- <div class="me-2">Welcome, <span th:text="Csaba"></span></div>-->
<!-- <div class="dropdown">-->
<!-- <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"-->
<!-- data-bs-toggle="dropdown" aria-expanded="false">-->
<!-- <i class="fas fa-bars"></i>-->
<!-- </button>-->
<!-- <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">-->
<!-- <li><a class="dropdown-item" >Logout</a></li>-->
<!-- <li><a class="dropdown-item" th:href="@{/thy/litter}">View Reports</a></li>-->
<!-- <li><a class="dropdown-item" th:href="@{/thy/users}">User List</a></li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->




<!--Getting the input and populating the addlitter-->
<!-- <div class="row justify-content-center mt-10">-->
<!-- <div class="col-12 col-md-7 col-lg-6">-->
<!-- <form th:action="@{/thy/litter/create}" method="get" class="d-flex">-->
<!-- <div class="form-group flex-grow-1">-->
<!-- <input type="text" class="form-control" id="cityInput" name="city"-->
<!-- placeholder="Enter the city..." required>-->
<!-- </div>-->
<!-- <button type="submit" class="btn btn-primary btn-sm-md">Add Litter</button>-->
<!-- </form>-->
<!-- </div>-->
<!-- </div>-->


<!-- Container for dynamic content -->
<div class="container mt-4 bg-white">
<div class="row">
Expand Down