g
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import * as _ from 'lodash-es';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { IMAGE_ROOT } from '@/shared/constants/common';
|
import { IMAGE_ROOT } from '@/shared/constants/common';
|
||||||
@@ -43,10 +44,14 @@ export const CardCommissionBottomSheet = ({
|
|||||||
feeRate
|
feeRate
|
||||||
}: CardCommissionBottomSheetProps) => {
|
}: CardCommissionBottomSheetProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
// 01: 비씨, 02: KB국민, 03: 하나(외환), 04: 삼성, 06: 신한,
|
||||||
|
// 07: 현대, 08: 롯데, 11: 씨티, 12: NH채움, 16: 하나
|
||||||
|
// const useCodes = ['01', '02', '03', '04', '06', '07', '08', '11', '12', '16'];
|
||||||
const cardList = useStore.getState().CommonStore.creditCardList;
|
const cardList = useStore.getState().CommonStore.creditCardList;
|
||||||
console.log(cardList);
|
|
||||||
let newCardList = cardList.filter((value, index) => value.code2 === 'pur');
|
let newCardList = cardList.filter((value, index) => value.code2 === 'pur');
|
||||||
|
// let newCardList = cardList.filter((value, index) => useCodes.includes(value.code1));
|
||||||
|
|
||||||
|
const [newGeneralTabItems, setNewGeneralTabItems] = useState<Record<string, any>>({});
|
||||||
|
|
||||||
const [onTab, setOnTab] = useState<CardCommissionTabKey>(CardCommissionTabKey.GENERAL);
|
const [onTab, setOnTab] = useState<CardCommissionTabKey>(CardCommissionTabKey.GENERAL);
|
||||||
const [selectedCard, setSelectedCard] = useState<string>(cardList[0].desc1);
|
const [selectedCard, setSelectedCard] = useState<string>(cardList[0].desc1);
|
||||||
@@ -57,20 +62,27 @@ export const CardCommissionBottomSheet = ({
|
|||||||
setCardCommissionBottomSheetOn(false);
|
setCardCommissionBottomSheetOn(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const getItemList = (key?: CardCommissionTabKey) => {
|
const getItemList = (key?: CardCommissionTabKey) => {
|
||||||
let rs = [];
|
let rs = [];
|
||||||
if(key === CardCommissionTabKey.GENERAL){
|
if(key === CardCommissionTabKey.GENERAL){
|
||||||
for(let i=0;i<newCardList.length;i++){
|
for(let i=0;i<newCardList.length;i++){
|
||||||
|
let cardItem = newCardList[i];
|
||||||
|
let cardCompany = cardItem.desc1;
|
||||||
|
if(newGeneralTabItems.hasOwnProperty(cardCompany)){
|
||||||
|
let feeRate = newGeneralTabItems[cardCompany];
|
||||||
rs.push(
|
rs.push(
|
||||||
<div
|
<div
|
||||||
key={`card-fee-row-${i}`}
|
key={`card-fee-row-${i}`}
|
||||||
className="card-fee-row"
|
className="card-fee-row"
|
||||||
>
|
>
|
||||||
<span>{ newCardList[i].desc1 }</span>
|
<span>{ cardCompany }</span>
|
||||||
<span>2.000%</span>
|
<span>{ feeRate || ''}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
@@ -97,6 +109,19 @@ export const CardCommissionBottomSheet = ({
|
|||||||
}
|
}
|
||||||
}, [itemKey]);
|
}, [itemKey]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(onTab === CardCommissionTabKey.NO_INTEREST){
|
||||||
|
|
||||||
|
}
|
||||||
|
}, [selectedCard]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(!!generalTabItems){
|
||||||
|
let objectGeneralTabItems = _.chain(generalTabItems).keyBy('cardCompany').mapValues('feeRate').value();
|
||||||
|
setNewGeneralTabItems(objectGeneralTabItems);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{ cardCommissionBottomSheetOn &&
|
{ cardCommissionBottomSheetOn &&
|
||||||
@@ -172,11 +197,13 @@ export const CardCommissionBottomSheet = ({
|
|||||||
onChange={ (e: ChangeEvent<HTMLSelectElement>) => setSelectedCard(e.target.value) }
|
onChange={ (e: ChangeEvent<HTMLSelectElement>) => setSelectedCard(e.target.value) }
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
newCardList.map((value, index) => (
|
newCardList.filter((value1, index1) => {
|
||||||
|
return newGeneralTabItems.hasOwnProperty(value1.desc1)
|
||||||
|
}).map((value2, index2) => (
|
||||||
<option
|
<option
|
||||||
key={ `card-list-${value.desc1}`}
|
key={ `card-list-${value2.desc1}`}
|
||||||
value={ value.desc1 }
|
value={ value2.desc1 }
|
||||||
>{ value.desc1 }</option>
|
>{ value2.desc1 }</option>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user