현금영수증 리스트
This commit is contained in:
@@ -5,14 +5,14 @@ import { IMAGE_ROOT } from '@/shared/constants/common';
|
||||
import { PATHS } from '@/shared/constants/paths';
|
||||
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
|
||||
import { BillingList } from '@/entities/transaction/ui/billing-list';
|
||||
import { BillingListItem, TransactionCategory, BillingRequestStatus, BillingProcessResult, BillingPaymentMethod, BillingSearchType } from '@/entities/transaction/model/types';
|
||||
import { BillingListItem, TransactionCategory, BillingRequestStatus, BillingProcessResult, BillingPaymentMethod, BillingSearchType, ListItemProps, BillingListParams, BillingListResponse } from '@/entities/transaction/model/types';
|
||||
import { useBillingListMutation } from '@/entities/transaction/api/use-billing-list-mutation';
|
||||
import { useDownloadExcelMutation } from '@/entities/transaction/api/use-download-excel-mutation';
|
||||
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
|
||||
import { BillingFilter } from '@/entities/transaction/ui/filter/billing-filter';
|
||||
import { SortTypeBox } from '@/entities/common/ui/sort-type-box';
|
||||
import { BillingRequestStatusBtnGroup } from '@/entities/transaction/model/contant';
|
||||
import { SortTypeKeys, HeaderType } from '@/entities/common/model/types';
|
||||
import { SortTypeKeys, HeaderType, DefaultRequestPagination } from '@/entities/common/model/types';
|
||||
import {
|
||||
useSetOnBack,
|
||||
useSetHeaderTitle,
|
||||
@@ -26,9 +26,9 @@ export const BillingListPage = () => {
|
||||
const userInfo = useStore((state) => state.UserStore.userInfo);
|
||||
|
||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||
const [listItems, setListItems] = useState({});
|
||||
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||
const [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM);
|
||||
const [pageParam, setPageParam] = useState<DefaultRequestPagination>(DEFAULT_PAGE_PARAM);
|
||||
const [mid, setMid] = useState<string>(userMid);
|
||||
const [searchType, setSearchType] = useState<BillingSearchType>(BillingSearchType.ALL);
|
||||
const [searchKeyword, setSearchKeyword] = useState<string>('');
|
||||
@@ -55,8 +55,6 @@ export const BillingListPage = () => {
|
||||
sortType?: SortTypeKeys,
|
||||
val?: string
|
||||
}) => {
|
||||
pageParam.sortType = (option?.sortType)? option.sortType: sortType;
|
||||
setPageParam(pageParam);
|
||||
let newMinAmount = minAmount;
|
||||
if(!!minAmount && typeof(minAmount) === 'string'){
|
||||
newMinAmount = parseInt(minAmount);
|
||||
@@ -65,7 +63,7 @@ export const BillingListPage = () => {
|
||||
if(!!maxAmount && typeof(maxAmount) === 'string'){
|
||||
newMaxAmount = parseInt(maxAmount);
|
||||
}
|
||||
let listParams = {
|
||||
let listParams: BillingListParams = {
|
||||
mid: mid,
|
||||
searchType: searchType,
|
||||
searchKeyword: searchKeyword,
|
||||
@@ -76,30 +74,18 @@ export const BillingListPage = () => {
|
||||
paymentMethod: paymentMethod,
|
||||
minAmount: newMinAmount,
|
||||
maxAmount: newMaxAmount,
|
||||
pagination: pageParam
|
||||
};
|
||||
|
||||
billingList(listParams).then((rs) => {
|
||||
setListItems(assembleData(rs.content));
|
||||
page: pageParam
|
||||
};
|
||||
if(listParams.page){
|
||||
listParams.page.sortType = (option?.sortType)? option.sortType: sortType;
|
||||
setPageParam(listParams.page);
|
||||
}
|
||||
|
||||
billingList(listParams).then((rs: BillingListResponse) => {
|
||||
setListItems(rs.content);
|
||||
});
|
||||
}
|
||||
|
||||
const assembleData = (content: Array<BillingListItem>) => {
|
||||
let data: any = {};
|
||||
if(content && content.length > 0){
|
||||
for(let i=0;i<content?.length;i++){
|
||||
let groupDate = moment(content[i]?.transactionDateTime).format('YYYYMMDD');
|
||||
if(!!groupDate && !data.hasOwnProperty(groupDate)){
|
||||
data[groupDate] = [];
|
||||
}
|
||||
if(!!groupDate && data.hasOwnProperty(groupDate)){
|
||||
data[groupDate].push(content[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
const onClickToOpenFilter = () => {
|
||||
setFilterOn(!filterOn);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user