Skip to content

Commit

Permalink
refactor: 백과 프론트 도메인을 맞추기 위한 수정
Browse files Browse the repository at this point in the history
- 프론트의 amount => quantity, glass => quantity unit
  • Loading branch information
toneyparky committed Feb 24, 2021
1 parent 832923c commit a541df5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 54 deletions.
13 changes: 0 additions & 13 deletions front/src/component/userCocktail/GlassItem.js

This file was deleted.

4 changes: 2 additions & 2 deletions front/src/component/userCocktail/Ingredient.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const Ingredient = ({ setStage }) => {
{ ingredientId: selected.id, ingredientName: selected.name },
],
});
history.push("/my-cocktail/glass");
setStage("glass");
history.push("/my-cocktail/quantity-unit");
setStage("quantity-unit");
};

const ingredients = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { useHistory } from "react-router-dom";
import { useRecoilState } from "recoil";
import { userCocktailState } from "../../recoil";
import div from "infinite-react-carousel";
import GlassItem from "./GlassItem";

const Amount = ({ setStage }) => {
const Quantity = ({ setStage }) => {
const history = useHistory();
const [userCocktail, setUserCocktail] = useRecoilState(userCocktailState);
const [selected, setSelected] = useState({ id: 0, name: "기본값" });
Expand All @@ -23,10 +22,10 @@ const Amount = ({ setStage }) => {
{
ingredientId: lastRecipe.ingredientId,
ingredientName: lastRecipe.ingredientName,
glassId: lastRecipe.id,
glassName: lastRecipe.glassName,
amountId: selected.id,
amountName: selected.name,
quantityUnitId: lastRecipe.quantityUnitId,
quantityUnitName: lastRecipe.quantityUnitName,
quantityId: selected.id,
quantityName: selected.name,
},
],
});
Expand Down Expand Up @@ -54,7 +53,7 @@ const Amount = ({ setStage }) => {

return (
<div>
<div>amount 화면입니다.</div>
<div>quantity 화면입니다.</div>
<div>
<div>{selected.name}</div>
<button>X</button>
Expand All @@ -69,18 +68,18 @@ const Amount = ({ setStage }) => {
{"잔 종류: " +
userCocktail.userRecipeItemRequests[
userCocktail.userRecipeItemRequests.length - 1
].glassName}
].quantityUnitName}
</div>
<div>
{/*Slider로 수정*/}
{units &&
units.map((it, index) => (
<div
className="amount-unit-container"
className="quantity-unit-container"
onClick={onSelect}
key={"amount" + index}
key={"quantity" + index}
>
<div className="amount-unit" data-id={it.id}>
<div className="quantity-unit" data-id={it.id}>
{it.name}
</div>
</div>
Expand All @@ -93,4 +92,4 @@ const Amount = ({ setStage }) => {
);
};

export default Amount;
export default Quantity;
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useHistory } from "react-router-dom";
import { useRecoilState } from "recoil";
import div from "infinite-react-carousel";
import { userCocktailState } from "../../recoil";
import GlassItem from "./GlassItem";
import QuantityUnitItem from "./QuantityUnitItem";

const Glass = ({ setStage }) => {
const QuantityUnit = ({ setStage }) => {
const history = useHistory();
const [userCocktail, setUserCocktail] = useRecoilState(userCocktailState);
const [selected, setSelected] = useState({ id: 0, name: "기본값" });
Expand All @@ -23,16 +23,16 @@ const Glass = ({ setStage }) => {
{
ingredientId: lastRecipe.ingredientId,
ingredientName: lastRecipe.ingredientName,
glassId: selected.id,
glassName: selected.name,
quantityUnitId: selected.id,
quantityUnitName: selected.name,
},
],
});
history.push("/my-cocktail/amount");
setStage("amount");
history.push("/my-cocktail/quantity");
setStage("quantity");
};

const glasses =
const quantityUnits =
// api로 받아오든 내부에 있는 값을 가져오든 해야한다.
// 값도 바뀌어야 한다. 백에서 원하는 SOJU BEER PAPER SHOT PIECE를 가지고 이미지 링크와 한글 이름이 필요하다.
[
Expand All @@ -45,13 +45,13 @@ const Glass = ({ setStage }) => {

const onSelect = (e) => {
const selectedId = e.target.dataset.id;
const found = glasses.find((it) => it.id === parseInt(selectedId));
const found = quantityUnits.find((it) => it.id === parseInt(selectedId));
setSelected(found);
};

return (
<div className="glass-container">
<div>glass 화면입니다.</div>
<div className="quantity-unit-container">
<div>quantity unit 화면입니다.</div>
<div>
<div>{selected.name}</div>
<button>X</button>
Expand All @@ -64,9 +64,9 @@ const Glass = ({ setStage }) => {
</div>
<div>
{/*Slider로 수정*/}
{glasses &&
glasses.map((it) => (
<GlassItem glass={it} key={it.id} onSelect={onSelect} />
{quantityUnits &&
quantityUnits.map((it) => (
<QuantityUnitItem unitItem={it} key={it.id} onSelect={onSelect} />
))}
</div>
<button className="next-button" type="submit" onClick={onNext}>
Expand All @@ -76,4 +76,4 @@ const Glass = ({ setStage }) => {
);
};

export default Glass;
export default QuantityUnit;
13 changes: 13 additions & 0 deletions front/src/component/userCocktail/QuantityUnitItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

const QuantityUnitItem = ({ unitItem, onSelect }) => {
return (
<div className="quantity-unit-item-container" onClick={onSelect}>
<div className="quantity-unit-item" data-id={unitItem.id}>
{unitItem.name}
</div>
</div>
);
};

export default QuantityUnitItem;
2 changes: 1 addition & 1 deletion front/src/component/userCocktail/Recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Recipe = ({ setStage }) => {

const recipe = userCocktail.userRecipeItemRequests.map((it, index) => (
<div key={"recipe" + index}>
{it.ingredientName} {it.glassName} {it.amountName}
{it.ingredientName} {it.quantityUnitName} {it.quantityName}
<button onClick={removeRecipe} data-id={index}>
X
</button>
Expand Down
19 changes: 9 additions & 10 deletions front/src/component/userCocktail/UserCocktail.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useEffect, useState } from "react";
import React, { useState } from "react";
import StepProgressBar from "./StepProgressBar";
import "react-step-progress-bar/styles.css";
import "../../css/userCocktail/userCocktail.css";
import Question from "./Question";
import Name from "./Name";
import Ingredient from "./Ingredient";
import Glass from "./Glass";
import Amount from "./Amount";
import Quantity from "./Quantity";
import Recipe from "./Recipe";
import List from "./UserCocktailItems";
import QuantityUnit from "./QuantityUnit";
import UserCocktailItems from "./UserCocktailItems";

const UserCocktail = () => {
Expand All @@ -23,10 +22,10 @@ const UserCocktail = () => {
return <Name setStage={setStage} />;
case "ingredients":
return <Ingredient setStage={setStage} />;
case "glass":
return <Glass setStage={setStage} />;
case "amount":
return <Amount setStage={setStage} />;
case "quantity-unit":
return <QuantityUnit setStage={setStage} />;
case "quantity":
return <Quantity setStage={setStage} />;
case "recipe":
return <Recipe setStage={setStage} />;
}
Expand All @@ -40,9 +39,9 @@ const UserCocktail = () => {
return 0;
case "ingredients":
return 25;
case "glass":
case "quantity-unit":
return 50;
case "amount":
case "quantity":
return 75;
case "recipe":
return 100;
Expand Down
6 changes: 4 additions & 2 deletions front/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ export const USER_COCKTAIL_PROTOTYPE = {
// {
// ingredientId: "",
// ingredientName: "",
// quantityUnit: "",
// quantity: "",
// quantityUnitId: "",
// quantityUnitName: "",
// quantityId: "",
// quantityName: "",
// },
],
description: "",
Expand Down

0 comments on commit a541df5

Please sign in to comment.