Skip to content
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
58 changes: 9 additions & 49 deletions src/main/java/org/launchcode/controllers/SpaDayController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.launchcode.controllers;

import org.launchcode.models.Client;
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 @@ -9,59 +11,17 @@
@Controller
public class SpaDayController {

public boolean checkSkinType(String skinType, String facialType) {
if (skinType.equals("oily")) {
return facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating");
}
else if (skinType.equals("combination")) {
return facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating") || facialType.equals("Enzyme Peel");
}
else if (skinType.equals("dry")) {
return facialType.equals("Rejuvenating") || facialType.equals("Hydrofacial");
}
else {
return true;
}
}

@GetMapping(value="")
@ResponseBody
@GetMapping
public String customerForm () {
String html = "<form method = 'post'>" +
"Name: <br>" +
"<input type = 'text' name = 'name'>" +
"<br>Skin type: <br>" +
"<select name = 'skintype'>" +
"<option value = 'oily'>Oily</option>" +
"<option value = 'combination'>Combination</option>" +
"<option value = 'normal'>Normal</option>" +
"<option value = 'dry'>Dry</option>" +
"</select><br>" +
"Manicure or Pedicure? <br>" +
"<select name = 'manipedi'>" +
"<option value = 'manicure'>Manicure</option>" +
"<option value = 'pedicure'>Pedicure</option>" +
"</select><br>" +
"<input type = 'submit' value = 'Submit'>" +
"</form>";
return html;
return "serviceSelection";
}

@PostMapping(value="")
public String spaMenu(@RequestParam String name, @RequestParam String skintype, @RequestParam String manipedi, Model model) {

ArrayList<String> facials = new ArrayList<>();
facials.add("Microdermabrasion");
facials.add("Hydrofacial");
facials.add("Rejuvenating");
facials.add("Enzyme Peel");
@PostMapping
public String spaMenu(@RequestParam String skintype, @RequestParam String manipedi, Model model) {

ArrayList<String> appropriateFacials = new ArrayList<>();
for (int i = 0; i < facials.size(); i ++) {
if (checkSkinType(skintype,facials.get(i))) {
appropriateFacials.add(facials.get(i));
}
}
Client newClient = new Client(skintype, manipedi);
newClient.setAppropriateFacials(skintype);
model.addAttribute("client" , newClient);

return "menu";
}
Expand Down
82 changes: 82 additions & 0 deletions src/main/java/org/launchcode/models/Client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.launchcode.models;

import java.util.ArrayList;

public class Client {

private String skinType;
private String nailService;
private ArrayList<String> appropriateFacials = new ArrayList<>();

public Client(String skinType, String nailService) {
this.skinType = skinType;
this.nailService = nailService;
}

public String getSkinType() {
return skinType;
}

public void setSkinType(String skinType) {
this.skinType = skinType;
}

public String getNailService() {
return nailService;
}

public void setNailService(String nailService) {
this.nailService = nailService;
}

public ArrayList<String> getAppropriateFacials() {
return appropriateFacials;
}

private boolean checkSkinType(String skinType, String facialType) {
if (skinType.equals("oily")) {
if (facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating")) {
return true;
}
else {
return false;
}
}
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;
}
else if (skinType.equals("dry")) {
if (facialType.equals("Rejuvenating") || facialType.equals("Hydrofacial")) {
return true;
}
else {
return false;
}
}
else {
return true;
}
}

public void setAppropriateFacials(String skinType) {
ArrayList<String> facials = new ArrayList<String>();
facials.add("Microdermabrasion");
facials.add("Hydrofacial");
facials.add("Rejuvenating");
facials.add("Enzyme Peel");

for (int i = 0; i < facials.size(); i ++) {
if (checkSkinType(skinType,facials.get(i))) {
appropriateFacials.add(facials.get(i));
}
}
}
}
23 changes: 23 additions & 0 deletions src/main/resources/templates/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,31 @@
<body>
<h1>My Super Fancy Spa</h1>
<div id = "clientProfile">
<h2>My Profile</h2>
<p th:text = "${client.skinType}"></p>
<p th:text = "${client.nailService}"></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>
<table>
<th:block th:each = "facial : ${client.appropriateFacials}">
<tr>
<td th:text = "${facial}"></td>
</tr>
</th:block>
</table>
</div>
<div th:if = "${client.nailService == 'manicure'}">
<h3>Manicure</h3>
<p th:replace = "fragments :: manicureDescription"></p>
</div>
<div th:if = "${client.nailService == 'pedicure'}">
<h3>Pedicure</h3>
<p th:replace = "fragments :: pedicureDescription"></p>
</div>
</div>
</body>
</html>
30 changes: 30 additions & 0 deletions src/main/resources/templates/serviceSelection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en" xmlns:th = "http://www.thymeleaf.org/">
<head>
<meta charset="UTF-8">
<title>Select Your Spa Services</title>
<link href="../static/css/styles.css" th:href="@{/css/styles.css}" rel="stylesheet" />
</head>
<body>
<form method = 'post'>

<label>
Skin type:
<select name = 'skintype'>
<option value = 'oily'>Oily</option>
<option value = 'combination'>Combination</option>
<option value = 'normal'>Normal</option>
<option value = 'dry'>Dry</option>
</select>
</label>
<label>
Manicure or Pedicure?
<select name = 'manipedi'>
<option value = 'manicure'>Manicure</option>
<option value = 'pedicure'>Pedicure</option>
</select>
</label>
<input type = 'submit' value = 'Submit'>
</form>
</body>
</html>