diff --git a/src/entities/payment/model/types.ts b/src/entities/payment/model/types.ts index 40cebf5..d3ceeef 100644 --- a/src/entities/payment/model/types.ts +++ b/src/entities/payment/model/types.ts @@ -34,7 +34,7 @@ export interface MerchantInfo { paymentInfoType: string; mid: string; }; -export interface CreditCard { +export interface PaymentNotificationDataCommonType { id: number; paymentMethodName: string; startDate: string; @@ -46,59 +46,14 @@ export interface CreditCard { encryptionStatus: string; expandable: boolean; detail: Record; -}; -export interface AccountTransfer { - id: number; - paymentMethodName: string; - startDate: string; - adminEmail: string; - urlIp: string; - retransmissionInterval: string; - retransmissionCount: string; - okCheck: string; - encryptionStatus: string; - expandable: boolean; - detail: Record; -}; -export interface VirtualAccount { - id: number; - paymentMethodName: string; - startDate: string; - adminEmail: string; - urlIp: string; - retransmissionInterval: string; - retransmissionCount: string; - okCheck: string; - encryptionStatus: string; - expandable: boolean; - detail: Record; -}; -export interface MobilePayment { - id: 1, - paymentMethodName: string; - startDate: string; - adminEmail: string; - urlIp: string; - retransmissionInterval: string; - retransmissionCount: string; - okCheck: string; - encryptionStatus: string; - expandable: boolean; - detail: Record; -}; -export interface EscrowPayment { - id: 1, - paymentMethodName: string; - startDate: string; - adminEmail: string; - urlIp: string; - retransmissionInterval: string; - retransmissionCount: string; - okCheck: string; - encryptionStatus: string; - expandable: boolean; - detail: Record; -}; +} + +export interface CreditCard extends PaymentNotificationDataCommonType {}; +export interface AccountTransfer extends PaymentNotificationDataCommonType {}; +export interface VirtualAccount extends PaymentNotificationDataCommonType {}; +export interface MobilePayment extends PaymentNotificationDataCommonType {}; +export interface EscrowPayment extends PaymentNotificationDataCommonType {}; + export interface PaymentNonCardParams extends PaymentCommonParams { paymentMethod: string; }; @@ -125,13 +80,19 @@ export interface PaymentInstallmentParams extends PaymentCommonParams { export interface PaymentInstallmentResponse { installmentData: Array>; }; +export interface InstallmentDetails { + id: number; + installmentMonths: string; + applicationPeriod: string; + applicationAmount: number; +}; export interface PaymentInstallmentDetailParams extends PaymentCommonParams { cardCompany: string; }; export interface PaymentInstallmentDetailResponse { cardCompany: string; cardCompanyOptions: Array; - installmentDetails: Array>; + installmentDetails: Array; }; export interface PaymentCardParams extends PaymentCommonParams{ paymentMethod: string; diff --git a/src/entities/payment/ui/info-item.tsx b/src/entities/payment/ui/info-item.tsx index 16fe907..96db1f5 100644 --- a/src/entities/payment/ui/info-item.tsx +++ b/src/entities/payment/ui/info-item.tsx @@ -1,4 +1,6 @@ -import { PaymentInfoItemType } from '../model/types'; +import { + PaymentInfoItemType, +} from '../model/types'; export interface InfoItemProps { type?: PaymentInfoItemType; @@ -17,8 +19,8 @@ export const InfoItem = ({ }: InfoItemProps) => { const onClickToOpenBottomSheet = () => { - if(!!infoLink){ - + if(setNoInterestInfoBottomSheetOn){ + setNoInterestInfoBottomSheetOn(true); } }; return ( diff --git a/src/entities/payment/ui/info-wrap.tsx b/src/entities/payment/ui/info-wrap.tsx index fe35be2..f92725e 100644 --- a/src/entities/payment/ui/info-wrap.tsx +++ b/src/entities/payment/ui/info-wrap.tsx @@ -1,20 +1,25 @@ +import { useEffect, useState } from 'react'; import { IMAGE_ROOT } from '@/shared/constants/common'; import { InfoItem } from './info-item'; +import { NoInterestInfoBottomSheet } from './no-interest-info-bottom-sheet'; +import { usePaymentInstallmentDetailMutation } from '../api/use-payment-installment-detail-mutation'; import { + InstallmentDetails, PaymentCardResponse, PaymentInfoItemType, + PaymentInstallmentDetailResponse, PaymentInstallmentResponse, PaymentNonCardResponse } from '../model/types'; -import { NoInterestInfoBottomSheet } from './no-interest-info-bottom-sheet'; -import { useState } from 'react'; export interface InfoWrapProp { + mid: string; paymentCard?: PaymentCardResponse, paymentNonCard?: PaymentNonCardResponse, paymentInstallment?: PaymentInstallmentResponse }; export const InfoWrap = ({ + mid, paymentCard, paymentNonCard, paymentInstallment @@ -22,6 +27,12 @@ export const InfoWrap = ({ const [noInterestInfoBottomSheetOn, setNoInterestInfoBottomSheetOn] = useState(false); + const [cardCompany, setCardCompany] = useState('비씨'); + const [cardCompanyOptions, setCardCompanyOptions] = useState>(); + const [installmentDetails, setInstallmentDetails] = useState>([]); + + const { mutateAsync: paymentInstallmentDetail } = usePaymentInstallmentDetailMutation(); + const list1 = [ {payName: '신용카드', payImage: 'pay_01.svg', infoLink: ''}, {payName: '카카오페이', payImage: 'pay_02.svg', infoLink: ''}, @@ -85,8 +96,25 @@ export const InfoWrap = ({ } return rs; - } + }; + const callPaymentIntallmentDetail = () => { + let params = { + mid: mid, + cardCompany: cardCompany + }; + + paymentInstallmentDetail(params).then((rs) => { + console.log(rs); + setCardCompany(rs.cardCompany); + setCardCompanyOptions(rs.cardCompanyOptions); + setInstallmentDetails(rs.installmentDetails); + }); + }; + + useEffect(() => { + callPaymentIntallmentDetail(); + }, [cardCompany]); return ( <> @@ -104,6 +132,10 @@ export const InfoWrap = ({ ); diff --git a/src/entities/payment/ui/no-interest-info-bottom-sheet.tsx b/src/entities/payment/ui/no-interest-info-bottom-sheet.tsx index 618c226..b30a5ed 100644 --- a/src/entities/payment/ui/no-interest-info-bottom-sheet.tsx +++ b/src/entities/payment/ui/no-interest-info-bottom-sheet.tsx @@ -1,21 +1,40 @@ import { motion } from 'framer-motion'; import { IMAGE_ROOT } from '@/shared/constants/common'; import { BottomSheetMotionVaiants, BottomSheetMotionDuration } from '@/entities/common/model/constant'; +import { InstallmentDetails, PaymentInstallmentDetailResponse } from '../model/types'; +import { ChangeEvent } from 'react'; +import { NumericFormat } from 'react-number-format'; export interface NoInterestInfoBottomSheetProps { noInterestInfoBottomSheetOn: boolean; setNoInterestInfoBottomSheetOn: (noInterestInfoBottomSheetOn: boolean) => void; + cardCompany?: string; + cardCompanyOptions?: Array; + installmentDetails?: Array; + setCardCompany?: (cardCompany: string) => void; }; export const NoInterestInfoBottomSheet = ({ noInterestInfoBottomSheetOn, - setNoInterestInfoBottomSheetOn + setNoInterestInfoBottomSheetOn, + cardCompany, + cardCompanyOptions, + installmentDetails, + setCardCompany }: NoInterestInfoBottomSheetProps) => { const onClickToClose = () => { // close setNoInterestInfoBottomSheetOn(false); }; - return ( + + const onChangeToCardCompany = (e: ChangeEvent) => { + let value = e.target.value; + if(setCardCompany){ + setCardCompany(value); + } + }; + + return ( <> { noInterestInfoBottomSheetOn &&
@@ -47,11 +66,48 @@ export const NoInterestInfoBottomSheet = ({
카드사
- + { cardCompanyOptions.map((value, index) => ( + + )) + } + }
+ { !!installmentDetails + && installmentDetails.length > 0 + && installmentDetails.map((value, index) => ( + <> + { (index > 0) && +
+ } +
+ 할부개월 : + { value.installmentMonths } +
+
+ 적용기간 : + { value.applicationPeriod } +
+
+ 적용금액 : + + + +
+ + )) + } + {/*
할부개월 : 02, 03, 07
적용기간 : 2025.06.01 ~ 9999.12.31
적용금액 : 70,000
@@ -59,6 +115,7 @@ export const NoInterestInfoBottomSheet = ({
할부개월 : 15, 20, 36, 60
적용기간 : 2025.06.01 ~ 9999.12.31
적용금액 : 50,000
+ */} diff --git a/src/pages/payment/info/info-page.tsx b/src/pages/payment/info/info-page.tsx index 4926f96..2643cd5 100644 --- a/src/pages/payment/info/info-page.tsx +++ b/src/pages/payment/info/info-page.tsx @@ -83,6 +83,7 @@ export const InfoPage = () => {