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

[Feat/#372] 예매 조회 페이지 취소 상태 추가 #376

Merged
merged 9 commits into from
Aug 31, 2024
11 changes: 11 additions & 0 deletions src/constants/bookingStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const bookingStatusText = {
CHECKING_PAYMENT: "입금 확인 예정",
BOOKING_CONFIRMED: "입금 완료",
BOOKING_CANCELLED: "예매 취소",
};

export type bookingStatusTypes = keyof typeof bookingStatusText;

export interface DefaultDepositProps {
$status;
}
1 change: 1 addition & 0 deletions src/pages/lookup/Lookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface LookupProps {
accountNumber: string;
accountHolder: string;
dueDate: number;
bookingStatus: string;
isPaymentCompleted: boolean;
createdAt: string;
posterImage: string;
Expand Down
29 changes: 19 additions & 10 deletions src/pages/lookup/components/LookupCard.styled.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from "styled-components";
import styled, { css } from "styled-components";
import { IconArrowRight } from "@assets/svgs";
import { DefaultDepositProps } from "@constants/bookingStatus";

export const LookupCardWrapper = styled.section`
display: flex;
Expand Down Expand Up @@ -91,18 +92,26 @@ export const DepositLayout = styled.section`
justify-content: center;
`;

export const CheckingDeposit = styled.div`
export const CheckingDeposit = styled.div<DefaultDepositProps>`
display: flex;
${({ $status }) => {
switch ($status) {
case "CHECKING_PAYMENT":
return css`
color: ${({ theme }) => theme.colors.yellow_400};
`;
case "BOOKING_CONFIRMED":
return css`
color: ${({ theme }) => theme.colors.green};
`;
case "BOOKING_CANCELLED":
return css`
color: ${({ theme }) => theme.colors.red};
`;
}
}}

${({ theme }) => theme.fonts["caption2-medi"]};
color: ${({ theme }) => theme.colors.red};
`;

export const CheckedDeposit = styled.div`
display: flex;

${({ theme }) => theme.fonts["caption2-medi"]};
color: ${({ theme }) => theme.colors.green};
`;

export const AccountLayout = styled.button`
Expand Down
13 changes: 6 additions & 7 deletions src/pages/lookup/components/LookupCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useModal } from "@hooks";
import BankAccount from "@pages/test/modalTest/BankAccount";
import { getBankNameKr } from "@utils/getBankName";
import { bookingStatusText, bookingStatusTypes } from "@constants/bookingStatus";
import { useNavigate } from "react-router-dom";
import { LookupProps } from "../types/lookupType";
import * as S from "./LookupCard.styled";
Expand All @@ -13,12 +14,12 @@ const LookupCard = ({
scheduleNumber,
performanceVenue,
purchaseTicketCount,
isPaymentCompleted,
bankName,
bookerName,
accountHolder,
accountNumber,
dueDate,
bookingStatus,
totalPaymentAmount,
}: LookupProps) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -89,14 +90,12 @@ const LookupCard = ({
<S.Context>
<S.SubTitle>입금상태</S.SubTitle>
<S.DepositLayout>
{isPaymentCompleted ? (
<S.CheckedDeposit>입금 완료</S.CheckedDeposit>
) : (
<S.CheckingDeposit>입금 확인 중</S.CheckingDeposit>
)}
<S.CheckingDeposit $status={bookingStatus}>
{bookingStatusText[bookingStatus as bookingStatusTypes]}
</S.CheckingDeposit>
</S.DepositLayout>
</S.Context>
{dueDate >= 0 && totalPaymentAmount > 0 ? (
{dueDate >= 0 && totalPaymentAmount > 0 && bookingStatus === "CHECKING_PAYMENT" ? (
<S.AccountLayout onClick={() => handleModal(getBankNameKr(bankName), accountNumber)}>
<S.Account>계좌번호</S.Account>
</S.AccountLayout>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/lookup/components/LookupWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ const LookupWrapper = ({ handleBtn, ...item }: LookupProps) => {
<S.LookupCardLeft>
<S.LookupImage src={item.posterImage} />
<Label dueDate={item.dueDate} />
{item.dueDate >= 0 ? (
{item.dueDate < 0 || item.bookingStatus === "BOOKING_CANCELLED" ? (
<Button variant="line" disabled={true} size={{ width: "10.8rem", height: "3.6rem" }}>
취소하기
</Button>
) : (
<Button
variant="line"
size={{ width: "10.8rem", height: "3.6rem" }}
onClick={handleBtn}
>
취소하기
</Button>
) : (
<Button variant="line" disabled={true} size={{ width: "10.8rem", height: "3.6rem" }}>
취소하기
</Button>
)}
Comment on lines +16 to 28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p5) 이 부분 중복 코드가 가독성을 떨어뜨리는 것 같습니다.

<Button
  variant="line"
  disabled={item.dueDate < 0 || item.bookingStatus === "BOOKING_CANCELLED"}
  size={{ width: "10.8rem", height: "3.6rem" }}
  onClick={handleBtn}
>
  취소하기
</Button>

이렇게 줄여보는건 어떤가용?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아용
@sinji2102 신지 추후에 반영해주세용 ~
머지할게요!

</S.LookupCardLeft>
<LookupCard {...item}></LookupCard>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/lookup/types/lookupType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface LookupProps {
accountNumber: string;
accountHolder: string;
dueDate: number;
isPaymentCompleted: boolean;
bookingStatus: string;
createdAt: string;
posterImage: string;
totalPaymentAmount: number;
Expand Down
Loading