From 9051d224eae2cccd20b5f2d2015fbb1480e422c1 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 9 Jan 2024 16:33:17 +0800 Subject: [PATCH] create DN --- src/pages/DemandNote/Create/DataGrid.js | 2 +- src/pages/DemandNote/Create/SearchForm.js | 83 +++++++++++++++++++++-- src/pages/DemandNote/Create/index.js | 9 ++- src/pages/DemandNote/Search/index.js | 2 + 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/src/pages/DemandNote/Create/DataGrid.js b/src/pages/DemandNote/Create/DataGrid.js index 9dad92c..0a4bc9f 100644 --- a/src/pages/DemandNote/Create/DataGrid.js +++ b/src/pages/DemandNote/Create/DataGrid.js @@ -50,7 +50,7 @@ export default function SearchPublicNoticeTable({ recordList }) { headerName: 'Status', flex: 1, renderCell: (params) => { - return PublicNoteStatusUtils.getStatusByTextEng(params.row.status); + return PublicNoteStatusUtils.getStatusByTextEng(params.row.status, params.row.creditor); } }, { diff --git a/src/pages/DemandNote/Create/SearchForm.js b/src/pages/DemandNote/Create/SearchForm.js index 54c317f..6b46abd 100644 --- a/src/pages/DemandNote/Create/SearchForm.js +++ b/src/pages/DemandNote/Create/SearchForm.js @@ -14,15 +14,23 @@ import * as DateUtils from "utils/DateUtils"; import * as UrlUtils from "utils/ApiPathConst"; import * as HttpUtils from "utils/HttpUtils"; import { useNavigate } from "react-router-dom"; +import { notifyDownloadSuccess } from 'utils/CommonFunction'; + + // ==============================|| DASHBOARD - DEFAULT ||============================== // -const SearchPublicNoticeForm = ({ applySearch, issueComboData }) => { +const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _publishCount }) => { const [isFailPopUp, setIsFailPopUp] = React.useState(false); const [failText, setFailText] = React.useState(""); + const [isSuccessPopUp, setIsSuccessPopUp] = React.useState(false); + const [resultCount, setResultCount] = React.useState(0); + const [issueSelected, setIssueSelected] = React.useState({}); + const [paymentCount, setPaymentCount] = React.useState(0); + const [publishCount, setPublishCount] = React.useState(0); const [issueCombo, setIssueCombo] = React.useState([]); const navigate = useNavigate() @@ -48,7 +56,14 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData }) => { } }, [issueComboData]); - + React.useEffect(() => { + setPaymentCount(_paymentCount); + }, [_paymentCount]); + + React.useEffect(() => { + setPublishCount(_publishCount); + }, [_publishCount]); + React.useEffect(() => { onPreView(); }, [issueSelected]); @@ -69,14 +84,33 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData }) => { } else { HttpUtils.post({ url: UrlUtils.DEMAND_NOTE_CREATE + "/" + issueSelected.id, - onSuccess: function () { - navigate('/paymentPage/demandNote'); + onSuccess: function (responseData) { + setResultCount(responseData.count); + setIsSuccessPopUp(true); } }); } }; + const fileDownload = () => { + HttpUtils.fileDownload({ + url: UrlUtils.DEMAND_NOTE_EXPORT, + params: { + "issueId": issueSelected.id + }, + onSuccess: function () { + notifyDownloadSuccess(); + } + }); + } + + const onNavigate = () => { + setIsSuccessPopUp(false); + if(resultCount > 0) + navigate('/paymentPage/demandNote'); + }; + const onPreView = () => { if (!issueSelected?.id) { return; @@ -104,7 +138,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData }) => { {/*row 2*/} - + { Preview */} - + + + + Pending Payment: {paymentCount} + + + + Pending Publish: {publishCount} +
@@ -165,6 +207,35 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData }) => {
+
+ setIsSuccessPopUp(false)} > + Create Result + + + + Created DN record: {resultCount} + + {resultCount == 0 ? <> : + + + + } + + + + + + + +
); }; diff --git a/src/pages/DemandNote/Create/index.js b/src/pages/DemandNote/Create/index.js index 1c6cafe..2d0d5e4 100644 --- a/src/pages/DemandNote/Create/index.js +++ b/src/pages/DemandNote/Create/index.js @@ -35,6 +35,9 @@ const Index = () => { const [searchCriteria, setSearchCriteria] = React.useState({}); const [onReady, setOnReady] = React.useState(false); + const [paymentCount, setPaymentCount] = React.useState(0); + const [publishCount, setPublishCount] = React.useState(0); + React.useEffect(()=>{ getIssueCombo(); },[]); @@ -51,7 +54,9 @@ const Index = () => { HttpUtils.get({ url: UrlUtils.DEMAND_NOTE_PREVIEW+"/"+searchCriteria.issueId, onSuccess: function(responseData){ - setRecord(responseData); + setRecord(responseData.records); + setPaymentCount(responseData.paymentCount); + setPublishCount(responseData.publishCount); } }); } @@ -88,6 +93,8 @@ const Index = () => {
{/*row 2*/} diff --git a/src/pages/DemandNote/Search/index.js b/src/pages/DemandNote/Search/index.js index b0ab178..cbe9141 100644 --- a/src/pages/DemandNote/Search/index.js +++ b/src/pages/DemandNote/Search/index.js @@ -18,6 +18,7 @@ const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/Loa const SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' +import { notifyDownloadSuccess } from 'utils/CommonFunction'; const BackgroundHead = { backgroundImage: `url(${titleBackgroundImg})`, @@ -77,6 +78,7 @@ const UserSearchPage_Individual = () => { url: UrlUtils.DEMAND_NOTE_EXPORT, params: searchCriteria, onSuccess: function () { + notifyDownloadSuccess(); } }); }