페이징
This commit is contained in:
@@ -16,10 +16,12 @@ import { useVatReturnListMutation } from '../api/use-vat-return-list-mutation';
|
|||||||
import { ListDateGroup } from './list-date-group';
|
import { ListDateGroup } from './list-date-group';
|
||||||
import { useStore } from '@/shared/model/store';
|
import { useStore } from '@/shared/model/store';
|
||||||
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
||||||
|
import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||||
|
|
||||||
export const ListWrap = () => {
|
export const ListWrap = () => {
|
||||||
const userMid = useStore.getState().UserStore.mid;
|
const userMid = useStore.getState().UserStore.mid;
|
||||||
|
|
||||||
|
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||||
const [listItems, setListItems] = useState<Array<VatReturnListContent>>([]);
|
const [listItems, setListItems] = useState<Array<VatReturnListContent>>([]);
|
||||||
@@ -33,8 +35,27 @@ export const ListWrap = () => {
|
|||||||
const [emailBottomSheetOn, setEmailBottomSheetOn] = useState<boolean>(false);
|
const [emailBottomSheetOn, setEmailBottomSheetOn] = useState<boolean>(false);
|
||||||
|
|
||||||
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
|
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
|
||||||
|
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
||||||
|
entries.forEach((entry: IntersectionObserverEntry) => {
|
||||||
|
if(entry.isIntersecting){
|
||||||
|
console.log('Element is now intersecting with the root. [' + onActionIntersect + ']');
|
||||||
|
if(onActionIntersect && !!pageParam.cursor){
|
||||||
|
callList('page');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log('Element is no longer intersecting with the root.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const callList = () => {
|
const { setTarget } = useIntersectionObserver({
|
||||||
|
threshold: 1,
|
||||||
|
onIntersect
|
||||||
|
});
|
||||||
|
|
||||||
|
const callList = (type?: string) => {
|
||||||
|
setOnActionIntersect(false);
|
||||||
let params: VatReturnListParams = {
|
let params: VatReturnListParams = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
startMonth: startMonth,
|
startMonth: startMonth,
|
||||||
@@ -48,7 +69,28 @@ export const ListWrap = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
vatReturnList(params).then((rs: VatReturnListResponse) => {
|
vatReturnList(params).then((rs: VatReturnListResponse) => {
|
||||||
setListItems(rs.content);
|
if(type === 'page'){
|
||||||
|
setListItems([
|
||||||
|
...listItems,
|
||||||
|
...rs.content
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setListItems(rs.content);
|
||||||
|
}
|
||||||
|
if(rs.hasNext){
|
||||||
|
setPageParam({
|
||||||
|
...pageParam,
|
||||||
|
...{ cursor: rs.nextCursor }
|
||||||
|
});
|
||||||
|
setOnActionIntersect(true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setPageParam({
|
||||||
|
...pageParam,
|
||||||
|
...{ cursor: null }
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -152,7 +194,8 @@ export const ListWrap = () => {
|
|||||||
></SortTypeBox>
|
></SortTypeBox>
|
||||||
</div>
|
</div>
|
||||||
<div className="transaction-list">
|
<div className="transaction-list">
|
||||||
{ getListDateGroup() }
|
{ getListDateGroup() }
|
||||||
|
<div ref={ setTarget }></div>
|
||||||
</div>
|
</div>
|
||||||
<ListFilter
|
<ListFilter
|
||||||
filterOn={ filterOn }
|
filterOn={ filterOn }
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ export const AllTransactionListPage = () => {
|
|||||||
|
|
||||||
const [emailBottomSheetOn, setEmailBottomSheetOn] = useState<boolean>(false);
|
const [emailBottomSheetOn, setEmailBottomSheetOn] = useState<boolean>(false);
|
||||||
|
|
||||||
|
|
||||||
useSetHeaderTitle('거래내역 조회');
|
useSetHeaderTitle('거래내역 조회');
|
||||||
useSetHeaderType(HeaderType.LeftArrow);
|
useSetHeaderType(HeaderType.LeftArrow);
|
||||||
useSetOnBack(() => {
|
useSetOnBack(() => {
|
||||||
|
|||||||
@@ -29,12 +29,14 @@ import {
|
|||||||
useSetFooterMode
|
useSetFooterMode
|
||||||
} from '@/widgets/sub-layout/use-sub-layout';
|
} from '@/widgets/sub-layout/use-sub-layout';
|
||||||
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
||||||
|
import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||||
|
|
||||||
export const BillingListPage = () => {
|
export const BillingListPage = () => {
|
||||||
const { navigate } = useNavigate();
|
const { navigate } = useNavigate();
|
||||||
const userMid = useStore.getState().UserStore.mid;
|
const userMid = useStore.getState().UserStore.mid;
|
||||||
const userInfo = useStore((state) => state.UserStore.userInfo);
|
const userInfo = useStore((state) => state.UserStore.userInfo);
|
||||||
|
|
||||||
|
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||||
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
||||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||||
@@ -62,8 +64,27 @@ export const BillingListPage = () => {
|
|||||||
|
|
||||||
const { mutateAsync: billingList } = useBillingListMutation();
|
const { mutateAsync: billingList } = useBillingListMutation();
|
||||||
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
|
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
|
||||||
|
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
||||||
|
entries.forEach((entry: IntersectionObserverEntry) => {
|
||||||
|
if(entry.isIntersecting){
|
||||||
|
console.log('Element is now intersecting with the root. [' + onActionIntersect + ']');
|
||||||
|
if(onActionIntersect && !!pageParam.cursor){
|
||||||
|
callList('page');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log('Element is no longer intersecting with the root.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const callList = () => {
|
const { setTarget } = useIntersectionObserver({
|
||||||
|
threshold: 1,
|
||||||
|
onIntersect
|
||||||
|
});
|
||||||
|
|
||||||
|
const callList = (type?: string) => {
|
||||||
|
setOnActionIntersect(false);
|
||||||
let listParams: BillingListParams = {
|
let listParams: BillingListParams = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
searchType: searchType,
|
searchType: searchType,
|
||||||
@@ -80,9 +101,33 @@ export const BillingListPage = () => {
|
|||||||
...{ sortType: sortType }
|
...{ sortType: sortType }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if(type !== 'page' && listParams.page){
|
||||||
|
listParams.page.cursor = null;
|
||||||
|
}
|
||||||
|
|
||||||
billingList(listParams).then((rs: BillingListResponse) => {
|
billingList(listParams).then((rs: BillingListResponse) => {
|
||||||
setListItems(rs.content);
|
if(type === 'page'){
|
||||||
|
setListItems([
|
||||||
|
...listItems,
|
||||||
|
...rs.content
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setListItems(rs.content);
|
||||||
|
}
|
||||||
|
if(rs.hasNext){
|
||||||
|
setPageParam({
|
||||||
|
...pageParam,
|
||||||
|
...{ cursor: rs.nextCursor }
|
||||||
|
});
|
||||||
|
setOnActionIntersect(true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setPageParam({
|
||||||
|
...pageParam,
|
||||||
|
...{ cursor: null }
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +213,7 @@ export const BillingListPage = () => {
|
|||||||
listItems={ listItems }
|
listItems={ listItems }
|
||||||
transactionCategory={ TransactionCategory.Billing }
|
transactionCategory={ TransactionCategory.Billing }
|
||||||
></BillingList>
|
></BillingList>
|
||||||
|
<div ref={ setTarget }></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -33,11 +33,13 @@ import { CashReceiptTransactionTypeBtnGroup } from '@/entities/transaction/model
|
|||||||
import { useStore } from '@/shared/model/store';
|
import { useStore } from '@/shared/model/store';
|
||||||
import { useCashReceiptSummaryMutation } from '@/entities/transaction/api/use-cash-receipt-summary-mutation';
|
import { useCashReceiptSummaryMutation } from '@/entities/transaction/api/use-cash-receipt-summary-mutation';
|
||||||
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
||||||
|
import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||||
|
|
||||||
export const CashReceiptListPage = () => {
|
export const CashReceiptListPage = () => {
|
||||||
const { navigate } = useNavigate();
|
const { navigate } = useNavigate();
|
||||||
const userMid = useStore.getState().UserStore.mid;
|
const userMid = useStore.getState().UserStore.mid;
|
||||||
|
|
||||||
|
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||||
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
||||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||||
@@ -68,8 +70,27 @@ export const CashReceiptListPage = () => {
|
|||||||
const { mutateAsync: cashReceiptList } = useCashReceiptListMutation();
|
const { mutateAsync: cashReceiptList } = useCashReceiptListMutation();
|
||||||
const { mutateAsync: cashReceiptSummary } = useCashReceiptSummaryMutation();
|
const { mutateAsync: cashReceiptSummary } = useCashReceiptSummaryMutation();
|
||||||
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
|
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
|
||||||
|
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
||||||
|
entries.forEach((entry: IntersectionObserverEntry) => {
|
||||||
|
if(entry.isIntersecting){
|
||||||
|
console.log('Element is now intersecting with the root. [' + onActionIntersect + ']');
|
||||||
|
if(onActionIntersect && !!pageParam.cursor){
|
||||||
|
callList('page');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log('Element is no longer intersecting with the root.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const callList = () => {
|
const { setTarget } = useIntersectionObserver({
|
||||||
|
threshold: 1,
|
||||||
|
onIntersect
|
||||||
|
});
|
||||||
|
|
||||||
|
const callList = (type?: string) => {
|
||||||
|
setOnActionIntersect(false);
|
||||||
let listSummaryParams: CashReceiptSummaryParams = {
|
let listSummaryParams: CashReceiptSummaryParams = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
startDate: startDate,
|
startDate: startDate,
|
||||||
@@ -88,9 +109,33 @@ export const CashReceiptListPage = () => {
|
|||||||
...{ sortType: sortType }
|
...{ sortType: sortType }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if(type !== 'page' && listParams.page){
|
||||||
|
listParams.page.cursor = null;
|
||||||
|
}
|
||||||
|
|
||||||
cashReceiptList(listParams).then((rs: CashReceiptListResponse) => {
|
cashReceiptList(listParams).then((rs: CashReceiptListResponse) => {
|
||||||
setListItems(rs.content);
|
if(type === 'page'){
|
||||||
|
setListItems([
|
||||||
|
...listItems,
|
||||||
|
...rs.content
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setListItems(rs.content);
|
||||||
|
}
|
||||||
|
if(rs.hasNext){
|
||||||
|
setPageParam({
|
||||||
|
...pageParam,
|
||||||
|
...{ cursor: rs.nextCursor }
|
||||||
|
});
|
||||||
|
setOnActionIntersect(true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setPageParam({
|
||||||
|
...pageParam,
|
||||||
|
...{ cursor: null }
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
cashReceiptSummary(listSummaryParams).then((rs: CashReceiptSummaryResponse) => {
|
cashReceiptSummary(listSummaryParams).then((rs: CashReceiptSummaryResponse) => {
|
||||||
setApprovalCount(rs.approvalCount);
|
setApprovalCount(rs.approvalCount);
|
||||||
@@ -230,6 +275,7 @@ export const CashReceiptListPage = () => {
|
|||||||
listItems={ listItems }
|
listItems={ listItems }
|
||||||
transactionCategory={ TransactionCategory.CashReceipt }
|
transactionCategory={ TransactionCategory.CashReceipt }
|
||||||
></CashReceiptList>
|
></CashReceiptList>
|
||||||
|
<div ref={ setTarget }></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -28,12 +28,14 @@ import {
|
|||||||
useSetFooterMode
|
useSetFooterMode
|
||||||
} from '@/widgets/sub-layout/use-sub-layout';
|
} from '@/widgets/sub-layout/use-sub-layout';
|
||||||
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
||||||
|
import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||||
|
|
||||||
export const EscrowListPage = () => {
|
export const EscrowListPage = () => {
|
||||||
const { navigate } = useNavigate();
|
const { navigate } = useNavigate();
|
||||||
const userInfo = useStore((state) => state.UserStore.userInfo);
|
const userInfo = useStore((state) => state.UserStore.userInfo);
|
||||||
const userMid = useStore.getState().UserStore.mid;
|
const userMid = useStore.getState().UserStore.mid;
|
||||||
|
|
||||||
|
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||||
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
const [listItems, setListItems] = useState<Array<ListItemProps>>([]);
|
||||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||||
@@ -60,8 +62,27 @@ export const EscrowListPage = () => {
|
|||||||
|
|
||||||
const { mutateAsync: escrowList } = useEscrowListMutation();
|
const { mutateAsync: escrowList } = useEscrowListMutation();
|
||||||
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
|
const { mutateAsync: downloadExcel } = useDownloadExcelMutation();
|
||||||
|
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
||||||
|
entries.forEach((entry: IntersectionObserverEntry) => {
|
||||||
|
if(entry.isIntersecting){
|
||||||
|
console.log('Element is now intersecting with the root. [' + onActionIntersect + ']');
|
||||||
|
if(onActionIntersect && !!pageParam.cursor){
|
||||||
|
callList('page');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log('Element is no longer intersecting with the root.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const callList = () => {
|
const { setTarget } = useIntersectionObserver({
|
||||||
|
threshold: 1,
|
||||||
|
onIntersect
|
||||||
|
});
|
||||||
|
|
||||||
|
const callList = (type?: string) => {
|
||||||
|
setOnActionIntersect(false);
|
||||||
let listParams: EscrowListParams = {
|
let listParams: EscrowListParams = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
searchType: 'ORDER_NUMBER',
|
searchType: 'ORDER_NUMBER',
|
||||||
@@ -171,6 +192,7 @@ export const EscrowListPage = () => {
|
|||||||
listItems={ listItems }
|
listItems={ listItems }
|
||||||
transactionCategory={ TransactionCategory.Escrow }
|
transactionCategory={ TransactionCategory.Escrow }
|
||||||
></EscrowList>
|
></EscrowList>
|
||||||
|
<div ref={ setTarget }></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
Reference in New Issue
Block a user