세금계산서 엑셀다운로드 추가
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL_VAT_RETURN } from '@/shared/api/api-url-vat-return';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { NiceAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
VatReturnDownloadExcelParams,
|
||||
VatReturnDownloadExcelResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
import { getHeaderUserAgent } from '@/shared/constants/url';
|
||||
|
||||
export const vatReturnDownloadExcel = (params: VatReturnDownloadExcelParams) => {
|
||||
let headerOptions = {
|
||||
menuId: 48,
|
||||
apiType: 'SELECT'
|
||||
};
|
||||
let options = {
|
||||
headers: {
|
||||
'X-User-Agent': getHeaderUserAgent(headerOptions)
|
||||
}
|
||||
};
|
||||
return resultify(
|
||||
axios.post<VatReturnDownloadExcelResponse>(API_URL_VAT_RETURN.vatReturnDownloadExcel(), params, options),
|
||||
);
|
||||
};
|
||||
|
||||
export const useVatReturnDownloadExcelMutation = (options?: UseMutationOptions<VatReturnDownloadExcelResponse, NiceAxiosError, VatReturnDownloadExcelParams>) => {
|
||||
const mutation = useMutation<VatReturnDownloadExcelResponse, NiceAxiosError, VatReturnDownloadExcelParams>({
|
||||
...options,
|
||||
mutationFn: (params: VatReturnDownloadExcelParams) => vatReturnDownloadExcel(params),
|
||||
});
|
||||
|
||||
return {
|
||||
...mutation,
|
||||
};
|
||||
};
|
||||
@@ -165,4 +165,13 @@ export interface TransactionDetails {
|
||||
supplyAmount: number;
|
||||
taxAmount: number;
|
||||
remarks: string;
|
||||
};
|
||||
};
|
||||
export interface VatReturnDownloadExcelParams {
|
||||
email: string;
|
||||
mid: string;
|
||||
startMonth: string;
|
||||
endMonth: string;
|
||||
receiptType: VatReturnReceiptType;
|
||||
targetType: VatReturnTargetType;
|
||||
};
|
||||
export interface VatReturnDownloadExcelResponse {};
|
||||
@@ -8,6 +8,8 @@ import { DefaultRequestPagination, SortTypeKeys } from '@/entities/common/model/
|
||||
import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant';
|
||||
import {
|
||||
DetailData,
|
||||
VatReturnDownloadExcelParams,
|
||||
VatReturnDownloadExcelResponse,
|
||||
VatReturnListContent,
|
||||
VatReturnListParams,
|
||||
VatReturnListResponse,
|
||||
@@ -22,7 +24,8 @@ import useIntersectionObserver from '@/widgets/intersection-observer';
|
||||
import { TaxInvoiceDetail } from './detail/tax-invoice-detail';
|
||||
import { showAlert } from '@/widgets/show-alert';
|
||||
import { checkGrant } from '@/shared/lib/check-grant';
|
||||
import { TaxInvoiceSample } from '@/entities/common/ui/tax-invoice-sample';
|
||||
import { useVatReturnDownloadExcelMutation } from '../api/use-vat-return-download-excel-mutation';
|
||||
import { snackBar } from '@/shared/lib';
|
||||
|
||||
/* 세금계산서 48 */
|
||||
const menuId = 48;
|
||||
@@ -42,11 +45,12 @@ export const ListWrap = () => {
|
||||
const [targetType, setTargetType] = useState<VatReturnTargetType>(VatReturnTargetType.ALL);
|
||||
|
||||
const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState<boolean>(false);
|
||||
const [taxInvoiceSampleOn, setTaxInvoiceSampleOn] = useState<boolean>(false);
|
||||
|
||||
|
||||
const [detailOn, setDetailOn] = useState<boolean>(false);
|
||||
const [detailTaxInvoiceNumber, setDetailTaxInvoiceNumber] = useState<string>('');
|
||||
|
||||
const { mutateAsync: vatReturnList } = useVatReturnListMutation();
|
||||
const { mutateAsync: vatReturnDownloadExcel } = useVatReturnDownloadExcelMutation();
|
||||
|
||||
const onIntersect: IntersectionObserverCallback = (entries: Array<IntersectionObserverEntry>) => {
|
||||
entries.forEach((entry: IntersectionObserverEntry) => {
|
||||
@@ -132,8 +136,26 @@ export const ListWrap = () => {
|
||||
selectedMode: DownloadSelectedMode,
|
||||
userEmail?: string
|
||||
) => {
|
||||
if(selectedMode === DownloadSelectedMode.IMAGE){
|
||||
setTaxInvoiceSampleOn(true);
|
||||
if(selectedMode === DownloadSelectedMode.EMAIL
|
||||
&& !!userEmail
|
||||
){
|
||||
let params: VatReturnDownloadExcelParams = {
|
||||
email: userEmail,
|
||||
mid: mid,
|
||||
startMonth: startMonth,
|
||||
endMonth: endMonth,
|
||||
receiptType: receiptType,
|
||||
targetType: targetType
|
||||
};
|
||||
vatReturnDownloadExcel(params).then((rs: VatReturnDownloadExcelResponse) => {
|
||||
console.log(rs);
|
||||
snackBar('이메일로 엑셀파일 요청이 완료되었습니다.');
|
||||
}).catch((e: any) => {
|
||||
if(e.response?.data?.error?.message){
|
||||
snackBar(e.response?.data?.error?.message);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -262,13 +284,6 @@ export const ListWrap = () => {
|
||||
sendRequest={ onRequestDownloadExcel }
|
||||
></DownloadBottomSheet>
|
||||
}
|
||||
{ !!taxInvoiceSampleOn &&
|
||||
<TaxInvoiceSample
|
||||
taxInvoiceSampleOn={ taxInvoiceSampleOn }
|
||||
setTaxInvoiceSampleOn={ setTaxInvoiceSampleOn }
|
||||
></TaxInvoiceSample>
|
||||
|
||||
}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user