Skip to content

Commit

Permalink
Merge pull request #112 from TEAM-SYLUV/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
seokkkkkk authored Aug 6, 2024
2 parents 8e0713c + dc323b4 commit e2c2a28
Show file tree
Hide file tree
Showing 13 changed files with 686 additions and 307 deletions.
7 changes: 7 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import PayCallback from "utils/PayCallback";
import OrderRequest from "utils/OrderRequest";
import OrderResult from "pages/OrderResult";
import QRredirection from "utils/QRredirection";
import ErrorPage from "pages/ErrorPage";
import FeedBack from "pages/FeedBack";

const App = () => {
useEffect(() => {
Expand Down Expand Up @@ -104,6 +106,11 @@ const App = () => {
path="/qr/redirection/:marketId/:storeId"
element={<QRredirection />}
/>
<Route path="/error" element={<ErrorPage />} />
<Route
path="/feedback"
element={<FeedBack />}
/>
</Routes>
</BrowserRouter>
</MobileContainer>
Expand Down
27 changes: 19 additions & 8 deletions src/components/Common/ButtonModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ const ButtonModal = ({
<div className="title-text">{title}</div>
<div className="sub-text">{subText}</div>
<div className="buttons">
<ModalButton onClick={() => onLeftClick()}>
{left}
</ModalButton>
<ModalButton onClick={() => onRightClick()}>
{right}
</ModalButton>
{left && (
<ModalButton onClick={() => onLeftClick()}>
{left}
</ModalButton>
)}
{right && (
<ModalButton onClick={() => onRightClick()}>
{right}
</ModalButton>
)}
</div>
</ModalContainer>
</>
Expand All @@ -34,19 +38,20 @@ const Overlay = styled.div`
top: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5); // Semi-transparent black
z-index: 5; // Ensure it's below the modal but above other content
z-index: 120; // Ensure it's below the modal but above other content
width: 480px;
@media (max-width: 480px) {
width: 100dvw;
}
`;

const ModalContainer = styled.div`
min-width: 380px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
z-index: 121;
background-color: white;
border-radius: 5px;
display: flex;
Expand All @@ -70,13 +75,19 @@ const ModalContainer = styled.div`
font-weight: ${({ theme }) => theme.fontWeight.bold};
color: ${({ theme }) => theme.color.gray900};
margin-bottom: 20px;
text-align: center;
}
.sub-text {
font-size: 20px;
color: ${({ theme }) => theme.color.primary};
font-weight: ${({ theme }) => theme.fontWeight.bold};
margin-bottom: 20px;
text-align: center;
}
@media (max-width: 480px) {
min-width: 80dvw;
}
`;

Expand Down
57 changes: 40 additions & 17 deletions src/owner/components/OwnerHeader.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,53 @@
import styled from "styled-components";
import { useNavigate } from "react-router-dom";
import useSyluvAxios from "hooks/useSyluvAxios";
import { useEffect, useState } from "react";
import { ReactComponent as Syluv } from "assets/images/syluv-small.svg";
import { useState } from "react";
import ButtonModal from "components/Common/ButtonModal";

const OwnerHeader = ({ name, stores }) => {
const navigate = useNavigate();
const storeData = stores || [];
const [openModal, setOpenModal] = useState(false);

const handleSelectStore = (storeId) => {
navigate(`/owner/${storeId}`);
};

return (
<Header>
<div className="title">{name}</div>
<select
onChange={(e) => handleSelectStore(e.target.value)}
defaultValue=""
>
<option value="" disabled>
가게 이동
</option>
{storeData.map((store) => (
<option key={store.storeId} value={store.storeId}>
{store.name}
<>
<Header>
<div className="title">
<Syluv
cursor={"pointer"}
onClick={() => setOpenModal(true)}
/>
{name}
</div>
<select
onChange={(e) => handleSelectStore(e.target.value)}
defaultValue=""
>
<option value="" disabled>
가게 이동
</option>
))}
</select>
</Header>
{storeData.map((store) => (
<option key={store.storeId} value={store.storeId}>
{store.name}
</option>
))}
</select>
</Header>
{openModal && (
<ButtonModal
title="일반 사용자 뷰 방문하기"
subText="홈으로 이동하시겠습니까?"
left="이동"
right="취소"
onLeftClick={() => navigate("/")}
onRightClick={() => setOpenModal(false)}
/>
)}
</>
);
};

Expand All @@ -45,6 +65,9 @@ const Header = styled.div`
margin-left: 22px;
font-size: 20px;
font-weight: ${({ theme }) => theme.fontWeight.bold};
display: flex;
align-items: center;
gap: 12px;
}
select {
Expand Down
1 change: 1 addition & 0 deletions src/owner/pages/OwnerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const Header = styled.div`
@media (max-width: 480px) {
width: 100%;
}
z-index: 10;
`;

const Wrapper = styled.div`
Expand Down
14 changes: 10 additions & 4 deletions src/pages/CartPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import StoreList from "components/Cart/StoreList";
import useSyluvAxios from "hooks/useSyluvAxios";
import { useEffect, useState, useCallback } from "react";
import Toast from "components/Common/Toast";
import { useNavigate } from "react-router-dom";

const CartPage = () => {
const syluvAxios = useSyluvAxios();
const [cartList, setCartList] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const [rightDisabled, setRightDisabled] = useState(true);
const [toastMessage, setToastMessage] = useState("");
const navigate = useNavigate();

useEffect(() => {
const getCartList = async () => {
Expand All @@ -21,10 +23,12 @@ const CartPage = () => {
}));
setCartList(updatedCartList);
setIsLoading(false);
} catch (err) {}
} catch (err) {
navigate("/error", { replace: true });
}
};
getCartList();
}, []);
}, [navigate]);

useEffect(() => {
const isAnyItemChecked = cartList.some((item) => item.isChecked);
Expand All @@ -44,9 +48,11 @@ const CartPage = () => {
);
setToastMessage("장바구니에서 메뉴가 삭제되었습니다.");
})
.catch((err) => {});
.catch((err) => {
navigate("/error", { replace: true });
});
});
}, [cartList, syluvAxios]);
}, [cartList, syluvAxios, navigate]);

const closeToast = useCallback(() => {
setToastMessage("");
Expand Down
34 changes: 34 additions & 0 deletions src/pages/ErrorPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import ButtonModal from "components/Common/ButtonModal";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";

const ErrorPage = () => {
const navigate = useNavigate();
return (
<Wrapper>
<ButtonModal
title="문제가 발생했습니다"
subText="서비스 개선을 위해 노력하겠습니다"
left="홈으로"
right="피드백하기"
onLeftClick={() => navigate("/", { replace: true })}
onRightClick={() => navigate("/feedback", { replace: true })}
/>
</Wrapper>
);
};

export default ErrorPage;

const Wrapper = styled.div`
height: 100dvh;
width: 480px;
display: flex;
justify-content: center;
align-items: center;
@media (max-width: 480px) {
width: 100dvw;
}
`;
Loading

0 comments on commit e2c2a28

Please sign in to comment.