diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..e9e14d996 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +package.json +yarn.lock +BE +DOCS \ No newline at end of file diff --git a/BE/README.md b/BE/README.md new file mode 100644 index 000000000..93efa8432 --- /dev/null +++ b/BE/README.md @@ -0,0 +1 @@ +## 이 폴더에 BE 소스 파일 추가 하면 됩니다. diff --git a/DOCS/Database/Schema.mwb b/DOCS/Database/Schema.mwb new file mode 100644 index 000000000..245a441f7 Binary files /dev/null and b/DOCS/Database/Schema.mwb differ diff --git a/DOCS/Database/Schema.png b/DOCS/Database/Schema.png new file mode 100644 index 000000000..8744fe24a Binary files /dev/null and b/DOCS/Database/Schema.png differ diff --git a/DOCS/README.md b/DOCS/README.md new file mode 100644 index 000000000..df33853cf --- /dev/null +++ b/DOCS/README.md @@ -0,0 +1 @@ +## 이 폴더에 문서 파일 추가 하면 됩니다. diff --git a/FE/.gitignore b/FE/.gitignore new file mode 100644 index 000000000..67d496e6e --- /dev/null +++ b/FE/.gitignore @@ -0,0 +1,31 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +node_module +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +/**/package.json +/**/package-lock.json +/**/yarn.lock +public +README.old.md +.gittignore + diff --git a/FE/README.md b/FE/README.md new file mode 100644 index 000000000..02aac3f6e --- /dev/null +++ b/FE/README.md @@ -0,0 +1,70 @@ +# Getting Started with Create React App + +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.\ +You will also see any lint errors in the console. + +### `yarn test` + +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.\ +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.\ +Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `yarn eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). + +### Code Splitting + +This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) + +### Analyzing the Bundle Size + +This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) + +### Making a Progressive Web App + +This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) + +### Advanced Configuration + +This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) + +### Deployment + +This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) + +### `yarn build` fails to minify + +This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) diff --git a/FE/public/favicon.ico b/FE/public/favicon.ico new file mode 100644 index 000000000..a11777cc4 Binary files /dev/null and b/FE/public/favicon.ico differ diff --git a/FE/public/index.html b/FE/public/index.html new file mode 100644 index 000000000..aa069f27c --- /dev/null +++ b/FE/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + React App + + + +
+ + + diff --git a/FE/public/logo192.png b/FE/public/logo192.png new file mode 100644 index 000000000..fc44b0a37 Binary files /dev/null and b/FE/public/logo192.png differ diff --git a/FE/public/logo512.png b/FE/public/logo512.png new file mode 100644 index 000000000..a4e47a654 Binary files /dev/null and b/FE/public/logo512.png differ diff --git a/FE/public/manifest.json b/FE/public/manifest.json new file mode 100644 index 000000000..080d6c77a --- /dev/null +++ b/FE/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/FE/public/robots.txt b/FE/public/robots.txt new file mode 100644 index 000000000..e9e57dc4d --- /dev/null +++ b/FE/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/FE/src/App.js b/FE/src/App.js new file mode 100644 index 000000000..683bdfa2b --- /dev/null +++ b/FE/src/App.js @@ -0,0 +1,37 @@ +import React, { useState } from "react"; +import Main from "./Components/Main/Main"; +import Header from "./Components/Header/Header"; +import All from "./Components/All/All"; +import Best from "./Components/Best/Best"; + +const App = () => { + const [modal, setModal] = useState(false); + const [ModalData, setModalData] = useState([]); + const [loginModal, setLoginModal] = useState(false); + + return ( +
+
+ +
+ +
+ ); +}; + +export default App; diff --git a/FE/src/Components/All/All.js b/FE/src/Components/All/All.js new file mode 100644 index 000000000..894222734 --- /dev/null +++ b/FE/src/Components/All/All.js @@ -0,0 +1,136 @@ +import React, { useState, useEffect, useRef } from "react"; +import styled from "styled-components"; +import axios from "axios"; +import Carousel from "../Carousel/Carousel"; +import PopUpModal from "../PopUpModal/PopUpModal"; +import CarouselButton from "../Carousel/CarouselButton"; +const All = ({ modal, setModal, ModalData, setModalData }) => { + const [Soup, setSoup] = useState([]); + const [Side, setSide] = useState([]); + const [rander, setRander] = useState(false); + const soupImageRef = useRef(); + const sideImageRef = useRef(); + const soupRef = useRef(); + const sideRef = useRef(); + + useEffect(() => { + const fetchData = async () => { + const soupData = await axios + .get("/products/soup") + .then((res) => res.data.data.items); + const sideData = await axios + .get("/products/side") + .then((res) => res.data.data.items); + setSoup(soupData); + setSide(sideData); + }; + fetchData(); + }, []); // eslint-disable-line + + const randerImage = () => { + rander ? setRander(false) : setRander(true); + }; + + const soupSlide = (e) => { + e.target.classList.contains("Left") + ? soupRef.current.Slider(1) + : soupRef.current.Slider(-1); + }; + + const sideSlide = (e) => { + e.target.classList.contains("Left") + ? sideRef.current.Slider(1) + : sideRef.current.Slider(-1); + }; + + const PopUpCarousel = () => { + for (const i of Soup) { + if (i.detailHash === ModalData[0]) { + return ( + + ); + } + } + return ( + + ); + }; + + return ( + + {rander && ( +
+ {modal && PopUpCarousel()} + + + + + + + + + + +
+ )} + + {rander ? "끄기" : "모든 카테고리 보기"} + +
+ ); +}; + +const AllBox = styled.div``; +const CarouselSlide = styled.div` + margin-top: 77px; + padding: 0 35px; + display: flex; + display: flex; + justify-content: center; + align-items: center; +`; + +const PlusButton = styled.button` + margin-top: 120px; + width: 1440px; + height: 100px; + background-color: #f5f5f7; + + font-style: normal; + font-weight: bold; + font-size: 18px; + line-height: 26px; + &:active { + transform: translateY(2px); + } +`; + +export default All; diff --git a/FE/src/Components/Best/Best.js b/FE/src/Components/Best/Best.js new file mode 100644 index 000000000..1a00ccbb3 --- /dev/null +++ b/FE/src/Components/Best/Best.js @@ -0,0 +1,71 @@ +import React, { useState, useEffect } from "react"; +import styled from "styled-components"; +import TabContent from "./TabContent"; +import TabButton from "./TabButton"; +import axios from "axios"; + +const BestTitle = styled.h2` + margin-top: 80px; + margin-bottom: 32px; +`; + +const TabCotainer = styled.div` + display: flex; + flex-direction: column; + position: relative; + width: 100%; + height: 678px; + background-color: transparent; + margin: auto 0; + word-break: break-all; + border-top: 0px; +`; + +const Box = styled.div` + width: 1280px; + margin: 0 auto; +`; + +const Best = ({ modal, setModal, ModalData, setModalData }) => { + const [toggleState, setToggleState] = useState(1); + + const toggleTab = (index) => { + setToggleState(index); + }; + + //fetch + const [Best, setBest] = useState([]); + + useEffect(() => { + const fetchData = async () => { + const data = await axios("/products/best").then((res) => res.data.data); + setBest(data); + }; + fetchData(); + }, []); // eslint-disable-line + + return ( + + 후기가 증명한 베스트 반찬 + + + + + + ); +}; + +export default Best; diff --git a/FE/src/Components/Best/TabButton.js b/FE/src/Components/Best/TabButton.js new file mode 100644 index 000000000..31abd1894 --- /dev/null +++ b/FE/src/Components/Best/TabButton.js @@ -0,0 +1,47 @@ +import React from "react"; +import styled from "styled-components"; + +// 탭들 영역 +const TabsBlock = styled.div` + display: flex; + flex-direction: row; + align-items: flex-start; +`; + +const Btn = styled.button` + font-size: 18px; + border: none; +`; + +const TabBtn = styled(Btn)` + background-color: ${(props) => (props.active ? "#eef4fa;" : "#f5f5f7")}; + border-radius: 5px 5px 0px 0px; + padding: 16px 32px; + text-align: center; + margin-right: 8px; + cursor: pointer; + box-sizing: content-box; + position: relative; + outline: none; +`; + +const TabButton = ({ Food, setFood, toggleState, toggleTab }) => { + return ( + + {Food.map((v, idx) => { + return ( + toggleTab(idx + 1)} + > + {v.name} + + ); + })} + + ); +}; + +export default TabButton; diff --git a/FE/src/Components/Best/TabContent.js b/FE/src/Components/Best/TabContent.js new file mode 100644 index 000000000..c77467cc9 --- /dev/null +++ b/FE/src/Components/Best/TabContent.js @@ -0,0 +1,78 @@ +import React from "react"; +import styled from "styled-components"; +import CarouselCard from "../Carousel/CarouselCard"; +import PopUpModal from "../PopUpModal/PopUpModal"; + +const ContentWrapper = styled.div` + display: ${(props) => (props.active ? "flex" : "none")}; + /* align-items: center; */ + justify-content: center; + background-color: #eef4fa; + border-radius: 0px 5px 5px 5px; + /* padding: 40px; */ + width: 100%; + height: 100%; +`; + +const CardBlock = styled.div` + display: flex; + justify-content: space-between; +`; + +const ContentContainer = styled.div` + height: 620px; + flex-grow: 1; +`; + +const TabContent = ({ + Food, + toggleState, + modal, + setModal, + ModalData, + setModalData, +}) => { + const Modal = () => { + let result = Food.map((v) => v.items).reduce( + (acc, cur) => (acc = acc.concat(cur)) + ); + for (const i of result) { + if (i.detailHash === ModalData[0]) { + return ( + + ); + } + } + return null; + }; + return ( + + {modal && Modal()} + {Food.map((_, idx) => { + return ( + + + {Food[idx].items.map((v, idx) => { + return ( + + ); + })} + + + ); + })} + + ); +}; + +export default TabContent; diff --git a/FE/src/Components/Carousel/Carousel.js b/FE/src/Components/Carousel/Carousel.js new file mode 100644 index 000000000..61a7c8b1c --- /dev/null +++ b/FE/src/Components/Carousel/Carousel.js @@ -0,0 +1,145 @@ +import React, { + useState, + useEffect, + forwardRef, + useImperativeHandle, +} from "react"; +import styled from "styled-components"; +import CarouselCard from "./CarouselCard"; +const Carousel = ( + { PopUp, MainTitle, Food, setFood, Ref, setModal, setModalData }, + ref +) => { + const virtualImage = PopUp ? Food : Food.slice(Food.length - 4, Food.length); // 마지막부분 4개의 사진을 복사하여 0~4번 이미지를 만들어준다. + const transitionDefault = `all 0.5s ease-in-out`; + const panelWidth = PopUp ? 180 : 325; + const panelCount = PopUp ? 5 : 4; + const [X, setX] = useState(0); + const [moving, setMoving] = useState(false); + const [transitionValue, setTransitionValue] = useState(transitionDefault); + + useImperativeHandle(ref, () => ({ + Slider, + })); + + useEffect(() => { + if (transitionValue === "none") setTransitionValue(transitionDefault); + }, [X]); // eslint-disable-line + + const Slider = (direction) => { + if (PopUp) { + if (moving) return; + setX((prevX) => + prevX + ? prevX + direction * panelWidth * panelCount + : direction * panelWidth * panelCount + ); + setMoving(true); + } else { + if (moving) return; + setX((prevX) => + prevX + ? prevX + direction * panelWidth * panelCount + : direction * panelWidth * panelCount + ); + setMoving(true); + } + }; + + const onTransitionEnd = () => { + if (!PopUp) { + setMoving(false); + setTransitionValue("none"); + const first = Food.slice(4, Food.length); + const result = first.concat(Food.slice(0, 4)); + setFood(result); + setX(0); + } + }; + + return ( + + {MainTitle} + { + + + {virtualImage + .concat(PopUp ? [] : Food) + .map( + ( + { + detailHash, + image, + alt, + deliveryType, + title, + description, + nprice, + sprice, + badge, + }, + index + ) => { + return ( + + ); + } + )} + + + } + + ); +}; + +const Box = styled.div` + width: ${({ PopUp }) => (PopUp ? `900px` : `1280px`)}; + margin: ${({ PopUp }) => (PopUp ? `0px` : `80px auto 0`)}; + z-index: ${({ PopUp }) => (PopUp ? `2` : `1`)}; +`; + +const CarouselTitle = styled.div` + width: 350px; + height: 35px; + margin: ${({ PopUp }) => (PopUp ? `10px 0` : `0 0 40px 0 `)}; + + font-style: normal; + font-weight: bold; + font-size: 24px; + line-height: 35px; +`; + +const CarouselImage = styled.div` + display: flex; + justify-content: center; + overflow: hidden; +`; + +const Image = styled.div` + transform: ${({ PopUp, X }) => + PopUp ? `translateX(${X - 100}px)` : `translateX(${X}px)`}; + transition: ${({ transitionValue }) => transitionValue}; + display: flex; +`; + +export default forwardRef(Carousel); diff --git a/FE/src/Components/Carousel/CarouselButton.js b/FE/src/Components/Carousel/CarouselButton.js new file mode 100644 index 000000000..5631e8f37 --- /dev/null +++ b/FE/src/Components/Carousel/CarouselButton.js @@ -0,0 +1,50 @@ +import React, { useState } from "react"; +import styled from "styled-components"; +import { + BeforeRight, + AfterRight, + BeforeLeft, + AfterLeft, +} from "../../Svg/Button"; + +const CarouselButton = ({ PopUp, Name, Slide }) => { + const [Right, setRight] = useState(BeforeRight); + const [Left, setLeft] = useState(BeforeLeft); + + const MouseEnter = (e) => { + e.target.classList.contains("Left") + ? setLeft(AfterLeft) + : setRight(AfterRight); + }; + + const MouseLeave = (e) => { + e.target.classList.contains("Left") + ? setLeft(BeforeLeft) + : setRight(BeforeRight); + }; + + return ( + + ); +}; + +const Button = styled.button` + margin: ${({ PopUp }) => (PopUp ? `0px` : `170px 0 0 0`)}; + z-index: ${({ PopUp }) => (PopUp ? `3` : `1`)}; + background-color: transparent; + border: none; + outline: none; + height: 50px; + &:active { + transform: translateY(2px); + } +`; +export default CarouselButton; diff --git a/FE/src/Components/Carousel/CarouselCard.js b/FE/src/Components/Carousel/CarouselCard.js new file mode 100644 index 000000000..22049c5d6 --- /dev/null +++ b/FE/src/Components/Carousel/CarouselCard.js @@ -0,0 +1,161 @@ +import React from "react"; +import styled from "styled-components"; +const CarouselCard = ({ + detailHash, + PopUp, + image, + alt, + deliveryType, + title, + description, + n_price, + s_price, + badge, + setModal, + setModalData, + best, +}) => { + const openModal = () => { + setModalData([detailHash, title, badge]); + setModal(true); + }; + + return ( + + + {title} + {description} + {n_price !== undefined ? ( + + {s_price} + {n_price} + + ) : ( + {s_price} + )} + {badge !== undefined && + badge.length !== 0 && + (badge.length <= 1 ? ( + {badge} + ) : ( + + + {badge[0]} + + + {badge[1]} + + + ))} + + ); +}; +const Price = styled.div` + margin-top: 10px; +`; + +const ContentMain = styled.div` + margin: 10px; + align-self: ${({ best }) => (best ? `center` : null)}; +`; + +const Image = styled.div` + cursor: pointer; + background-image: ${({ image }) => `url(${image})`}; + background-size: cover; + background-repeat: no-repeat; + width: ${({ best, PopUp }) => (best ? `384px` : PopUp ? `160px` : `305px`)}; + height: ${({ best, PopUp }) => (best ? `384px` : PopUp ? `160px` : `305px`)}; + border-radius: 5px; + &:hover { + display: flex; + justify-content: center; + align-items: center; + background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), + ${({ image }) => `url(${image})`}; + background-size: cover; + background-repeat: no-repeat; + text-align: center; + color: white; + &::before { + position: absolute; + top: ${({ best, PopUp }) => (best ? `270px` : PopUp ? `50px` : `125px`)}; + font-size: 22px; + font-weight: normal; + content: "새벽배송"; + } + &::after { + background-color: transparent; + width: 82px; + height: 0.1px; + border: 1px solid white; + line-height: 50px; + font-size: 22px; + content: "전국택배"; + } + } +`; + +const Title = styled.div` + margin-top: 16px; + + font-style: normal; + font-weight: normal; + font-size: 16px; + line-height: 23px; + color: #333333; +`; + +const Description = styled.div` + margin-top: 8px; + color: #828282; + + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 20px; +`; +const NPrice = styled.span` + width: 48px; + + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 20px; + text-decoration-line: line-through; + color: #bdbdbd; + margin: 0 8px; +`; + +const SPrice = styled.span` + width: 73px; + + font-style: normal; + font-weight: bold; + font-size: 20px; + line-height: 29px; + margin: 0 8px 0 0; +`; + +const Badge = styled.span` + padding: 0; + display: flex; + justify-content: center; + align-items: center; + flex-direction: row; + padding: ${({ PopUp }) => (PopUp ? `0` : `4px 16px`)}; + width: ${({ PopUp }) => (PopUp ? `80px` : `100px`)}; + height: 25px; + background-color: ${({ badge }) => + badge == "이벤트특가" ? "#82d32d" : "#86C6FF"}; + border-radius: 5px; + color: white; + font-size: 14px; + line-height: 20px; + margin: ${({ PopUp }) => (PopUp ? `0` : `0 10px 0 0`)}; + font-weight: bold; +`; +const BadgeBox = styled.div` + display: flex; +`; +export default CarouselCard; diff --git a/FE/src/Components/Header/Header.js b/FE/src/Components/Header/Header.js new file mode 100644 index 000000000..5cf091cd4 --- /dev/null +++ b/FE/src/Components/Header/Header.js @@ -0,0 +1,183 @@ +import React, { useState } from "react"; +import styled from "styled-components"; +import { FaSearch } from "react-icons/fa"; +import Login from "./login"; + +const HeaderMain = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + min-width: 1100px; + width: 1280px; + margin: 0 auto; + height: 122px; +`; +const MainNav = styled.ul` + display: flex; + list-style: none; + align-items: center; +`; +const HeaderList = styled.li` + cursor: pointer; + background-color: transparent; + outline: none; + border: none; + margin-left: 20px; + font-size: 20px; +`; +const HeaderLeft = styled.div` + display: flex; + align-items: center; +`; +const Logo = styled.h1` + font-size: 40px; +`; +const MainInput = styled.input` + width: 80%; + outline: none; + background-color: #f0f0f0; + border: none; +`; + +const Search = styled.div` + width: 150px; + background-color: #f0f0f0; + padding: 0px 5px; + border-radius: 10px; + display: flex; +`; + +const SearchBtn = styled.button` + padding: 7px; + border: 0; +`; +const DropMenu1 = styled.ul` + position: absolute; + top: 70%; + left: 10%; + list-style: none; + text-align: left; +`; +const DropMenu2 = styled.ul` + position: absolute; + top: 70%; + left: 10%; + list-style: none; + text-align: left; +`; +const DropMenu3 = styled.ul` + position: absolute; + top: 70%; + left: 10%; + list-style: none; + text-align: left; +`; +const MenuBtn = styled.button` + border: 0; + outline: 0; + background-color: transparent; + font-size: 20px; + padding: 30px 0; + position: relative; +`; +const DropBtn = styled.button` + border: 0; + outline: 0; + background-color: transparent; + font-size: 15px; + color: gray; + &:hover { + color: black; + text-decoration: underline; + } +`; +const DropList = styled.li``; + +const Header = ({ loginModal, setLoginModal }) => { + const [isShownDrop1, setIsShownDrop1] = useState(false); + const [isShownDrop2, setIsShownDrop2] = useState(false); + const [isShownDrop3, setIsShownDrop3] = useState(false); + + const openLoginModal = () => { + setLoginModal(true); + }; + + return ( + + + BANCHAN + + + setIsShownDrop1(true)} + onMouseLeave={() => setIsShownDrop1(false)} + > + 든든한 메인 요리 + {isShownDrop1 && ( + + + 육류 요리 + + + 해산물 요리 + + + )} + + + + setIsShownDrop2(true)} + onMouseLeave={() => setIsShownDrop2(false)} + > + 뜨끈한 국물요리 + {isShownDrop2 && ( + + + 국탕찌개 + + + )} + + + + setIsShownDrop3(true)} + onMouseLeave={() => setIsShownDrop3(false)} + > + 정갈한 밑반찬 + {isShownDrop3 && ( + + + 나물/무침 + + + 조림/볶음 + + + 절임/장아찌 + + + )} + + + + + + + + + + + + + + {loginModal && } + 로그인 + 장바구니 + + + ); +}; + +export default Header; diff --git a/FE/src/Components/Header/login.js b/FE/src/Components/Header/login.js new file mode 100644 index 000000000..743015d40 --- /dev/null +++ b/FE/src/Components/Header/login.js @@ -0,0 +1,42 @@ +import React from "react"; +import styled from "styled-components"; + +const login = ({ setLoginModal }) => { + return ( + + + + + + ); +}; + +const ModalBackground = styled.div` + position: fixed; + z-index: 3; + width: 100%; + height: 100%; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: rgba(0, 0, 0, 0.3); + display: flex; + justify-content: center; + align-items: center; +`; +const ModalCard = styled.div` + position: fixed; + top: 300px; + display: flex; + width: 500px; + height: 660px; + background-color: transparent; +`; + +const Card = styled.div` + width: 960px; + background-color: white; +`; + +export default login; diff --git a/FE/src/Components/Main/Main.js b/FE/src/Components/Main/Main.js new file mode 100644 index 000000000..d9afeb827 --- /dev/null +++ b/FE/src/Components/Main/Main.js @@ -0,0 +1,73 @@ +import React, { useState, useEffect, useRef } from "react"; +import styled from "styled-components"; +import axios from "axios"; +import Carousel from "../Carousel/Carousel"; +import PopUpModal from "../PopUpModal/PopUpModal"; +import CarouselButton from "../Carousel/CarouselButton"; +const Main = ({ modal, setModal, ModalData, setModalData }) => { + const [Food, setFood] = useState([]); + const mainRef = useRef(null); + const foodRef = useRef(); + + // 꼭 fetchData를 useEffect 안에 넣어놔야 하는가? + useEffect(() => { + const fetchData = async () => { + const data = await axios + .get("/products/main") + .then((res) => res.data.data.items); + setFood(data); + }; + fetchData(); + }, []); // eslint-disable-line + + const leftSlider = () => { + foodRef.current.Slider(1); + }; + + const rightSlider = () => { + foodRef.current.Slider(-1); + }; + + const PopUpCarousel = () => { + for (const i of Food) { + if (i.detailHash === ModalData[0]) { + return ( + + ); + } + } + return null; + }; + + return ( + + {modal && PopUpCarousel()} + + + + + ); +}; + +const CarouselSlide = styled.div` + display: flex; + margin: 77px auto 0; + width: 1370px; + align-items: center; +`; + +export default Main; diff --git a/FE/src/Components/PopUpModal/PopUpModal.js b/FE/src/Components/PopUpModal/PopUpModal.js new file mode 100644 index 000000000..2afe962a6 --- /dev/null +++ b/FE/src/Components/PopUpModal/PopUpModal.js @@ -0,0 +1,516 @@ +import React, { useState, useEffect, useRef } from "react"; +import styled from "styled-components"; +import { + BeforeX, + AfterX, + BeforeDown, + AfterDown, + BeforeUp, + AfterUp, +} from "../../Svg/Button"; +import axios from "axios"; +import CarouselButton from "../Carousel/CarouselButton"; +import Carousel from "../Carousel/Carousel"; + +const PopUpModal = ({ + MainTitle, + Food, + setModal, + ModalData, + setModalData, + best, +}) => { + const [PopUpCarousel, setPopUpCarousel] = useState(Food); + const [close, setClose] = useState(BeforeX); + const [detail, setDetail] = useState(); + const [Up, setUp] = useState(BeforeUp); + const [Down, setDown] = useState(BeforeDown); + const [quantity, setQuantity] = useState(0); + const [toggleState, setToggleState] = useState(); + const [imgState, setState] = useState(1); + const PopUpRef = useRef(null); + const PopUpCardRef = useRef(); + + useEffect(() => { + const fetchData = async () => { + const data = await axios(`products/detail/${ModalData[0]}`).then( + (res) => res.data.data + ); + setDetail(data); + }; + fetchData(); + }, [setDetail, ModalData[0]]); // eslint-disable-line + + const MouseEnter = (e) => { + if (detail.stock !== 0) { + if (e.target.classList.contains("Up")) setUp(AfterUp); + if (e.target.classList.contains("Down")) setDown(AfterDown); + if (e.target.classList.contains("close")) setClose(AfterX); + } + }; + const MouseLeave = (e) => { + if (e.target.classList.contains("Up")) setUp(BeforeUp); + if (e.target.classList.contains("Down")) setDown(BeforeDown); + if (e.target.classList.contains("close")) setClose(BeforeX); + }; + const Click = () => { + setModal(false); + }; + const quantityCheck = (e) => { + if (e.target.classList.contains("Up")) setQuantity(quantity + 1); + if (quantity >= 1) { + if (e.target.classList.contains("Down")) setQuantity(quantity - 1); + } + }; + + const Calculate = () => { + if (detail.prices.length === 1) { + return numberWithCommas(quantity * detail.prices[0]); + } + if (detail.prices.length === 2) { + return numberWithCommas(quantity * detail.prices[1]); + } + }; + + const numberWithCommas = (x) => { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + }; + + const toggleImg = (v) => { + setState(0); + setToggleState(v); + }; + const apiPost = async () => { + //수량 받아서 그만큼 -된 값을 반환하기. + await axios.post(`/order`, { + productHash: `${ModalData[0]}`, + count: `${quantity}`, + }); + }; + + const leftSlider = () => { + PopUpCardRef.current.Slider(1); + }; + + const rightSlider = () => { + PopUpCardRef.current.Slider(-1); + }; + + return ( + + + + + {detail && ( + <> + + toggleImg(detail.topImage)} + src={imgState === 1 ? detail.topImage : toggleState} + /> + + {detail.thumbImages.map((v, idx) => ( + toggleImg(v)} + /> + ))} + + + + + {ModalData[1]} + {detail.productDescription} + {ModalData[2] !== undefined && + ModalData[2].length !== 0 && + ModalData[2].length <= 1 ? ( + {ModalData[2]} + ) : null} + {detail.prices[1]} + {detail.prices[0]} + + + + + 적립금 + {detail.point} + + + 배송정보 + + {detail.deliveryInfo} + + + + 배송비 + + {detail.deliveryFee} + + + + + + 수량 + + {quantity} + + + {Up} + + + {Down} + + + + + + + + {detail.stock === 0 ? "" : "총 주문금액"} + + + {detail.stock === 0 ? "일시품절" : `${Calculate()}원`} + + + + {detail.stock === 0 ? "일시품절" : "주문하기"} + + + + )} + + {best ? null : ( + + + {Food && ( + + )} + + )} + + + {close} + + + + ); +}; + +const Button = styled.div` + position: absolute; + display: flex; + float: right; + width: 70px; + height: 50px; + justify-content: space-between; + align-items: center; + right: 60px; +`; +const CarouselSlide = styled.div` + position: relative; + width: 960px; + height: 440px; + display: flex; + justify-content: center; + background-color: #f5f5f7; +`; + +const OrderButton = styled.button` + position: absolute; + width: 440px; + height: 58px; + background: ${({ detail }) => (detail.stock === 0 ? `#E0E0E0` : `#82d32d`)}; + color: ${({ detail }) => (detail.stock === 0 ? `#BDBDBD` : `#ffffff`)}; + box-shadow: 0px 0px 4px rgba(204, 204, 204, 0.5), + 0px 2px 4px rgba(0, 0, 0, 0.25); + backdrop-filter: blur(4px); + border-radius: 5px; + border: none; + + font-style: normal; + font-weight: bold; + font-size: 18px; + line-height: 26px; + /* identical to box height */ + text-align: center; +`; +const AllMoney = styled.div` + font-style: normal; + font-weight: bold; + font-size: 32px; + line-height: 46px; + width: 160px; + text-align: right; +`; +const MoneyTitle = styled.div` + font-style: normal; + font-weight: bold; + font-size: 18px; + line-height: 26px; + color: #828282; +`; +const Finish = styled.div` + display: flex; + justify-content: flex-end; + align-items: center; + width: 440px; + padding: 20px 0; +`; +const DownButton = styled.button` + pointer-events: ${({ stock }) => (stock === 0 ? `none` : null)}; + display: block; + width: 30px; + height: 25px; + border: 1px solid #e0e0e0; + background-color: white; + outline: none; + padding: 0; + margin: 0; + &:active { + transform: translateY(0.5px); + } +`; +const UpButton = styled.button` + pointer-events: ${({ stock }) => (stock === 0 ? `none` : null)}; + display: block; + width: 30px; + height: 25px; + border: 1px solid #e0e0e0; + background-color: white; + outline: none; + padding: 0; + margin: 0; + &:active { + transform: translateY(0.5px); + } +`; + +const Counter = styled.div` + display: flex; + justify-content: center; + height: 50px; +`; +const CounterButton = styled.div` + height: 23px; +`; +const Number = styled.div` + display: flex; + justify-content: center; + align-items: center; + padding: 8px 0; + border: 1px solid #e0e0e0; + border-right: none; + margin: 0; + width: 60px; +`; + +const ProductCounter = styled.div` + display: flex; + justify-content: space-between; + align-items: center; + padding: 25px 0; + width: 440px; +`; +const ImageInformation = styled.div` + padding-bottom: 28px; + width: 440px; +`; +const Information = styled.div` + padding: 24px 0; + width: 440px; + + font-style: normal; + font-weight: normal; + font-size: 16px; + line-height: 23px; +`; +const InformationTitle = styled.div` + color: #828282; + width: 60px; + margin-right: 16px; +`; +const InformationContent = styled.div` + color: #4f4f4f; + word-break: normal; + width: 360px; +`; +const Subheading = styled.div` + display: flex; + ${({ middle }) => (middle ? "padding:16px 0;" : null)} +`; + +const Divider = styled.div` + width: 440px; + height: 1px; + border: 1px solid #e0e0e0; +`; + +const ModalContent = styled.div` + position: absolute; + top: 48px; + left: 480px; +`; + +const ImageBox = styled.div` + position: absolute; + left: 48px; + top: 48px; +`; +const Mini = styled.div` + position: absolute; + display: flex; +`; +const MiniImage = styled.img` + padding: 4px; + width: 72px; + height: 72px; +`; +const Badge = styled.span` + padding: 4px 16px; + width: 100px; + height: 18px; + background-color: ${({ children }) => + children == "이벤트특가" ? "#82d32d" : "#86C6FF"}; + border-radius: 5px; + color: white; + font-size: 14px; + line-height: 20px; + margin-right: 10px; +`; +const Nprice = styled.span` + ${({ props }) => + props.length === 1 + ? `width: 73px; + + font-style: normal; + font-weight: bold; + font-size: 20px; + line-height: 29px; + margin: 0 8px 0 0;` + : `width: 48px; + + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 20px; + text-decoration-line: line-through; + color: #bdbdbd; + margin: 0 8px;`} +`; +const Sprice = styled.span` + width: 73px; + + font-style: normal; + font-weight: bold; + font-size: 20px; + line-height: 29px; + margin: 0 8px 0 0; +`; +const Title = styled.div` + font-size: 24px; + + font-style: normal; + font-weight: bold; +`; +const Description = styled.div` + font-style: normal; + font-weight: normal; + font-size: 18px; + color: #828282; + padding: 16px 0 23px 0; +`; +const Image = styled.img` + width: 392px; + height: 392px; +`; + +const ModalBackground = styled.div` + position: fixed; + z-index: 3; + width: 100%; + height: 100%; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: rgba(0, 0, 0, 0.3); + display: flex; + justify-content: center; + align-items: center; +`; +const ModalCard = styled.div` + position: fixed; + display: flex; + justify-content: center; + align-items: center; + width: 1000px; + background-color: transparent; +`; +const Card = styled.div` + width: 960px; + background-color: white; +`; + +const Content = styled.div` + position: relative; + display: flex; + width: 960px; + height: 660px; + background-color: white; +`; + +const CloseButton = styled.button` + position: absolute; + height: 30px; + right: -5px; + top: 0px; + display: flex; + justify-content: center; + &:active { + transform: translateY(2px); + } + color: white; + background-color: transparent; + border: none; + outline: none; +`; + +export default PopUpModal; diff --git a/FE/src/Svg/Button.js b/FE/src/Svg/Button.js new file mode 100644 index 000000000..8722caf0e --- /dev/null +++ b/FE/src/Svg/Button.js @@ -0,0 +1,215 @@ +export const BeforeRight = ( + + + +); + +export const AfterRight = ( + + + +); + +export const BeforeLeft = ( + + + +); + +export const AfterLeft = ( + + + +); + +export const BeforeX = ( + + + + +); + +export const AfterX = ( + + + + +); + +export const BeforeUp = ( + + + +); + +export const AfterUp = ( + + + +); + +export const BeforeDown = ( + + + +); + +export const AfterDown = ( + + + +); diff --git a/FE/src/index.css b/FE/src/index.css new file mode 100644 index 000000000..ee5fd5c4a --- /dev/null +++ b/FE/src/index.css @@ -0,0 +1,22 @@ +html { + width: 1440px; + margin: auto; +} +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} diff --git a/FE/src/index.js b/FE/src/index.js new file mode 100644 index 000000000..00be67611 --- /dev/null +++ b/FE/src/index.js @@ -0,0 +1,17 @@ +import React from "react"; +import ReactDOM from "react-dom"; +import "./index.css"; +import App from "./App"; +// import reportWebVitals from './reportWebVitals'; + +ReactDOM.render( + + + , + document.getElementById("root") +); + +// If you want to start measuring performance in your app, pass a function +// to log results (for example: reportWebVitals(console.log)) +// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals +// reportWebVitals(); diff --git a/FE/src/setupProxy.js b/FE/src/setupProxy.js new file mode 100644 index 000000000..3645c5c07 --- /dev/null +++ b/FE/src/setupProxy.js @@ -0,0 +1,15 @@ +const { createProxyMiddleware } = require("http-proxy-middleware"); +const cors = require("cors"); + +// src/setupProxy.js +module.exports = function (app) { + app.use( + cors( + "/api", + createProxyMiddleware({ + target: "http://3.35.230.0:8080", + changeOrigin: true, + }) + ) + ); +};