// material-ui import { Button, Grid, TextField, Autocomplete, Typography } from '@mui/material'; import MainCard from "components/MainCard"; import { useForm } from "react-hook-form"; import * as React from "react"; // import * as DateUtils from "utils/DateUtils"; import {PNSPS_BUTTON_THEME} from "../../themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; import * as ComboData from "utils/ComboData"; import * as DateUtils from "utils/DateUtils"; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); import {DatePicker} from "@mui/x-date-pickers/DatePicker"; import dayjs from "dayjs"; import {DemoItem} from "@mui/x-date-pickers/internals/demo"; import {LocalizationProvider} from "@mui/x-date-pickers/LocalizationProvider"; import {AdapterDayjs} from "@mui/x-date-pickers/AdapterDayjs"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const SearchPublicNoticeForm = ({ applySearch, generateReport, onLoad }) => { const [sysTxnMinDate, setSysTxnMinDate] = React.useState(null); const [sysTxnMaxDate, setsysTxnMaxDate] = React.useState(null); const [txnMinDate, setTxnMinDate] = React.useState(null); const [txnMaxDate, setTxnMaxDate] = React.useState(null); const [collMinDate, setCollMinDate] = React.useState(null); const [collMaxDate, setCollMaxDate] = React.useState(null); const [sysTxnFromDateValue, setSysTxnFromDateValue] = React.useState(null); const [sysTxnToDateValue, setSysTxnToDateValue] = React.useState(null); const [txnFromDateValue, setTxnFromDateValue] = React.useState(null); const [txnToDateValue, setTxnToDateValue] = React.useState(null); const [collFromDateValue, setCollFromDateValue] = React.useState(null); const [collToDateValue, setCollToDateValue] = React.useState(null); const [status, setStatus] = React.useState(ComboData.paymentStatus[0]); const [method, setMethod] = React.useState(ComboData.paymentMethod[0]); const marginBottom = 2.5; const { register, handleSubmit } = useForm() React.useEffect(() => { setSysTxnFromDateValue(sysTxnMinDate); }, [sysTxnMinDate]); React.useEffect(() => { setSysTxnToDateValue(sysTxnMaxDate); }, [sysTxnMaxDate]); React.useEffect(() => { setTxnFromDateValue(txnMinDate); }, [txnMinDate]); React.useEffect(() => { setTxnToDateValue(txnMaxDate); }, [txnMaxDate]); React.useEffect(() => { setCollFromDateValue(collMinDate); }, [collMinDate]); React.useEffect(() => { setCollToDateValue(collMaxDate); }, [collMaxDate]); const onSubmit = () => { let sentSysTxnDateFrom = ""; let sentSysTxnDateTo = ""; let sentTxnDateFrom = ""; let sentTxnDateTo = ""; let sentCollDateFrom = ""; let sentCollDateTo = ""; // Invalid Date if (sysTxnFromDateValue != "dd / mm / yyyy" && sysTxnToDateValue != "dd / mm / yyyy" ) { sentSysTxnDateFrom = DateUtils.dateValue(sysTxnFromDateValue)!="Invalid Date"?DateUtils.dateValue(sysTxnFromDateValue):"" sentSysTxnDateTo = DateUtils.dateValue(sysTxnToDateValue)!="Invalid Date"?DateUtils.dateValue(sysTxnToDateValue):"" } if (txnFromDateValue != "dd / mm / yyyy" && txnToDateValue != "dd / mm / yyyy") { sentTxnDateFrom = DateUtils.dateValue(txnFromDateValue)!="Invalid Date"?DateUtils.dateValue(txnFromDateValue):"" sentTxnDateTo = DateUtils.dateValue(txnToDateValue)!="Invalid Date"?DateUtils.dateValue(txnToDateValue):"" } if (collFromDateValue != "dd / mm / yyyy" && collToDateValue != "dd / mm / yyyy") { sentCollDateFrom = DateUtils.dateValue(collFromDateValue)!="Invalid Date"?DateUtils.dateValue(collFromDateValue):"" sentCollDateTo = DateUtils.dateValue(collToDateValue)!="Invalid Date"?DateUtils.dateValue(collToDateValue):"" } const temp = { PaymentMethod:(method?.type && method?.type != 'Please Select') ? method?.type : "", PaymentStatus : (status?.type && status?.type != 'all') ? status?.type : "", SysTxnDateFrom: sentSysTxnDateFrom, SysTxnDateTo: sentSysTxnDateTo, TxnDateFrom: sentTxnDateFrom, TxnDateTo: sentTxnDateTo, CollDateFrom: sentCollDateFrom, CollDateTo: sentCollDateTo, }; // console.log(temp) applySearch(temp); }; const generateFileHandler = (fileFormart) => () => { let sentSysTxnDateFrom = ""; let sentSysTxnDateTo = ""; let sentTxnDateFrom = ""; let sentTxnDateTo = ""; let sentCollDateFrom = ""; let sentCollDateTo = ""; if (sysTxnFromDateValue != "dd / mm / yyyy" && sysTxnToDateValue != "dd / mm / yyyy" ) { sentSysTxnDateFrom = DateUtils.dateValue(sysTxnFromDateValue)!="Invalid Date"?DateUtils.dateValue(sysTxnFromDateValue):"" sentSysTxnDateTo = DateUtils.dateValue(sysTxnToDateValue)!="Invalid Date"?DateUtils.dateValue(sysTxnToDateValue):"" } if (txnFromDateValue != "dd / mm / yyyy" && txnToDateValue != "dd / mm / yyyy") { sentTxnDateFrom = DateUtils.dateValue(txnFromDateValue)!="Invalid Date"?DateUtils.dateValue(txnFromDateValue):"" sentTxnDateTo = DateUtils.dateValue(txnToDateValue)!="Invalid Date"?DateUtils.dateValue(txnToDateValue):"" } if (collFromDateValue != "dd / mm / yyyy" && collToDateValue != "dd / mm / yyyy") { sentCollDateFrom = DateUtils.dateValue(collFromDateValue)!="Invalid Date"?DateUtils.dateValue(collFromDateValue):"" sentCollDateTo = DateUtils.dateValue(collToDateValue)!="Invalid Date"?DateUtils.dateValue(collToDateValue):"" } const temp = { PaymentMethod:(method?.type && method?.type != 'Please Select') ? method?.type : "", PaymentStatus : (status?.type && status?.type != 'all') ? status?.type : "", SysTxnDateFrom: sentSysTxnDateFrom, SysTxnDateTo: sentSysTxnDateTo, TxnDateFrom: sentTxnDateFrom, TxnDateTo: sentTxnDateTo, CollDateFrom: sentCollDateFrom, CollDateTo: sentCollDateTo, ReportFormat:fileFormart }; generateReport(temp); } const clearHandler = () => () => { setSysTxnMinDate(null) setsysTxnMaxDate(null) setTxnMinDate(null) setTxnMaxDate(null) setCollMinDate(null) setCollMaxDate(null) setSysTxnFromDateValue("") setSysTxnToDateValue("") setTxnFromDateValue("") setTxnToDateValue("") setCollFromDateValue("") setCollToDateValue("") setStatus(ComboData.paymentStatus[0]) setMethod(ComboData.paymentMethod[0]) } return (
{/*row 1*/} Submit Form {/*row 2*/} options} options={ComboData.paymentMethod} value={method} getOptionLabel={(option) => option.label} inputValue={method?.label ? method?.label : ""} onChange={(event, newValue) => { if (newValue !== null) { setMethod(newValue); } }} renderInput={(params) => ( )} InputLabelProps={{ shrink: true }} /> options} options={ComboData.paymentStatus} value={status} getOptionLabel={(option) => option.label} inputValue={status?.label ? status?.label : ""} onChange={(event, newValue) => { if (newValue !== null) { setStatus(newValue); } }} renderInput={(params) => ( )} InputLabelProps={{ shrink: true }} /> setReceiptFromError(newError)} slotProps={{ field: { readOnly: true, }, textField: { // helperText: receiptFromErrorMessage, InputLabelProps: { shrink: true } }, }} format="DD/MM/YYYY" label="PNSPS Transaction Date (From)" value={sysTxnMinDate === null ? null : dayjs(sysTxnMinDate)} maxDate={sysTxnMaxDate === null ? null : dayjs(sysTxnMaxDate)} onChange={(newValue) => { setSysTxnMinDate(newValue); }} /> setReceiptFromError(newError)} slotProps={{ field: { readOnly: true, }, textField: { // helperText: receiptFromErrorMessage, InputLabelProps: { shrink: true } }, }} format="DD/MM/YYYY" label="PNSPS Transaction Date (To)" value={sysTxnMaxDate === null ? null : dayjs(sysTxnMaxDate)} minDate={sysTxnMinDate === null ? null : dayjs(sysTxnMinDate)} onChange={(newValue) => { // console.log(newValue) setsysTxnMaxDate(newValue); }} /> {/*row 3*/} setReceiptFromError(newError)} slotProps={{ field: { readOnly: true, }, textField: { // helperText: receiptFromErrorMessage, InputLabelProps: { shrink: true } }, }} format="DD/MM/YYYY" label="FI Transaction Date (From)" value={txnMinDate === null ? null : dayjs(txnMinDate)} maxDate={txnMaxDate === null ? null : dayjs(txnMaxDate)} onChange={(newValue) => { // console.log(newValue) setTxnMinDate(newValue); }} /> setReceiptFromError(newError)} slotProps={{ field: { readOnly: true, }, textField: { // helperText: receiptFromErrorMessage, InputLabelProps: { shrink: true } }, }} format="DD/MM/YYYY" label="FI Transaction Date (To)" value={txnMaxDate === null ? null : dayjs(txnMaxDate)} minDate={txnMinDate === null ? null : dayjs(txnMinDate)} onChange={(newValue) => { // console.log(newValue) setTxnMaxDate(newValue); }} /> {/*row 5*/} setReceiptFromError(newError)} slotProps={{ field: { readOnly: true, }, textField: { // helperText: receiptFromErrorMessage, InputLabelProps: { shrink: true } }, }} format="DD/MM/YYYY" label="Bank Credit Date (From)" value={collMinDate === null ? null : dayjs(collMinDate)} maxDate={collMaxDate === null ? null : dayjs(collMaxDate)} onChange={(newValue) => { // console.log(newValue) setCollMinDate(newValue); }} /> setReceiptFromError(newError)} slotProps={{ field: { readOnly: true, }, textField: { // helperText: receiptFromErrorMessage, InputLabelProps: { shrink: true } }, }} format="DD/MM/YYYY" label="Bank Credit Date (To)" value={collMaxDate === null ? null : dayjs(collMaxDate)} minDate={collMinDate === null ? null : dayjs(collMinDate)} onChange={(newValue) => { // console.log(newValue) setCollMaxDate(newValue); }} /> {/* */} {onLoad? : {/* {onDownload? : } */} }
); }; export default SearchPublicNoticeForm;