Skip to content

Commit

Permalink
Update Property.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Apr 14, 2024
1 parent 8f922ba commit e5f529d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion frontend/src/pages/Property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const Property = () => {
const [from, setFrom] = useState<Date>()
const [to, setTo] = useState<Date>()
const [minDate, setMinDate] = useState<Date>()
const [maxDate, setMaxDate] = useState<Date>()
const [hideAction, setHideAction] = useState(true)

useEffect(() => {
Expand Down Expand Up @@ -76,6 +77,11 @@ const Property = () => {
setFrom(_from || undefined)
setTo(_to || undefined)
setMinDate(_from || undefined)
if (_to) {
const _maxDate = new Date(_to)
_maxDate.setDate(_maxDate.getDate() - 1)
setMaxDate(_maxDate)
}

try {
const _property = await PropertyService.getProperty(propertyId)
Expand Down Expand Up @@ -176,6 +182,7 @@ const Property = () => {
label={commonStrings.FROM}
value={from}
minDate={new Date()}
maxDate={maxDate}
variant="outlined"
required
onChange={(date) => {
Expand Down Expand Up @@ -204,7 +211,15 @@ const Property = () => {
variant="outlined"
required
onChange={(date) => {
setTo(date || undefined)
if (date) {
setTo(date)
const _maxDate = new Date(date)
_maxDate.setDate(_maxDate.getDate() - 1)
setMaxDate(_maxDate)
} else {
setTo(undefined)
setMaxDate(undefined)
}
}}
language={UserService.getLanguage()}
/>
Expand Down

0 comments on commit e5f529d

Please sign in to comment.