fixed date range not updating on clear button pressed
This commit is contained in:
parent
493e43b38b
commit
9f9f113a0e
1 changed files with 16 additions and 3 deletions
|
@ -104,13 +104,21 @@ function _Search() {
|
||||||
query: _query.query ? _query.query.toString() : "",
|
query: _query.query ? _query.query.toString() : "",
|
||||||
}
|
}
|
||||||
|
|
||||||
const [dateRange, setDateRange] = useState([
|
const defaultDateRange = [
|
||||||
{
|
{
|
||||||
startDate: new Date(0), // default date
|
startDate: new Date(0),
|
||||||
endDate: null,
|
endDate: null,
|
||||||
key: "selection",
|
key: "selection",
|
||||||
},
|
},
|
||||||
])
|
]
|
||||||
|
|
||||||
|
const [dateRange, setDateRange] = useState<
|
||||||
|
Array<{
|
||||||
|
startDate: Date | null
|
||||||
|
endDate: Date | null
|
||||||
|
key?: string
|
||||||
|
}>
|
||||||
|
>(defaultDateRange)
|
||||||
|
|
||||||
const [postCards, setPostCards] = useState<unknown[]>([])
|
const [postCards, setPostCards] = useState<unknown[]>([])
|
||||||
|
|
||||||
|
@ -133,6 +141,9 @@ function _Search() {
|
||||||
ranges={dateRange}
|
ranges={dateRange}
|
||||||
onChange={(item) => {
|
onChange={(item) => {
|
||||||
const historyToPush = {
|
const historyToPush = {
|
||||||
|
...(query.query && {
|
||||||
|
query: query.query,
|
||||||
|
}),
|
||||||
...(query.from && {
|
...(query.from && {
|
||||||
from: query.from,
|
from: query.from,
|
||||||
}),
|
}),
|
||||||
|
@ -297,6 +308,8 @@ function _Search() {
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setDateRange(defaultDateRange)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
clear date
|
clear date
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue