Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/SP1' into SP1/#566-cart-…
Browse files Browse the repository at this point in the history
…page-api
  • Loading branch information
gunom committed Dec 6, 2023
2 parents eca55ef + 687e204 commit a4db805
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 158 deletions.
24 changes: 24 additions & 0 deletions src/common/Modal/DeleteCartModal/DeleteCartModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ModalPortal from '../ModalPortal';
import EscapeModalForm from '../EscapeModal/EscapeModalForm';

interface DeleteCartModalProps {
setModalOn: React.Dispatch<React.SetStateAction<boolean>>;
}

const DeleteCartModal = ({ setModalOn }: DeleteCartModalProps) => {
return (
<ModalPortal>
<EscapeModalForm
onClose={() => setModalOn(false)}
pageName={'CartPage'}
title={'선택한 상품을 삭제하시나요?'}
subTitle={'삭제하시면 결제 대상에서'}
subTitle2={'해당 상품이 제외돼요'}
continueBtn={'삭제하기'}
stopBtn={'그만하기'}
/>
</ModalPortal>
);
};

export default DeleteCartModal;
19 changes: 17 additions & 2 deletions src/common/Modal/EscapeModal/EscapeModalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ const EscapeModalForm = ({
}: EscapeModalFormProps) => {
const navigate = useNavigate();

const handleClickContinueBtn = () => {
onClose();
switch (pageName) {
case 'CartPage':
// 아이템 삭제 로직 추가
break;

default:
break;
}
};

const handleClickStopBtn = () => {
onClose();
switch (pageName) {
// 페이지 이름과 라우팅 주소는 나중에 보고 수정
case 'LoginPage':
navigate('/');
removeAccessToken();
Expand All @@ -43,6 +54,10 @@ const EscapeModalForm = ({
navigate('/onboarding');
break;

case 'CartPage':
navigate('/cart');
break;

default:
navigate('/');
break;
Expand All @@ -60,7 +75,7 @@ const EscapeModalForm = ({
</St.ModalTitleWrapper>

<St.BtnWrapper>
<St.ContinueBtn onClick={onClose}>{continueBtn}</St.ContinueBtn>
<St.ContinueBtn onClick={handleClickContinueBtn}>{continueBtn}</St.ContinueBtn>
<St.StopBtn onClick={handleClickStopBtn}>{stopBtn}</St.StopBtn>
</St.BtnWrapper>
</St.ModalContent>
Expand Down
20 changes: 0 additions & 20 deletions src/common/Modal/WelcomeModal/WelcomeModal.tsx

This file was deleted.

130 changes: 0 additions & 130 deletions src/common/Modal/WelcomeModal/WelcomeModalForm.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/components/Cart/CartBottom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const St = {
color: ${({ theme }) => theme.colors.gray8};
`,
LightBorder: styled.hr`
width: 100%;
max-width: 43rem;
height: 1.3rem;
border: none;
background-color: ${({ theme }) => theme.colors.gray0};
Expand All @@ -34,6 +36,7 @@ const St = {
position: fixed;
bottom: 7rem;
width: 100%;
max-width: 43rem;
`,
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Cart/CartFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const St = {
position: fixed;
bottom: 0;
width: 100%;
max-width: 43rem;
height: 7rem;
`,

Expand Down
8 changes: 7 additions & 1 deletion src/components/Cart/CartItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import styled from 'styled-components';
import { IcCancelDark, IcMinus, IcMinusOneunder, IcPlus } from '../../assets/icon';
import { useState } from 'react';
import DeleteCartModal from '../../common/Modal/DeleteCartModal/DeleteCartModal';

const CartItem = ({ id, name, price, originalPrice }) => {
const [count, setCount] = useState(1);
const [modalOn, setModalOn] = useState(false);

const CartItem = ({
id,
Expand Down Expand Up @@ -46,7 +51,8 @@ const CartItem = ({
</St.TitleSection>
</St.ItemInformation>
<St.ButtonSection>
<IcCancelDark />
<IcCancelDark onClick={() => setModalOn(true)} />
{modalOn && <DeleteCartModal setModalOn={setModalOn} />}
<St.Stepper>
{quantity === 1 ? (
<IcMinusOneunder />
Expand Down
5 changes: 0 additions & 5 deletions src/page/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import SideMenu from '../common/SideMenu';
import HotCustom from '../common/HotCustom';
import Toast from '../common/ToastMessage/Toast';
import { useLocation } from 'react-router';
import WelcomeModal from '../common/Modal/WelcomeModal/WelcomeModal';
import ChargePointCompleteModal from '../common/Modal/ChargePointModal/ChargePointCompleteModal';
import MainArticle from '../components/MainPage/MainArticle';

Expand All @@ -26,9 +25,6 @@ const MainPage = () => {

const location = useLocation();

const [isWelcomeModalOpen, setIsWelcomeModalOpen] = useState(
location.state?.isWellcomeModalOpen || false,
);
const [isPointModalOpen, setIsPointModalOpen] = useState(
location.state?.isPointModalOpen || false,
);
Expand Down Expand Up @@ -76,7 +72,6 @@ const MainPage = () => {
renderHeader={reanderMainPageHeader}
footer={<MainFooter isFooterVisible={isFooterVisible} />}
>
{isWelcomeModalOpen && <WelcomeModal setModalOn={setIsWelcomeModalOpen} />}
<MainBanner />
<HotCustom isList={false} />
<MainEventBanner setToast={setToast} />
Expand Down

0 comments on commit a4db805

Please sign in to comment.