Skip to content
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

Pull Request #16

Open
wants to merge 6 commits into
base: user-signup-starter
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'org.springframework.boot' version '2.4.4'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}

group = 'org.launchcode'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '13'
sourceCompatibility = '11'

configurations {
developmentOnly
Expand All @@ -22,6 +22,7 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.launchcode.spaday.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
Expand All @@ -12,31 +11,13 @@ public class SpaDayController {

public boolean checkSkinType(String skinType, String facialType) {
if (skinType.equals("oily")) {
if (facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating")) {
return true;
}
else {
return false;
}
return facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating");
}
else if (skinType.equals("combination")) {
if (facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating") || facialType.equals("Enzyme Peel")) {
return true;
}
else {
return false;
}
}
else if (skinType.equals("normal")) {
return true;
return facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating") || facialType.equals("Enzyme Peel");
}
else if (skinType.equals("dry")) {
if (facialType.equals("Rejuvenating") || facialType.equals("Hydrofacial")) {
return true;
}
else {
return false;
}
return facialType.equals("Rejuvenating") || facialType.equals("Hydrofacial");
}
else {
return true;
Expand All @@ -46,7 +27,7 @@ else if (skinType.equals("dry")) {
@GetMapping(value="")
@ResponseBody
public String customerForm () {
String html = "<form method = 'post'>" +
String html = "<form method = 'post' action='menu'>" +
"Name: <br>" +
"<input type = 'text' name = 'name'>" +
"<br>Skin type: <br>" +
Expand All @@ -60,34 +41,45 @@ public String customerForm () {
"<select name = 'manipedi'>" +
"<option value = 'manicure'>Manicure</option>" +
"<option value = 'pedicure'>Pedicure</option>" +
"<option value = 'both'>Mani/Pedi</option>" +
"</select><br>" +
"<input type = 'submit' value = 'Submit'>" +
"</form>";
return html;
}

@PostMapping(value="")
@PostMapping(value="/menu")
public String spaMenu(@RequestParam String name, @RequestParam String skintype, @RequestParam String manipedi, Model model) {
String cap = skintype.substring(0, 1).toUpperCase() + skintype.substring(1);

ArrayList<String> facials = new ArrayList<String>();
ArrayList<String> facials = new ArrayList<>();
facials.add("Microdermabrasion");
facials.add("Hydrofacial");
facials.add("Rejuvenating");
facials.add("Enzyme Peel");

ArrayList<String> appropriateFacials = new ArrayList<String>();
ArrayList<String> appropriateFacials = new ArrayList<>();
for (int i = 0; i < facials.size(); i ++) {
if (checkSkinType(skintype,facials.get(i))) {
appropriateFacials.add(facials.get(i));
}
}

model.addAttribute("name" , name);
model.addAttribute("skintype", cap);
model.addAttribute("facials", facials);
model.addAttribute("appropriateFacials", appropriateFacials);
ArrayList<String> polishChoices = new ArrayList<>();
polishChoices.add("#000000");
polishChoices.add("#162252");
polishChoices.add("#2E0854");
polishChoices.add("#8B3626");
polishChoices.add("#A02422");
polishChoices.add("#E79EA9");

model.addAttribute("polishChoices", polishChoices);

model.addAttribute("name", name);
model.addAttribute("skintype",skintype);
model.addAttribute("manipedi", manipedi);
model.addAttribute("appropriateFacials", appropriateFacials);


return "menu";
}
}
32 changes: 20 additions & 12 deletions src/main/resources/templates/menu.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en" xmlns:th = "http://www.thymeleaf.org/">
<head>
<meta charset="UTF-8" />
Expand All @@ -9,31 +9,39 @@
<h1>My Super Fancy Spa</h1>
<div id = "clientProfile">
<h2>My Profile</h2>
<p th:text = "${name}"></p>
<p th:text = "${skintype}"></p>
<p th:text = "${manipedi}"></p>
<p th:text="${name}"></p>
<p th:text="${skintype}"></p>
<p th:text="${manipedi}"></p>
</div>
<div id = "servicesMenu">
<h2>Menu of Available Services</h2>
<div>
<h3>Facial Treatments</h3>
<p>The below facial treatments are recommended by our estheticians for your given skin type.</p>
<p>Our esteticians reccomend the following for your skin type:</p>

<table>
<th:block th:each = "facial : ${appropriateFacials}">
<th:block th:each="service : ${appropriateFacials}">
<tr>
<td th:text = "${facial}"></td>
<td th:text="${service}"></td>
</tr>
</th:block>

</table>
</div>
<div th:if = "${manipedi == 'manicure'}">
<div th:if="${manipedi.equals('manicure')} or ${manipedi.equals('both')}">
<h3>Manicure</h3>
<p th:replace = "fragments :: manicureDescription"></p>
<p th:replace="~{fragments :: manicureDescription}"></p>
</div>
<div th:if = "${manipedi == 'pedicure'}">
<div th:if="${manipedi.equals('pedicure')} or ${manipedi.equals('both')}">
<h3>Pedicure</h3>
<p th:replace = "fragments :: pedicureDescription"></p>
<p th:replace="~{fragments :: pedicureDescription}"></p>
</div>
</div>

<footer>
<div>Choose a color for your manicure or pedicure </div>
<div th:each = "option : ${polishChoices}">
<div th:style = "'background: ' + ${option}"></div>
</div>
</footer>
</body>
</html>