Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#71] 쿠폰 수정 , 삭제 공통 모달 구현 #78

Merged
merged 3 commits into from
Jan 22, 2024
Merged
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
9 changes: 6 additions & 3 deletions src/api/lib/getCouponList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const getCouponList = async (
status,
title
};
const response = await instance.get(`/v1/coupons/${accommodationId}`, {
params
});
const response = await instance.get(
`/v1/accommodations/${accommodationId}/coupons`,
{
params
}
);
return response.data;
};

Expand Down
117 changes: 117 additions & 0 deletions src/components/modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import styled from '@emotion/styled';
import theme from '@styles/theme';
import { useState } from 'react';

export interface ModalProps {
modalText: string;
subText: boolean;
onConfirmClick(): void;
}

const Modal = ({ modalText, subText, onConfirmClick }: ModalProps) => {
const [isShowModal, setIsShowModal] = useState(true);
const [isShowSubText] = useState(true);

const handleModalClose = () => {
setIsShowModal(false);
};

const handleConfirmClick = () => {
onConfirmClick;
handleModalClose();
};

return isShowModal ? (
<ModalContainer>
<ModalWrap>
<ModalText>{modalText}</ModalText>
{isShowSubText && <ModalSubText>{subText}</ModalSubText>}
<ButtonWrap>
<ConfirmButton onClick={handleConfirmClick}>확인</ConfirmButton>
<CancelButton onClick={handleModalClose}>취소</CancelButton>
</ButtonWrap>
</ModalWrap>
</ModalContainer>
) : null;
};

export default Modal;

const ModalContainer = styled.div`
position: fixed;
z-index: 1;
top: 0;
left: 0;

width: 100%;
height: 100%;

background: var(--Back-Ground, rgba(66, 66, 66, 0.5));
`;

const ModalWrap = styled.div`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-40%, -50%);

width: 517px;
height: 228px;

border-radius: 16px;

display: flex;
flex-direction: column;
align-items: center;
justify-content: center;

background: var(--Main-Color-White, #fff);
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
`;

const ModalText = styled.div`
margin-top: 69px;

color: #404446;
font-size: 15px;
font-weight: 500;
line-height: 22px; /* 146.667% */
`;

const ModalSubText = styled.div`
color: #da1e28;
font-size: 15px;
font-weight: 700;
line-height: 22px;
`;

const ButtonWrap = styled.div`
display: flex;
gap: 16px;

margin-top: 38px;
margin-bottom: 33px;
`;

const ConfirmButton = styled.button`
width: 158px;
height: 44px;

border-radius: 12px;
border: none;

color: ${theme.colors.white};
background: #1a2849;
cursor: pointer;
`;
const CancelButton = styled.button`
width: 158px;
height: 44px;

border-radius: 12px;
border: none;

color: ${theme.colors.white};
background: #b1b1b1;
cursor: pointer;
`;