Skip to content

Commit

Permalink
[#95]Chore: add markAccount lib
Browse files Browse the repository at this point in the history
  • Loading branch information
gilyeon00 committed May 30, 2023
1 parent 9ae95cb commit cb5196c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/profile/FamCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {React, useState, useEffect} from 'react';
import './famCard.css';
import { Link } from 'react-router-dom';
import axios from 'axios';
import { markAccount } from '../../lib/markAccount';

const FamCard = ({isParent}) => {
const [isGirl, setIsGirl] = useState(true);
Expand Down Expand Up @@ -46,7 +47,7 @@ const FamCard = ({isParent}) => {
<img src={`${imgSrc}`} alt='' className='fam-profile' />
<div className='fam-info-box'>
<p id='fam-name'>{sessionStorage.getItem("username")}</p>
<p>계좌번호: {userAccount}</p>
<p>계좌번호: {markAccount(userAccount)}</p>
</div>
<div className='fam-edit-box'>
{!isParent ? (
Expand Down
3 changes: 2 additions & 1 deletion src/components/profile/MyBigCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import './myBigCard.css';
import axios from 'axios';
import Modal from 'react-modal';
import Loading from '../../lib/Loading';
import { markAccount } from '../../lib/markAccount';

const MyBigCard = ({ isParent }) => {
const containerStyle = {
Expand Down Expand Up @@ -157,7 +158,7 @@ const MyBigCard = ({ isParent }) => {
<p id="my-balance">잔액: {userBalance}</p>
</>
)}
<p id="my-account">계좌번호: {userAccount}</p>
<p id="my-account">계좌번호: {markAccount(userAccount)}</p>
<p>{userEmail}</p>
</div>
<div className="my-edit-box">
Expand Down
9 changes: 9 additions & 0 deletions src/lib/markAccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function markAccount(account) {
const chunkedAccount = account.match(/(\d{3})(\d{6})(\d{2})/);
if (chunkedAccount) {
return `${chunkedAccount[1]}-${chunkedAccount[2]}-${chunkedAccount[3]}`;
} else {
return account;
}
}

0 comments on commit cb5196c

Please sign in to comment.