sort 관련 정리
This commit is contained in:
@@ -6,7 +6,7 @@ import { ListDateGroup } from './list-date-group';
|
||||
import { PATHS } from '@/shared/constants/paths';
|
||||
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
|
||||
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
|
||||
import { SortOptionsBox } from '@/entities/common/ui/sort-options-box';
|
||||
import { SortTypeBox } from '@/entities/common/ui/sort-type-box';
|
||||
import { useSettlementsHistoryMutation } from '../api/use-settlements-history-mutation';
|
||||
import { useSettlementsHistorySummaryMutation } from '../api/use-settlements-history-summary-mutation';
|
||||
import { useSettlementsTransactionSummaryMutation } from '../api/use-settlements-transaction-summary-mutation';
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
ListDateGroupProps,
|
||||
SettlementsTransactionListContent
|
||||
} from '../model/types';
|
||||
import { SortByKeys } from '@/entities/common/model/types';
|
||||
import { SortTypeKeys } from '@/entities/common/model/types';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
|
||||
export interface ListWrapProps {
|
||||
@@ -39,7 +39,7 @@ export const ListWrap = ({
|
||||
const { navigate } = useNavigate();
|
||||
const userMid = useStore.getState().UserStore.mid;
|
||||
|
||||
const [sortBy, setSortBy] = useState<SortByKeys>(SortByKeys.New);
|
||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||
const [settlementDateListItems, setSettlementDateListItems] = useState<Record<string, Array<SettlementsHistoryContent>>>({});
|
||||
const [transactionDatelistItems, setTransactionDateListItems] = useState<Record<string, Array<SettlementsTransactionListContent>>>({});
|
||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||
@@ -80,7 +80,7 @@ export const ListWrap = ({
|
||||
};
|
||||
|
||||
const callSettlementList = (option?: {
|
||||
sortBy?: string,
|
||||
sortType?: SortTypeKeys,
|
||||
val?: string
|
||||
}) => {
|
||||
let listSummaryParams = {
|
||||
@@ -90,7 +90,7 @@ export const ListWrap = ({
|
||||
endDate: endDate,
|
||||
paymentMethod: paymentMethod,
|
||||
};
|
||||
pageParam.sortBy = (option?.sortBy)? option.sortBy: sortBy;
|
||||
pageParam.sortType = (option?.sortType)? option.sortType: sortType;
|
||||
setPageParam(pageParam);
|
||||
|
||||
let listParams = {
|
||||
@@ -110,10 +110,10 @@ export const ListWrap = ({
|
||||
});
|
||||
};
|
||||
const callTransactionList = (option?: {
|
||||
sortBy?: string,
|
||||
sortType?: SortTypeKeys,
|
||||
val?: string
|
||||
}) => {
|
||||
pageParam.sortBy = (option?.sortBy)? option.sortBy: sortBy;
|
||||
pageParam.sortType = (option?.sortType)? option.sortType: sortType;
|
||||
setPageParam(pageParam);
|
||||
let params = {
|
||||
mid: mid,
|
||||
@@ -161,13 +161,17 @@ export const ListWrap = ({
|
||||
}
|
||||
return data;
|
||||
};
|
||||
const onClickToSort = (sort: SortByKeys) => {
|
||||
setSortBy(sort);
|
||||
const onClickToSort = (sort: SortTypeKeys) => {
|
||||
setSortType(sort);
|
||||
if(periodType === SettlementPeriodType.SETTLEMENT_DATE){
|
||||
callSettlementList({sortBy: sort});
|
||||
callSettlementList({
|
||||
sortType: sort
|
||||
});
|
||||
}
|
||||
else if(periodType === SettlementPeriodType.TRANSACTION_DATE){
|
||||
callTransactionList({sortBy: sort});
|
||||
callTransactionList({
|
||||
sortType: sort
|
||||
});
|
||||
}
|
||||
};
|
||||
const changePeriodType = (val: SettlementPeriodType) => {
|
||||
@@ -309,10 +313,10 @@ export const ListWrap = ({
|
||||
</div>
|
||||
|
||||
<div className="filter-section">
|
||||
<SortOptionsBox
|
||||
sortBy={ sortBy }
|
||||
<SortTypeBox
|
||||
sortType={ sortType }
|
||||
onClickToSort={ onClickToSort }
|
||||
></SortOptionsBox>
|
||||
></SortTypeBox>
|
||||
<div>
|
||||
<div className="full-menu-keywords no-padding">
|
||||
<span
|
||||
|
||||
Reference in New Issue
Block a user