fixed min and max datetimes

This commit is contained in:
AmirHossein Mahmoodi
2025-09-02 10:09:00 +03:30
parent 1f585fe18e
commit 0253b06018
4 changed files with 52 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ import { Box, FormHelperText, IconButton, InputAdornment } from "@mui/material";
import ClearIcon from "@mui/icons-material/Clear";
import moment from "jalali-moment";
function MuiDatePicker({ value, setFieldValue, name, minDate, maxDate, helperText, placeholder, error, label }) {
function MuiDatePicker({ value, disableFuture = true, setFieldValue, name, minDate, maxDate, helperText, placeholder, error, label }) {
return (
<>
<Box sx={{ display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }}>
@@ -20,7 +20,7 @@ function MuiDatePicker({ value, setFieldValue, name, minDate, maxDate, helperTex
id={name}
name={name}
closeOnSelect
disableFuture
disableFuture={disableFuture}
label={label}
aria-describedby="component-helper-text"
onChange={(value) => {

View File

@@ -0,0 +1,9 @@
export const makeDateTime = (date, time) => {
if (!date) return null;
const d = new Date(date);
if (time) {
const t = new Date(time);
d.setHours(t.getHours(), t.getMinutes(), 0, 0);
}
return d;
};