- getListDateGroup 수정
- 알림톡 필터 추가 - 일부 부가서비스 엑셀다운로드 바텀시트 추가
This commit is contained in:
@@ -3,9 +3,9 @@ import { useNavigate } from '@/shared/lib/hooks/use-navigate';
|
||||
import { DefaultRequestPagination, HeaderType, SortTypeKeys } from '@/entities/common/model/types';
|
||||
import { IMAGE_ROOT } from '@/shared/constants/common';
|
||||
import {
|
||||
useSetHeaderTitle,
|
||||
useSetHeaderType,
|
||||
useSetFooterMode,
|
||||
useSetHeaderTitle,
|
||||
useSetHeaderType,
|
||||
useSetFooterMode,
|
||||
useSetOnBack
|
||||
} from '@/widgets/sub-layout/use-sub-layout';
|
||||
import { JSX, useEffect, useState } from 'react';
|
||||
@@ -19,7 +19,8 @@ import {
|
||||
ExtensionAlimtalkDownloadExcelParams,
|
||||
ExtensionAlimtalkDownloadExcelResponse,
|
||||
ExtensionAlimtalkListParams,
|
||||
ExtensionAlimtalkListResponse
|
||||
ExtensionAlimtalkListResponse,
|
||||
ServiceCode
|
||||
} from '@/entities/additional-service/model/alimtalk/types';
|
||||
import moment from 'moment';
|
||||
import { useExtensionAlimtalkListMutation } from '@/entities/additional-service/api/alimtalk/use-extansion-alimtalk-list-mutation';
|
||||
@@ -27,47 +28,29 @@ import { useExtensionAlimtalkDownloadExcelMutation } from '@/entities/additional
|
||||
import { ListDateGroup } from '@/entities/additional-service/ui/list-date-group';
|
||||
import { AdditionalServiceCategory } from '@/entities/additional-service/model/types';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||
import { snackBar } from '@/shared/lib';
|
||||
import { EmailBottomSheet } from '@/entities/common/ui/email-bottom-sheet';
|
||||
import { AlimtalkFilter } from '@/entities/additional-service/ui/filter/alimtalk-filter';
|
||||
|
||||
export const AlimtalkListPage = () => {
|
||||
const { navigate } = useNavigate();
|
||||
const userMid = useStore.getState().UserStore.mid;
|
||||
|
||||
const [onActionIntersect, setOnActionIntersect] = useState<boolean>(false);
|
||||
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) {
|
||||
callList();
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('Element is no longer intersecting with the root.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const { setTarget } = useIntersectionObserver({
|
||||
threshold: 1,
|
||||
onIntersect
|
||||
});
|
||||
|
||||
const [sortType, setSortType] = useState<SortTypeKeys>(SortTypeKeys.LATEST);
|
||||
const [listItems, setListItems] = useState<Array<AlimtalkListContent>>([]);
|
||||
const [filterOn, setFilterOn] = useState<boolean>(false);
|
||||
const [nextCursor, setNextCursor] = useState<string | null>(null);
|
||||
const [pageParam, setPageParam] = useState<DefaultRequestPagination>(DEFAULT_PAGE_PARAM);
|
||||
const [mid, setMid] = useState<string>(userMid);
|
||||
const [searchCl, setSearchCl] = useState<AlimtalkSearchCl>(AlimtalkSearchCl.BUYER_NAME);
|
||||
const [searchValue, setSearchValue] = useState<string>();
|
||||
const [paymentMethod, setPaymentMethod] = useState<string>();
|
||||
const [searchValue, setSearchValue] = useState<string>('');
|
||||
const [serviceCode, setServiceCode] = useState<ServiceCode>(ServiceCode.CARD);
|
||||
const [alimCl, setAlimCl] = useState<AlimtalkAlimCl>(AlimtalkAlimCl.DEPOSIT_REQUEST);
|
||||
const [fromDate, setFromDate] = useState<string>(moment().format('YYYYMMDD'));
|
||||
const [toDate, setToDate] = useState<string>(moment().format('YYYYMMDD'));
|
||||
const [sendType, setSendType] = useState<AlimtalkSendType>(AlimtalkSendType.ALL);
|
||||
const [sendCl, setSendCl] = useState<AlimTalkSendCl>(AlimTalkSendCl.ALL);
|
||||
|
||||
const [emailBottomSheetOn, setEmailBottomSheetOn] = useState<boolean>(false);
|
||||
const { mutateAsync: extensionAlimtalkList } = useExtensionAlimtalkListMutation();
|
||||
const { mutateAsync: extensionAlimtalkDownloadExcel } = useExtensionAlimtalkDownloadExcelMutation();
|
||||
|
||||
@@ -79,101 +62,97 @@ export const AlimtalkListPage = () => {
|
||||
});
|
||||
|
||||
const callList = (option?: {
|
||||
sortType?: SortTypeKeys,
|
||||
resetPage?: boolean
|
||||
}) => {
|
||||
setOnActionIntersect(false);
|
||||
|
||||
const currentPageParam = option?.resetPage
|
||||
? { ...DEFAULT_PAGE_PARAM, sortType: option?.sortType ?? sortType }
|
||||
: { ...pageParam, sortType: option?.sortType ?? sortType };
|
||||
|
||||
setPageParam(currentPageParam);
|
||||
|
||||
sortType?: SortTypeKeys
|
||||
}) => {
|
||||
let params: ExtensionAlimtalkListParams = {
|
||||
mid: mid,
|
||||
searchCl: searchCl,
|
||||
searchValue: searchValue,
|
||||
serviceCode: paymentMethod,
|
||||
fromDate: fromDate,
|
||||
toDate: toDate,
|
||||
sendType: sendType,
|
||||
sendCl: sendCl,
|
||||
page: currentPageParam
|
||||
};
|
||||
extensionAlimtalkList(params).then((rs: ExtensionAlimtalkListResponse) => {
|
||||
setListItems(option?.resetPage ? rs.content : [
|
||||
...listItems,
|
||||
...rs.content
|
||||
]);
|
||||
if (rs.hasNext) {
|
||||
setNextCursor(rs.nextCursor);
|
||||
setPageParam({
|
||||
...currentPageParam,
|
||||
cursor: rs.nextCursor
|
||||
});
|
||||
setOnActionIntersect(true);
|
||||
}
|
||||
else {
|
||||
setNextCursor(null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const callDownloadExcel = () => {
|
||||
let params: ExtensionAlimtalkDownloadExcelParams = {
|
||||
mid: mid,
|
||||
searchCl: searchCl,
|
||||
searchValue: searchValue,
|
||||
paymentMethod: paymentMethod,
|
||||
serviceCode: serviceCode,
|
||||
alimCl: alimCl,
|
||||
fromDate: fromDate,
|
||||
toDate: toDate,
|
||||
sendType: sendType,
|
||||
sendCl: sendCl
|
||||
sendCl: sendCl,
|
||||
page: pageParam
|
||||
};
|
||||
extensionAlimtalkDownloadExcel(params).then((rs: ExtensionAlimtalkDownloadExcelResponse) => {
|
||||
|
||||
if (params.page) {
|
||||
params.page.sortType = option?.sortType || sortType;
|
||||
setPageParam(params.page);
|
||||
}
|
||||
|
||||
extensionAlimtalkList(params).then((rs: ExtensionAlimtalkListResponse) => {
|
||||
setListItems(rs.content);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const onClickToOpenEmailBottomSheet = () => {
|
||||
setEmailBottomSheetOn(true);
|
||||
}
|
||||
|
||||
const onSendRequest = (selectedEmail?: string) => {
|
||||
if (selectedEmail) {
|
||||
const params: ExtensionAlimtalkDownloadExcelParams = {
|
||||
mid: mid,
|
||||
searchCl: searchCl,
|
||||
searchValue: searchValue,
|
||||
serviceCode: serviceCode,
|
||||
alimCl: alimCl,
|
||||
fromDate: fromDate,
|
||||
toDate: toDate,
|
||||
sendType: sendType,
|
||||
sendCl: sendCl,
|
||||
//email: selectedEmail
|
||||
};
|
||||
extensionAlimtalkDownloadExcel(params).then((rs: ExtensionAlimtalkDownloadExcelResponse) => {
|
||||
console.log('Excel Download Status:', rs.status);
|
||||
});
|
||||
};
|
||||
setEmailBottomSheetOn(false);
|
||||
};
|
||||
|
||||
const onClickToNavigate = () => {
|
||||
navigate(PATHS.additionalService.alimtalk.setting);
|
||||
};
|
||||
const onClickToDownloadExcel = () => {
|
||||
callDownloadExcel();
|
||||
};
|
||||
|
||||
|
||||
const onClickToOpenFilter = () => {
|
||||
setFilterOn(!filterOn);
|
||||
};
|
||||
const getAlimtalkList = () => {
|
||||
let rs: JSX.Element[] = [];
|
||||
let rs = [];
|
||||
let date = '';
|
||||
let list: AlimtalkListContent[] = [];
|
||||
let list = [];
|
||||
for (let i = 0; i < listItems.length; i++) {
|
||||
// sendDate format: "20211018140420" (YYYYMMDDHHmmss)
|
||||
let sendDate = listItems[i]?.sendDate || '';
|
||||
let itemDate = sendDate.substring(0, 8);
|
||||
if (i === 0) {
|
||||
date = itemDate;
|
||||
}
|
||||
if (date !== itemDate) {
|
||||
// 날짜가 바뀌면 이전 리스트를 푸시
|
||||
if (list.length > 0) {
|
||||
rs.push(
|
||||
<ListDateGroup
|
||||
additionalServiceCategory={AdditionalServiceCategory.Alimtalk}
|
||||
mid={mid}
|
||||
key={date + '-' + i}
|
||||
date={date}
|
||||
items={list as any}
|
||||
></ListDateGroup>
|
||||
);
|
||||
let item = listItems[i];
|
||||
if (!!item) {
|
||||
// sendDate format: "20211018140420" (YYYYMMDDHHmmss)
|
||||
let sendDate = item?.sendDate || '';
|
||||
let itemDate = sendDate.substring(0, 8);
|
||||
if (!!itemDate) {
|
||||
if (i === 0) {
|
||||
date = itemDate;
|
||||
}
|
||||
if (date !== itemDate) {
|
||||
date = itemDate;
|
||||
if (list.length > 0) {
|
||||
rs.push(
|
||||
<ListDateGroup
|
||||
additionalServiceCategory={AdditionalServiceCategory.Alimtalk}
|
||||
mid={mid}
|
||||
key={date + '-' + i}
|
||||
date={date}
|
||||
items={list as any}
|
||||
></ListDateGroup>
|
||||
);
|
||||
}
|
||||
list = [];
|
||||
}
|
||||
list.push(item);
|
||||
}
|
||||
date = itemDate;
|
||||
list = [];
|
||||
}
|
||||
list.push(listItems[i] as any);
|
||||
}
|
||||
if (list.length > 0) {
|
||||
rs.push(
|
||||
@@ -188,15 +167,15 @@ export const AlimtalkListPage = () => {
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
// 필터 조건이 변경되면 첫 페이지부터 다시 시작
|
||||
callList({ resetPage: true });
|
||||
callList();
|
||||
}, [
|
||||
mid,
|
||||
searchCl,
|
||||
searchValue,
|
||||
paymentMethod,
|
||||
serviceCode,
|
||||
alimCl,
|
||||
fromDate,
|
||||
toDate,
|
||||
sendType,
|
||||
@@ -211,49 +190,78 @@ export const AlimtalkListPage = () => {
|
||||
<section className="summary-section no-border">
|
||||
<div className="credit-controls">
|
||||
<div>
|
||||
<input
|
||||
className="credit-period"
|
||||
type="text"
|
||||
value={ moment(fromDate).format('YYYY.MM.DD') + '-' + moment(toDate).format('YYYY.MM.DD') }
|
||||
readOnly={ true }
|
||||
<input
|
||||
className="credit-period"
|
||||
type="text"
|
||||
value={moment(fromDate).format('YYYY.MM.DD') + '-' + moment(toDate).format('YYYY.MM.DD')}
|
||||
readOnly={true}
|
||||
/>
|
||||
<button
|
||||
className="filter-btn"
|
||||
<button
|
||||
className="filter-btn"
|
||||
aria-label="필터"
|
||||
onClick={ () => onClickToOpenFilter() }
|
||||
onClick={() => onClickToOpenFilter()}
|
||||
>
|
||||
<img
|
||||
src={ IMAGE_ROOT + '/ico_setting.svg' }
|
||||
<img
|
||||
src={IMAGE_ROOT + '/ico_setting.svg'}
|
||||
alt="검색옵션"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
className="download-btn"
|
||||
<button
|
||||
className="download-btn"
|
||||
aria-label="다운로드"
|
||||
onClick={ () => onClickToDownloadExcel() }
|
||||
onClick={() => onClickToOpenEmailBottomSheet()}
|
||||
>
|
||||
<img
|
||||
src={ IMAGE_ROOT + '/ico_download.svg' }
|
||||
<img
|
||||
src={IMAGE_ROOT + '/ico_download.svg'}
|
||||
alt="다운로드"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<section className="transaction-list">
|
||||
{ getAlimtalkList() }
|
||||
<div ref={setTarget}></div>
|
||||
{getAlimtalkList()}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<div className="apply-row">
|
||||
<button
|
||||
<button
|
||||
className="btn-50 btn-blue flex-1"
|
||||
onClick={ () => onClickToNavigate() }
|
||||
onClick={() => onClickToNavigate()}
|
||||
>서비스 설정</button>
|
||||
</div>
|
||||
<AlimtalkFilter
|
||||
filterOn={filterOn}
|
||||
setFilterOn={setFilterOn}
|
||||
mid={mid}
|
||||
searchCl={searchCl}
|
||||
searchValue={searchValue}
|
||||
fromDate={fromDate}
|
||||
toDate={toDate}
|
||||
serviceCode={serviceCode}
|
||||
alimCl={alimCl}
|
||||
sendType={sendType}
|
||||
sendCl={sendCl}
|
||||
setMid={setMid}
|
||||
setSearchCl={setSearchCl}
|
||||
setSearchValue={setSearchValue}
|
||||
setFromDate={setFromDate}
|
||||
setToDate={setToDate}
|
||||
setServiceCode={setServiceCode}
|
||||
setAlimCl={setAlimCl}
|
||||
setSendType={setSendType}
|
||||
setSendCl={setSendCl}
|
||||
></AlimtalkFilter>
|
||||
<EmailBottomSheet
|
||||
bottomSheetOn={emailBottomSheetOn}
|
||||
setBottomSheetOn={setEmailBottomSheetOn}
|
||||
imageSave={false}
|
||||
sendEmail={true}
|
||||
sendRequest={onSendRequest}
|
||||
>
|
||||
</EmailBottomSheet>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user