// material-ui import { Button, Grid, TextField, Autocomplete, Typography, Dialog, DialogTitle, DialogContent, DialogActions, } from '@mui/material'; import MainCard from "components/MainCard"; import * as React from "react"; import * as FormatUtils from "utils/FormatUtils"; 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'; import { PNSPS_BUTTON_THEME } from "../../../themes/buttonConst"; import { ThemeProvider } from "@emotion/react"; import { useIntl } from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const SearchPublicNoticeForm = ({ applySearch, issueComboData }) => { const [isFailPopUp, setIsFailPopUp] = React.useState(false); const [failText, setFailText] = React.useState(""); const [confirmPopUp, setConfirmPopUp] = React.useState(false); const [dueDate, setDueDate] = React.useState(DateUtils.dateValue(DateUtils.dateValue((new Date().setDate(new Date().getDate() + 1))))); // const [isSuccessPopUp, setIsSuccessPopUp] = React.useState(false); // const [resultCount, setResultCount] = React.useState(0); // const [dnIdList, setDnIdList] = React.useState([]); const [issueSelected, setIssueSelected] = React.useState({}); // const [paymentCount, setPaymentCount] = React.useState(0); // const [publishCount, setPublishCount] = React.useState(0); const [issueCombo, setIssueCombo] = React.useState([]); const [waitDownload, setWaitDownload] = React.useState(false); // const navigate = useNavigate() const intl = useIntl(); const { locale } = intl; React.useEffect(() => { if (issueComboData && issueComboData.length > 0) { setIssueCombo(issueComboData); } }, [issueComboData]); // React.useEffect(() => { // setPaymentCount(_paymentCount); // }, [_paymentCount]); // React.useEffect(() => { // setPublishCount(_publishCount); // }, [_publishCount]); React.useEffect(() => { onPreView(); }, [issueSelected]); function getIssueLabel(data) { let issueYear = data.issueYear let volume = data.volume; let issueNo = data.issueNo; let issueDate = data.issueDate; if (locale === 'zh-HK') { return issueYear + " 第" + volume + "卷," + " 第" + issueNo + "期," + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + " (" + DateUtils.getWeekdayStr_ZH(issueDate) + ")"; } else if (locale === 'zh-CN') { return issueYear + " 第" + volume + "卷," + " 第" + issueNo + "期," + " " + DateUtils.dateFormat(issueDate, "YYYY年MM月DD日") + " (" + DateUtils.getWeekdayStr_CN(issueDate) + ")"; } return issueYear + " Vol. " + FormatUtils.zeroPad(volume, 3) + ", No. " + FormatUtils.zeroPad(issueNo, 2) + ", " + DateUtils.dateFormat(issueDate, "D MMM YYYY (ddd)"); } const onSubmit = () => { if (!issueSelected?.id) { setFailText("Fail Create: Please select Gazette Issue."); setIsFailPopUp(true); return; } else { setDueDate(DateUtils.dateValue((new Date().setDate(new Date().getDate() + 1)))); doDnExport(); } }; const doDnExport= () => { // setConfirmPopUp(false); setWaitDownload(true) HttpUtils.fileDownload({ url: UrlUtils.GDN_EXPORT, params: { issueId: issueSelected.id }, onResponse: () => { setTimeout(()=> setWaitDownload(false), 500) // location.reload(); } }); } // const fileDownload = () => { // HttpUtils.fileDownload({ // method: 'post', // url: UrlUtils.DEMAND_NOTE_EXPORT, // params: { // "dnIdList": dnIdList // }, // onSuccess: function () { // notifyDownloadSuccess(); // } // }); // } // const onNavigate = () => { // setIsSuccessPopUp(false); // if (resultCount > 0) // navigate('/paymentPage/demandNote'); // }; const onPreView = () => { if (!issueSelected?.id) { return; } const temp = { issueId: issueSelected.id, start:0, limit:10 }; applySearch(temp); }; return (
{/*row 1*/} {/*row 1*/} Please Select Gazette Issue : {/*row 2*/} getIssueLabel(option)} onChange={(event, newValue) => { if (newValue !== null) { setIssueSelected(newValue); } }} renderInput={(params) => ( )} /> {/* Pending Payment: {paymentCount} Pending Publish: {publishCount} */}
setIsFailPopUp(false)} PaperProps={{ sx: { minWidth: '40vw', maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } } }} > Action Fail {failText}
setConfirmPopUp(false)} PaperProps={{ sx: { minWidth: '40vw', maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } } }} > Create Confirm Due Date: { setDueDate(newValue.currentTarget.value) }} InputLabelProps={{ shrink: true }} />
); }; export default SearchPublicNoticeForm;