diff --git a/src/pages/PublicNotice/Search_GLD/SearchForm.js b/src/pages/PublicNotice/Search_GLD/SearchForm.js index 5573846..6cbe943 100644 --- a/src/pages/PublicNotice/Search_GLD/SearchForm.js +++ b/src/pages/PublicNotice/Search_GLD/SearchForm.js @@ -14,8 +14,25 @@ import * as FormatUtils from "utils/FormatUtils"; import { ThemeProvider } from "@emotion/react"; import { PNSPS_BUTTON_THEME } from "../../../themes/buttonConst"; import { useIntl } from "react-intl"; -// ==============================|| DASHBOARD - DEFAULT ||============================== // +import { makeStyles } from '@mui/styles'; +// ==============================|| DASHBOARD - DEFAULT ||============================== // +const useStyles = makeStyles(() => ({ + root: { + position: "relative" + }, + display: { + position: "absolute", + top: 2, + left: 12, + bottom: 2, + background: "white", + pointerEvents: "none", + right: 50, + display: "flex", + alignItems: "center" + }, +})); const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, issueComboData }) => { @@ -30,6 +47,60 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); + const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); + const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); + + React.useEffect(() => { + setFromDateValue(minDate); + }, [minDate]); + + React.useEffect(() => { + setToDateValue(maxDate); + }, [maxDate]); + + function FormDateInputComponent({ inputRef, ...props }) { + const classes = useStyles(); + return ( + <> +
+ {DateUtils.dateStr(fromDateValue) == "Invalid Date" ? + fromDateValue + : + DateUtils.dateStr(fromDateValue)} +
+ + + ); + } + + function ToDateInputComponent({ inputRef, ...props }) { + const classes = useStyles(); + return ( + <> +
+ {DateUtils.dateStr(toDateValue) == "Invalid Date" ? + toDateValue + : + DateUtils.dateStr(toDateValue)} +
+ + + ); + } const intl = useIntl(); const { locale } = intl; @@ -39,15 +110,22 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss const onSubmit = (data) => { data.status = selectedStatus?.type let typeArray = []; + let sentDateFrom = ""; + let sentDateTo = ""; for (let i = 0; i < type.length; i++) { typeArray.push(type[i].label); } + + if (fromDateValue != "dd / mm / yyyy" && toDateValue != "dd / mm / yyyy") { + sentDateFrom = DateUtils.dateValue(fromDateValue) + sentDateTo = DateUtils.dateValue(toDateValue) + } const temp = { appNo: data.appNo, - dateFrom: data.dateFrom, - dateTo: data.dateTo, + dateFrom: sentDateFrom, + dateTo: sentDateTo, contact: data.contact, status: (data.status === '' || data.status?.includes("all")) ? "" : data.status, orgId: (orgSelected?.key && orgSelected?.key > 0) ? orgSelected?.key : "", @@ -75,6 +153,8 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss setOrgSelected({}); setIssueSelected({}); setSelectedStatus({key: 0, label: 'All', type: 'all'}); + setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) + setMaxDate(DateUtils.dateValue(new Date())) reset(); } @@ -142,9 +222,11 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss type="date" label={"Submit Date (From)"} defaultValue={searchCriteria.dateFrom} - InputProps={{ inputProps: { max: maxDate } }} + InputProps={{ + inputComponent: FormDateInputComponent, + }} onChange={(newValue) => { - setMinDate(DateUtils.dateValue(newValue)); + setMinDate(newValue.target.value); }} InputLabelProps={{ shrink: true @@ -159,9 +241,11 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss shrink: true }} {...register("dateTo")} - InputProps={{ inputProps: { min: minDate } }} + InputProps={{ + inputComponent: ToDateInputComponent, + }} onChange={(newValue) => { - setMaxDate(DateUtils.dateValue(newValue)); + setMaxDate(newValue.target.value); }} id="dateTo" type="date" @@ -256,13 +340,18 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss options={orgCombo} size="small" value={orgSelected} - inputValue={(orgSelected?.label) ? orgSelected?.label : ""} + getOptionLabel={(option) => option.name? option.name : ""} + inputValue={orgSelected ? orgSelected.name : ""} onChange={(event, newValue) => { - setOrgSelected(newValue); + if (newValue !== null) { + setOrgSelected(newValue); + }else{ + setOrgSelected({}); + } }} renderInput={(params) => ( {FieldUtils.getComboField({ label: "Organisation:", valueName: "orgId", - getOptionLabel: (option) => option.brNo? option.brNo : "", + getOptionLabel: (option) => option.enCompanyName?option.enCompanyName:option.chCompanyName? option.chCompanyName : "", dataList: orgData, disabled: (!editMode), form: formik