import { BillingListProps } from '../model/types'; import { ListDateGroup } from './list-date-group'; import { useTranslation } from 'react-i18next'; import { useEffect, useState } from 'react'; import { GetListHeight, IMAGE_ROOT, ListScrollOn, setScrollAction } from '@/shared/constants/common'; export const BillingList = ({ transactionCategory, listItems, setDetailData, filterUsed, onClickToOpenFilter, onClickToOpenDownloadBottomSheet }: BillingListProps) => { const { t, i18n } = useTranslation(); const [groupDate, setGroupDate] = useState(''); const [groupDateOn, setGroupDateOn] = useState(false); const [listHeight, setListHeight] = useState(0); const getListDateGroup = () => { let rs = []; let date = ''; let list = []; for(let i=0;i 0){ rs.push( ); } date = transactionDate; list = []; } list.push(item); } } } if(list.length > 0){ rs.push( ); } return rs; }; useEffect(() => { ListScrollOn(true); let heightList = GetListHeight(); setListHeight(heightList.listHeight); let tabContent = document.querySelector('.tab-content'); tabContent?.addEventListener('scroll', (e: Event) => { setScrollAction(e, setGroupDate, setGroupDateOn); }); return () => { ListScrollOn(false); tabContent?.removeEventListener('scroll', (e: Event) => { setScrollAction(e, setGroupDate, setGroupDateOn); }); }; }, []); return ( <> { groupDateOn &&
{ groupDate }
}
0)? listHeight + 'px': 'unset' }} > { getListDateGroup() }
); };