Skip to content

Commit

Permalink
[KAN-122] fix(euna): 프론트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
EunaAhn committed Jul 24, 2024
1 parent 1b588f7 commit 67a38e4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 36 deletions.
15 changes: 1 addition & 14 deletions client/src/components/member/account/AccountInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react';
import Input from '@/components/common/inputs/Input';
import { useInvoiceStore } from '@/stores/useInvoiceStore';
import { verifyCMS } from '@/apis/validation';
import { formatBirthDate } from '@/utils/format/formatBirth';

const AccountInfo = ({ accountInfo, setAccountInfo }) => {
const selectedCard = useInvoiceStore(state => state.selectedCard);
Expand All @@ -10,20 +11,6 @@ const AccountInfo = ({ accountInfo, setAccountInfo }) => {
const [isVerified, setIsVerified] = useState(false);
const [verificationResult, setVerificationResult] = useState(null);

const formatBirthDate = value => {
const cleaned = value.replace(/\D/g, '');
let formatted = cleaned;

if (cleaned.length > 4) {
formatted = `${cleaned.slice(0, 4)}-${cleaned.slice(4)}`;
}
if (cleaned.length > 6) {
formatted = `${formatted.slice(0, 7)}-${formatted.slice(7)}`;
}

return formatted.slice(0, 10);
};

const handleInputChange = e => {
const { name, value } = e.target;
let formattedValue = value;
Expand Down
12 changes: 8 additions & 4 deletions client/src/components/member/account/ChooseBank.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { convertToProductSummary } from '@/pages/member/InvoicePage';
import { useInvoiceStore } from '@/stores/useInvoiceStore';
import React, { useState } from 'react';

const ChooseBank = ({billingInfo}) => {
const setSelectedCard = useInvoiceStore((state) => state.setSelectedCard);
const selectedCard = useInvoiceStore((state) => state.selectedCard);
const ChooseBank = ({ billingInfo }) => {
// const setSelectedCard = useInvoiceStore((state) => state.setSelectedCard);
// const selectedCard = useInvoiceStore((state) => state.selectedCard);

const { setSelectedCard, selectedCard } = useInvoiceStore();

const cardOptions = [
'기업은행',
Expand Down Expand Up @@ -36,7 +38,9 @@ const ChooseBank = ({billingInfo}) => {
<h4 className='text-sm text-gray-500 mb-2 font-semibold'>결제금액</h4>
<div className='mb-4 h-24 border border-mint rounded-lg p-4 flex flex-col justify-between'>
<div>
<p className='text-base font-semibold'>{convertToProductSummary(billingInfo.billingProducts)}</p>
<p className='text-base font-semibold'>
{convertToProductSummary(billingInfo.billingProducts)}
</p>
<p className='text-xs text-gray-500'>{billingInfo.billingDate}</p>
</div>
<div className='self-end'>
Expand Down
15 changes: 1 addition & 14 deletions client/src/components/member/card/CardInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react';
import Input from '@/components/common/inputs/Input';
import { useInvoiceStore } from '@/stores/useInvoiceStore';
import { verifyCard } from '@/apis/validation';
import { formatBirthDate } from '@/utils/format/formatBirth';

const CardInfo = ({ cardInfo, setCardInfo }) => {
const selectedCard = useInvoiceStore(state => state.selectedCard);
Expand All @@ -10,20 +11,6 @@ const CardInfo = ({ cardInfo, setCardInfo }) => {
const [isVerified, setIsVerified] = useState(false);
const [verificationResult, setVerificationResult] = useState(null);

const formatBirthDate = value => {
const cleaned = value.replace(/\D/g, '');
let formatted = cleaned;

if (cleaned.length > 4) {
formatted = `${cleaned.slice(0, 4)}-${cleaned.slice(4)}`;
}
if (cleaned.length > 6) {
formatted = `${formatted.slice(0, 7)}-${formatted.slice(7)}`;
}

return formatted.slice(0, 10);
};

const formatExpiryDate = value => {
const cleaned = value.replace(/\D/g, '');
let formatted = cleaned;
Expand Down
4 changes: 0 additions & 4 deletions client/src/components/member/card/ChooseCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { useInvoiceStore } from '@/stores/useInvoiceStore';
import React, { useState } from 'react';

const ChooseCard = () => {
// const setSelectedCard = useInvoiceStore(state => state.setSelectedCard);
// const selectedCard = useInvoiceStore(state => state.selectedCard);
// const invoiceInfo = useInvoiceStore(state => state.invoiceInfo);

const { setSelectedCard, selectedCard, invoiceInfo } = useInvoiceStore();

const cardOptions = [
Expand Down
15 changes: 15 additions & 0 deletions client/src/utils/format/formatBirth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,18 @@ export const removeDashesFromBirth = birth => {
// 생년월일에서 모든 대시를 제거하고 숫자만 이어붙임
return birth.replace(/-/g, '');
};

// <------ 생년월일 포맷팅 함수 ------>
export const formatBirthDate = value => {
const cleaned = value.replace(/\D/g, '');
let formatted = cleaned;

if (cleaned.length > 4) {
formatted = `${cleaned.slice(0, 4)}-${cleaned.slice(4)}`;
}
if (cleaned.length > 6) {
formatted = `${formatted.slice(0, 7)}-${formatted.slice(7)}`;
}

return formatted.slice(0, 10);
};

0 comments on commit 67a38e4

Please sign in to comment.